diff options
author | Craig Scott <craig.scott@crascit.com> | 2021-01-22 07:49:17 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2021-01-22 20:14:05 (GMT) |
commit | ee9da769725c3e58bbb002d648cfe75de94f7a78 (patch) | |
tree | 2c2d1121bc9fdcf5a5407e641b14af09dfcc322e /Tests/RunCMake/UnityBuild | |
parent | e93fb3c9c6f0c7141fea8c5daa4d7989332048d4 (diff) | |
download | CMake-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.cxx | 5 | ||||
-rw-r--r-- | Tests/RunCMake/UnityBuild/unitybuild_anon_ns-build-check.cmake | 10 | ||||
-rw-r--r-- | Tests/RunCMake/UnityBuild/unitybuild_anon_ns.cmake | 2 |
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) |