It uses CMake 3.16 built-in utilities to speed up build time: * Unity builds * Precompiled headers The feature is controlled via `ENABLE_FASTER_BUILD` CMake option (disabled by default). The option avaialble only on CMake >= 3.16. The feature is enabled per-target via `ie_faster_build` function. Some observations: * Don't have actual numbers for compile time, but subjectively can see speed up locally with VS 2019. * Unity builds gives much more effect, but has some restriction on source files, so are not used everywhere.
27 lines
579 B
CMake
27 lines
579 B
CMake
# Copyright (C) 2020 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
include(CMakeParseArguments)
|
|
|
|
function(ie_faster_build TARGET_NAME)
|
|
if(NOT ENABLE_FASTER_BUILD)
|
|
return()
|
|
endif()
|
|
|
|
cmake_parse_arguments(IE_FASTER_BUILD "UNITY" "" "PCH" ${ARGN})
|
|
|
|
if(IE_FASTER_BUILD_UNITY)
|
|
set_target_properties(${TARGET_NAME}
|
|
PROPERTIES
|
|
UNITY_BUILD ON
|
|
)
|
|
endif()
|
|
|
|
if(IE_FASTER_BUILD_PCH)
|
|
target_precompile_headers(${TARGET_NAME}
|
|
${IE_FASTER_BUILD_PCH}
|
|
)
|
|
endif()
|
|
endfunction()
|