diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-05-06 19:45:42 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2020-05-07 15:13:34 (GMT) |
commit | 9f4eb352fe1383f740876e3924205be1d4bf897c (patch) | |
tree | 6911d23d9c5f950860a9ba1d0048b4d7f1417f1c /Tests/RunCMake/VS10Project/UnityBuildNativeGrouped-check.cmake | |
parent | b00585adcc11afcf4d02d9d9927a929f33b19546 (diff) | |
download | CMake-9f4eb352fe1383f740876e3924205be1d4bf897c.zip CMake-9f4eb352fe1383f740876e3924205be1d4bf897c.tar.gz CMake-9f4eb352fe1383f740876e3924205be1d4bf897c.tar.bz2 |
Unity Builds: Support explicit specification of sources to groups
Instead of having CMake determine which files should go into each
unity file, the user can now use explicitly state the mapping.
Diffstat (limited to 'Tests/RunCMake/VS10Project/UnityBuildNativeGrouped-check.cmake')
-rw-r--r-- | Tests/RunCMake/VS10Project/UnityBuildNativeGrouped-check.cmake | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/Tests/RunCMake/VS10Project/UnityBuildNativeGrouped-check.cmake b/Tests/RunCMake/VS10Project/UnityBuildNativeGrouped-check.cmake new file mode 100644 index 0000000..d6380da --- /dev/null +++ b/Tests/RunCMake/VS10Project/UnityBuildNativeGrouped-check.cmake @@ -0,0 +1,56 @@ +set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_poolA_c.c") +if(NOT EXISTS "${unitybuild_c0}") + set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c0} does not exist.") + return() +endif() + +set(unitybuild_c1 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_poolB_c.c") +if(NOT EXISTS "${unitybuild_c1}") + set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c1} does not exist.") + return() +endif() + +set(tgt_project "${RunCMake_TEST_BINARY_DIR}/tgt.vcxproj") +if (NOT EXISTS "${tgt_project}") + set(RunCMake_TEST_FAILED "Generated project file ${tgt_project} doesn't exist.") + return() +endif() + +file(STRINGS ${tgt_project} tgt_projects_strings) + +foreach(line IN LISTS tgt_projects_strings) + if (line MATCHES "<EnableUnitySupport>true</EnableUnitySupport>") + set(have_unity_support ON) + endif() + + if (line MATCHES "<ClCompile Include=.*IncludeInUnityFile=\"false\" CustomUnityFile=\"true\"") + list(APPEND unity_source_lines ${line}) + endif() + + if (line MATCHES "<ClCompile Include=.*IncludeInUnityFile=\"true\" CustomUnityFile=\"true\"") + list(APPEND sources_list ${line}) + endif() +endforeach() + +if (NOT have_unity_support) + set(RunCMake_TEST_FAILED "Generated project should include the <EnableUnitySupport> block.") + return() +endif() + +string(REPLACE "\\" "/" unity_source_lines "${unity_source_lines}") +string(FIND "${unity_source_lines}" "CMakeFiles/tgt.dir/Unity/unity_poolA_c.c" unity_source_file_position) +if (unity_source_file_position EQUAL "-1") + set(RunCMake_TEST_FAILED "Generated project should include the generated unity source file 'poolA'.") + return() +endif() +string(FIND "${unity_source_lines}" "CMakeFiles/tgt.dir/Unity/unity_poolB_c.c" unity_source_file_position) +if (unity_source_file_position EQUAL "-1") + set(RunCMake_TEST_FAILED "Generated project should include the generated unity source file 'poolB'.") + return() +endif() + +list(LENGTH sources_list number_of_sources) +if(NOT number_of_sources EQUAL 7) + set(RunCMake_TEST_FAILED "Generated project doesn't include the expect number of files.") + return() +endif() |