]> granicus.if.org Git - icinga2/commitdiff
Implement support for excluding files from unity builds
authorGunnar Beutner <gunnar@beutner.name>
Mon, 1 Sep 2014 07:19:21 +0000 (09:19 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 1 Sep 2014 07:19:21 +0000 (09:19 +0200)
refs #7034

lib/config/CMakeLists.txt
test/CMakeLists.txt
tools/mkclass/CMakeLists.txt
tools/mkunity/CMakeLists.txt

index 1929b824a4a3c5b624631f41048088f92895a453..a442540619b73b2151df928eaf955d2b01db530c 100644 (file)
@@ -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)
index 29f480794d31a58a239b085fed4fc49061ce102e..fc331fcac18978b94a8153d12fd470d7fe71b082 100644 (file)
@@ -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()
index f58742b4d3d888f11cabb4237d69f21891d44906..8a9f4de7e1edc95f0e5cbe83ff1d49167c14f503 100644 (file)
@@ -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()
index 18e331b5c6252f9964f782aa92ac7276b094ae0f..57af9d18eac4771a08f03a4d8645e2b8c5276719 100644 (file)
@@ -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(