summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/UnityBuild
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2021-01-22 07:49:17 (GMT)
committerCraig Scott <craig.scott@crascit.com>2021-01-22 20:14:05 (GMT)
commitee9da769725c3e58bbb002d648cfe75de94f7a78 (patch)
tree2c2d1121bc9fdcf5a5407e641b14af09dfcc322e /Tests/RunCMake/UnityBuild
parente93fb3c9c6f0c7141fea8c5daa4d7989332048d4 (diff)
downloadCMake-ee9da769725c3e58bbb002d648cfe75de94f7a78.zip
CMake-ee9da769725c3e58bbb002d648cfe75de94f7a78.tar.gz
CMake-ee9da769725c3e58bbb002d648cfe75de94f7a78.tar.bz2
Unity: Generate reproducible unity IDs for anonymous namespaces
Fixes: #21564
Diffstat (limited to 'Tests/RunCMake/UnityBuild')
-rw-r--r--Tests/RunCMake/UnityBuild/f.cxx5
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_anon_ns-build-check.cmake10
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_anon_ns.cmake2
3 files changed, 16 insertions, 1 deletions
diff --git a/Tests/RunCMake/UnityBuild/f.cxx b/Tests/RunCMake/UnityBuild/f.cxx
new file mode 100644
index 0000000..d5813c6
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/f.cxx
@@ -0,0 +1,5 @@
+int f(int x)
+{
+ (void)x;
+ return 0;
+}
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_anon_ns-build-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_anon_ns-build-check.cmake
new file mode 100644
index 0000000..746be32
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_anon_ns-build-check.cmake
@@ -0,0 +1,10 @@
+set(unitybuild_0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_cxx.cxx")
+
+file(STRINGS ${unitybuild_0} src)
+
+foreach(expectedRegex IN ITEMS "SRC_f\\.cxx" "BLD_s1\\.cpp")
+ if(NOT "${src}" MATCHES "${expectedRegex}")
+ set(RunCMake_TEST_FAILED "Generated unity file doesn't have a match for expected unity ID regex ${expectedRegex}")
+ return()
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_anon_ns.cmake b/Tests/RunCMake/UnityBuild/unitybuild_anon_ns.cmake
index 6f4878f..e05863d 100644
--- a/Tests/RunCMake/UnityBuild/unitybuild_anon_ns.cmake
+++ b/Tests/RunCMake/UnityBuild/unitybuild_anon_ns.cmake
@@ -4,7 +4,7 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/unitybuild_anon_ns_test_files.cmake)
write_unity_build_anon_ns_test_files(srcs)
-add_library(tgt SHARED ${srcs})
+add_library(tgt SHARED f.cxx ${srcs})
set_target_properties(tgt PROPERTIES UNITY_BUILD ON)