From: Gunnar Beutner Date: Mon, 1 Sep 2014 07:19:21 +0000 (+0200) Subject: Implement support for excluding files from unity builds X-Git-Tag: v2.1.1~47 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=46f26024dc6a3aff3bc8744edce614b26ff5ff7d;p=icinga2 Implement support for excluding files from unity builds refs #7034 --- diff --git a/lib/config/CMakeLists.txt b/lib/config/CMakeLists.txt index 1929b824a..a44254061 100644 --- a/lib/config/CMakeLists.txt +++ b/lib/config/CMakeLists.txt @@ -19,7 +19,11 @@ find_package(BISON 2.3.0 REQUIRED) find_package(FLEX 2.5.31 REQUIRED) bison_target(config_parser config_parser.yy ${CMAKE_CURRENT_BINARY_DIR}/config_parser.cc) +set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/config_parser.cc PROPERTY EXCLUDE_UNITY_BUILD TRUE) + flex_target(config_lexer config_lexer.ll ${CMAKE_CURRENT_BINARY_DIR}/config_lexer.cc) +set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/config_lexer.cc PROPERTY EXCLUDE_UNITY_BUILD TRUE) + add_flex_bison_dependency(config_lexer config_parser) mkembedconfig_target(base-type.conf base-type.cpp) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 29f480794..fc331fcac 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,6 +25,8 @@ set(base_test_SOURCES icinga-perfdata.cpp test.cpp ) +set_property(SOURCE test.cpp PROPERTY EXCLUDE_UNITY_BUILD TRUE) + if(ICINGA2_UNITY_BUILD) mkunity_target(test base_test_SOURCES) endif() diff --git a/tools/mkclass/CMakeLists.txt b/tools/mkclass/CMakeLists.txt index f58742b4d..8a9f4de7e 100644 --- a/tools/mkclass/CMakeLists.txt +++ b/tools/mkclass/CMakeLists.txt @@ -41,4 +41,5 @@ macro(MKCLASS_TARGET ClassInput ClassOutput) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS mkclass ${ClassInput} ) + set_property(SOURCE ${ClassOutput} PROPERTY EXCLUDE_UNITY_BUILD) endmacro() diff --git a/tools/mkunity/CMakeLists.txt b/tools/mkunity/CMakeLists.txt index 18e331b5c..57af9d18e 100644 --- a/tools/mkunity/CMakeLists.txt +++ b/tools/mkunity/CMakeLists.txt @@ -22,16 +22,24 @@ set_target_properties ( FOLDER Bin ) +define_property( + SOURCE + PROPERTY EXCLUDE_UNITY_BUILD + BRIEF_DOCS "Whether to exclude the source file from unity builds" + FULL_DOCS "Specified whether a source file should be excluded from unity builds and should be built separately" +) + function(MKUNITY_TARGET Prefix UnityInputRef) set(UnityInput ${${UnityInputRef}}) set(UnityOutput ${CMAKE_CURRENT_BINARY_DIR}/${Prefix}_unity.cpp) set(RealSources "") set(UnitySources "") foreach(UnitySource ${UnityInput}) - if(${UnitySource} MATCHES "\\.cpp\$") - list(APPEND UnitySources ${UnitySource}) - else() + get_property(SourceExcluded SOURCE ${UnitySource} PROPERTY EXCLUDE_UNITY_BUILD) + if(SourceExcluded MATCHES TRUE OR NOT ${UnitySource} MATCHES "\\.(cpp|cxx|cc)\$") list(APPEND RealSources ${UnitySource}) + else() + list(APPEND UnitySources ${UnitySource}) endif() endforeach() add_custom_command(