diff options
author | Chris Mahoney <chris.mahoney@kitware.com> | 2023-07-21 15:24:14 (GMT) |
---|---|---|
committer | Chris Mahoney <chris.mahoney@kitware.com> | 2023-07-25 15:34:22 (GMT) |
commit | 3825d6ec981d20ee55b12aed8cc8f94ab1afc88f (patch) | |
tree | 334fde0ac2c06d6f2d4d7bd8c4277b3403e2fede /Tests | |
parent | 71e0887ea2c893504a4309c62de9f4e7db587de6 (diff) | |
download | CMake-3825d6ec981d20ee55b12aed8cc8f94ab1afc88f.zip CMake-3825d6ec981d20ee55b12aed8cc8f94ab1afc88f.tar.gz CMake-3825d6ec981d20ee55b12aed8cc8f94ab1afc88f.tar.bz2 |
add_custom_{command,target}: Teach JOB_SERVER_AWARE about WORKING_DIRECTORY
Issue: #16273
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/Make/Foo/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake | 32 | ||||
-rw-r--r-- | Tests/RunCMake/Make/GNUMakeJobServerAware.cmake | 27 |
3 files changed, 50 insertions, 13 deletions
diff --git a/Tests/RunCMake/Make/Foo/CMakeLists.txt b/Tests/RunCMake/Make/Foo/CMakeLists.txt new file mode 100644 index 0000000..baa6634 --- /dev/null +++ b/Tests/RunCMake/Make/Foo/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.26) +project(Foo NONE) + +add_custom_target(drive ALL COMMAND ${CMAKE_COMMAND} -E true) diff --git a/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake b/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake index 7c5c296..da18f00 100644 --- a/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake +++ b/Tests/RunCMake/Make/GNUMakeJobServerAware-check.cmake @@ -1,12 +1,26 @@ -# This test verifies that the commands in the generated Makefiles contain the -# `+` prefix -function(check_for_plus_prefix target) - set(file "${RunCMake_BINARY_DIR}/GNUMakeJobServerAware-build/${target}") - file(READ "${file}" build_file) - if(NOT "${build_file}" MATCHES [[\+]]) - message(FATAL_ERROR "The file ${file} does not contain the expected prefix in the custom command.") +set(BUILD_DIR "${RunCMake_BINARY_DIR}/GNUMakeJobServerAware-build") + +function(check target line) + # Read the file and split it into a list of lines + file(READ ${BUILD_DIR}/${target} contents) + STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}") + STRING(REGEX REPLACE "\n" ";" contents "${contents}") + + set(found FALSE) + foreach(entry ${contents}) + if("${entry}" MATCHES "${line}") + set(found TRUE) + break() + endif() + endforeach() + + if(NOT found) + message(FATAL_ERROR "Could not find '${line}' in ${BUILD_DIR}/${target}\n${contents}") endif() endfunction() -check_for_plus_prefix("CMakeFiles/dummy.dir/build.make") -check_for_plus_prefix("CMakeFiles/dummy2.dir/build.make") +check("CMakeFiles/dummy.dir/build.make" [[\+\$\(CMAKE_COMMAND\) -E true]]) +check("CMakeFiles/dummy2.dir/build.make" [[\+\$\(CMAKE_COMMAND\) -E true]]) + +check("CMakeFiles/dummy3.dir/build.make" [[\+cd (/d )?"?.*"? && \$\(CMAKE_COMMAND\) -E true]]) +check("CMakeFiles/dummy4.dir/build.make" [[\+cd (/d )?"?.*"? && \$\(CMAKE_COMMAND\) -E true]]) diff --git a/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake b/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake index 951c2d7..d92e842 100644 --- a/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake +++ b/Tests/RunCMake/Make/GNUMakeJobServerAware.cmake @@ -1,12 +1,31 @@ +# Test JOB_SERVER_AWARE with custom commands add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/custom-command" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/missing" JOB_SERVER_AWARE ON - COMMAND $(CMAKE_COMMAND) -E touch "${CMAKE_CURRENT_BINARY_DIR}/custom-command" + COMMAND $(CMAKE_COMMAND) -E true ) -add_custom_target(dummy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/custom-command") +add_custom_target(dummy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/missing") +# Test JOB_SERVER_AWARE with custom targets add_custom_target( dummy2 ALL JOB_SERVER_AWARE ON - COMMAND ${CMAKE_COMMAND} -E true + COMMAND $(CMAKE_COMMAND) -E true +) + +# Test JOB_SERVER_AWARE with custom commands with WORKING_DIRECTORY +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/missing2" + JOB_SERVER_AWARE ON + COMMAND $(CMAKE_COMMAND) -E true + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Foo" +) +add_custom_target(dummy3 ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/missing2") + +# Test JOB_SERVER_AWARE with custom targets with WORKING_DIRECTORY +add_custom_target( + dummy4 ALL + JOB_SERVER_AWARE ON + COMMAND $(CMAKE_COMMAND) -E true + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Foo" ) |