summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-11-12 14:03:22 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-11-12 14:03:39 (GMT)
commitea5d3f4d4c3094971e3938bf5b8b3abda99c53a5 (patch)
treeb0ed9f80f822f9f87f887fef8c0d972cd3f86d48 /Tests/RunCMake
parentad6da2d83f4897adf4108b6fc623ea11ee58feeb (diff)
parent129e3c65400a96c1f99b0fd6d445f1b9dc38ad51 (diff)
downloadCMake-ea5d3f4d4c3094971e3938bf5b8b3abda99c53a5.zip
CMake-ea5d3f4d4c3094971e3938bf5b8b3abda99c53a5.tar.gz
CMake-ea5d3f4d4c3094971e3938bf5b8b3abda99c53a5.tar.bz2
Merge topic 'unity-build-per-config'
129e3c6540 Unity Build: Fix per-config sources in multi-config generators ea289314ef VS: Fix pre-VS15.8 unity build exclusion of per-config sources 53990059da cmLocalGenerator: Add dedicated types to hold unity source info de6e362a88 cmLocalGenerator: Clarify name of method to write unity source include lines 3017b3e7d4 cmLocalGenerator: Simplify unity source copy-if-different logic 0b56f92576 cmLocalGenerator: De-duplicate unity source file generation Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6720
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/UnityBuild/RunCMakeTest.cmake16
-rw-r--r--Tests/RunCMake/UnityBuild/per_config_c.c16
-rw-r--r--Tests/RunCMake/UnityBuild/per_config_c.cmake12
-rw-r--r--Tests/RunCMake/UnityBuild/per_config_c_debug.c9
-rw-r--r--Tests/RunCMake/UnityBuild/per_config_c_other.c9
5 files changed, 62 insertions, 0 deletions
diff --git a/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake b/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake
index 8019f09..e3643c0 100644
--- a/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake
+++ b/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake
@@ -26,6 +26,22 @@ run_build(unitybuild_anon_ns)
run_build(unitybuild_anon_ns_no_unity_build)
run_build(unitybuild_anon_ns_group_mode)
+function(run_per_config name)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
+ run_cmake(${name})
+ set(RunCMake_TEST_NO_CLEAN 1)
+ if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ run_cmake_command(${name}-build-debug ${CMAKE_COMMAND} --build . --config Debug)
+ run_cmake_command(${name}-build-release ${CMAKE_COMMAND} --build . --config Release)
+ else()
+ run_cmake_command(${name}-build ${CMAKE_COMMAND} --build .)
+ endif()
+endfunction()
+
+if(NOT RunCMake_GENERATOR STREQUAL "Xcode")
+ run_per_config(per_config_c)
+endif()
+
function(run_test name)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
run_cmake(${name})
diff --git a/Tests/RunCMake/UnityBuild/per_config_c.c b/Tests/RunCMake/UnityBuild/per_config_c.c
new file mode 100644
index 0000000..081c7d3
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/per_config_c.c
@@ -0,0 +1,16 @@
+#ifdef CFG_DEBUG
+extern void per_config_c_debug(void);
+#endif
+#ifdef CFG_OTHER
+extern void per_config_c_other(void);
+#endif
+int main(void)
+{
+#ifdef CFG_DEBUG
+ per_config_c_debug();
+#endif
+#ifdef CFG_OTHER
+ per_config_c_other();
+#endif
+ return 0;
+}
diff --git a/Tests/RunCMake/UnityBuild/per_config_c.cmake b/Tests/RunCMake/UnityBuild/per_config_c.cmake
new file mode 100644
index 0000000..9f2ee48
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/per_config_c.cmake
@@ -0,0 +1,12 @@
+enable_language(C)
+
+add_executable(per_config_c per_config_c.c
+ "$<$<CONFIG:Debug>:per_config_c_debug.c>"
+ "$<$<NOT:$<CONFIG:Debug>>:per_config_c_other.c>"
+ )
+
+set_target_properties(per_config_c PROPERTIES UNITY_BUILD ON)
+target_compile_definitions(per_config_c PRIVATE
+ "$<$<CONFIG:Debug>:CFG_DEBUG>"
+ "$<$<NOT:$<CONFIG:Debug>>:CFG_OTHER>"
+ )
diff --git a/Tests/RunCMake/UnityBuild/per_config_c_debug.c b/Tests/RunCMake/UnityBuild/per_config_c_debug.c
new file mode 100644
index 0000000..6d32ead
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/per_config_c_debug.c
@@ -0,0 +1,9 @@
+#ifndef CFG_DEBUG
+# error "per_config_c_debug built without CFG_DEBUG"
+#endif
+#ifdef CFG_OTHER
+# error "per_config_c_debug built with CFG_OTHER"
+#endif
+void per_config_c_debug(void)
+{
+}
diff --git a/Tests/RunCMake/UnityBuild/per_config_c_other.c b/Tests/RunCMake/UnityBuild/per_config_c_other.c
new file mode 100644
index 0000000..89c7a6b
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/per_config_c_other.c
@@ -0,0 +1,9 @@
+#ifdef CFG_DEBUG
+# error "per_config_c_other built with CFG_DEBUG"
+#endif
+#ifndef CFG_OTHER
+# error "per_config_c_other built without CFG_OTHER"
+#endif
+void per_config_c_other(void)
+{
+}