diff options
author | Brad King <brad.king@kitware.com> | 2023-03-10 16:47:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-03-12 11:51:58 (GMT) |
commit | d6353e74b4dc53b98943d5d66ab5ffb0bef04d08 (patch) | |
tree | 34aefc9b5c0bc8cba575968d9a245efd93330e5c /Tests/RunCMake | |
parent | 9db40bec4e1004baa8b397c8b52c248d8de71f67 (diff) | |
download | CMake-d6353e74b4dc53b98943d5d66ab5ffb0bef04d08.zip CMake-d6353e74b4dc53b98943d5d66ab5ffb0bef04d08.tar.gz CMake-d6353e74b4dc53b98943d5d66ab5ffb0bef04d08.tar.bz2 |
VS: Add policy to build custom commands concurrently
In commit 33c15ae2b9 (VS: Build custom commands concurrently when
possible, 2023-01-19, v3.26.0-rc1~56^2) we added `BuildInParallel` to
custom commands in `.vcxproj` files, but that had to be reverted by
commit abb1c12162 (VS: Revert "Build custom commands concurrently when
possible", 2023-03-07, v3.26.0-rc6~3^2) because some projects may have
custom commands that accidentally rely on serial execution in MSBuild.
Add a policy to use `BuildInParallel` for custom commands in projects
that have been updated to set the policy to `NEW`.
Fixes: #18405
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/VS10Project/CustomCommandParallel-check.cmake | 40 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/CustomCommandParallel.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 3 |
3 files changed, 48 insertions, 0 deletions
diff --git a/Tests/RunCMake/VS10Project/CustomCommandParallel-check.cmake b/Tests/RunCMake/VS10Project/CustomCommandParallel-check.cmake new file mode 100644 index 0000000..87e2f70 --- /dev/null +++ b/Tests/RunCMake/VS10Project/CustomCommandParallel-check.cmake @@ -0,0 +1,40 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(found_CustomBuild_cmp0147_new 0) +set(found_CustomBuild_cmp0147_old 0) +set(found_BuildInParallel_cmp0147_new 0) +set(found_BuildInParallel_cmp0147_old 0) +set(in_CustomBuild_cmp0147 "") +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES [[<CustomBuild Include=".*\\cmp0147-old\.txt\.rule">]]) + set(found_CustomBuild_cmp0147_old 1) + set(in_CustomBuild_cmp0147 "old") + endif() + if(line MATCHES [[<CustomBuild Include=".*\\cmp0147-new\.txt\.rule">]]) + set(found_CustomBuild_cmp0147_new 1) + set(in_CustomBuild_cmp0147 "new") + endif() + if(line MATCHES [[</CustomBuild>]]) + set(in_CustomBuild_cmp0147 "") + endif() + if(line MATCHES [[<BuildInParallel .*>true</BuildInParallel>]] AND in_CustomBuild_cmp0147) + set(found_BuildInParallel_cmp0147_${in_CustomBuild_cmp0147} 1) + endif() +endforeach() +if(NOT found_CustomBuild_cmp0147_new) + string(APPEND RunCMake_TEST_FAILED "CustomBuild for cmp0147-new.txt.rule not found in\n ${vcProjectFile}\n") +endif() +if(NOT found_CustomBuild_cmp0147_old) + string(APPEND RunCMake_TEST_FAILED "CustomBuild for cmp0147-old.txt.rule not found in\n ${vcProjectFile}\n") +endif() +if(NOT found_BuildInParallel_cmp0147_new) + string(APPEND RunCMake_TEST_FAILED "BuildInParallel for cmp0147-new.txt.rule not found in\n ${vcProjectFile}\n") +endif() +if(found_BuildInParallel_cmp0147_old) + string(APPEND RunCMake_TEST_FAILED "BuildInParallel for cmp0147-old.txt.rule incorrectly found in\n ${vcProjectFile}\n") +endif() diff --git a/Tests/RunCMake/VS10Project/CustomCommandParallel.cmake b/Tests/RunCMake/VS10Project/CustomCommandParallel.cmake new file mode 100644 index 0000000..784fc68 --- /dev/null +++ b/Tests/RunCMake/VS10Project/CustomCommandParallel.cmake @@ -0,0 +1,5 @@ +cmake_policy(VERSION 3.26) # CMP0147 left unset +add_custom_command(OUTPUT "cmp0147-old.txt" COMMAND echo) +cmake_policy(SET CMP0147 NEW) +add_custom_command(OUTPUT "cmp0147-new.txt" COMMAND echo) +add_custom_target(foo DEPENDS "cmp0147-old.txt" "cmp0147-new.txt") diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index ed74896..669049a 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -8,6 +8,9 @@ if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREA endif() run_cmake(CustomCommandGenex) +if(NOT RunCMake_GENERATOR MATCHES "^Visual Studio 1[1-5] ") + run_cmake(CustomCommandParallel) +endif() run_cmake(VsCsharpSourceGroup) run_cmake(VsCSharpCompilerOpts) run_cmake(ExplicitCMakeLists) |