From 445ff5ccdf7f888b48d12076fb42ca856482779f Mon Sep 17 00:00:00 2001 From: Daniel Eiband Date: Wed, 11 Sep 2019 11:22:40 +0200 Subject: Byproducts: collapse full paths of custom target byproducts Collapse full paths of add_custom_target command byproducts for symmetry with byproducts passed to the add_custom_command command. --- Source/cmAddCustomTargetCommand.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index caea510..ec5c1a7 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -127,7 +127,7 @@ bool cmAddCustomTargetCommand(std::vector const& args, } filename += copy; cmSystemTools::ConvertToUnixSlashes(filename); - byproducts.push_back(filename); + byproducts.push_back(cmSystemTools::CollapseFullPath(filename)); } break; case doing_depends: { std::string dep = copy; -- cgit v0.12 From 3b409643bd0f69d38d91bba6b64250e48b276398 Mon Sep 17 00:00:00 2001 From: Daniel Eiband Date: Mon, 16 Sep 2019 10:24:24 +0200 Subject: Byproducts: Add test for collapsing of full paths in byproducts Add test for collapsing of full paths in byproducts and additional tests for the GENERATED source file properties set by add_custom_command and add_custom_target with relative paths. --- Tests/CustomCommandByproducts/CMakeLists.txt | 10 +++++----- Tests/RunCMake/add_custom_command/GeneratedProperty.cmake | 10 ++++++++++ Tests/RunCMake/add_custom_command/RunCMakeTest.cmake | 1 + Tests/RunCMake/add_custom_target/GeneratedProperty.cmake | 14 ++++++++++++++ Tests/RunCMake/add_custom_target/RunCMakeTest.cmake | 1 + 5 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 Tests/RunCMake/add_custom_command/GeneratedProperty.cmake create mode 100644 Tests/RunCMake/add_custom_target/GeneratedProperty.cmake diff --git a/Tests/CustomCommandByproducts/CMakeLists.txt b/Tests/CustomCommandByproducts/CMakeLists.txt index bfa69ce..08c897c 100644 --- a/Tests/CustomCommandByproducts/CMakeLists.txt +++ b/Tests/CustomCommandByproducts/CMakeLists.txt @@ -14,20 +14,20 @@ add_custom_command( # Generate a byproduct in a rule that runs in a dependency of the consumer. add_custom_command( - OUTPUT timestamp2.txt + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/timestamp2.txt COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/byproduct2.c.in byproduct2.c - BYPRODUCTS byproduct2.c + BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct2.c COMMAND ${CMAKE_COMMAND} -E touch timestamp2.txt DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct2.c.in ) -add_custom_target(Producer2 DEPENDS timestamp2.txt) +add_custom_target(Producer2 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/timestamp2.txt) # Generate a byproduct in a custom target. add_custom_target(Producer3_4 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in byproduct3.c - BYPRODUCTS byproduct3.c + BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct3.c DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in ) @@ -36,7 +36,7 @@ add_custom_command( TARGET Producer3_4 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in byproduct4.c - BYPRODUCTS byproduct4.c + BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct4.c DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in ) diff --git a/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake b/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake new file mode 100644 index 0000000..628134b --- /dev/null +++ b/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake @@ -0,0 +1,10 @@ +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/a" + BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/b" + COMMAND c + ) +get_source_file_property(GENERATED_A "${CMAKE_CURRENT_BINARY_DIR}/a" GENERATED) +get_source_file_property(GENERATED_B "${CMAKE_CURRENT_BINARY_DIR}/b" GENERATED) +if(NOT GENERATED_A OR NOT GENERATED_B) + message(FATAL_ERROR "failed") +endif() diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake index 0387dbb..20097b7 100644 --- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(AppendNoOutput) run_cmake(AppendNotOutput) run_cmake(BadArgument) +run_cmake(GeneratedProperty) run_cmake(NoArguments) run_cmake(NoOutputOrTarget) run_cmake(OutputAndTarget) diff --git a/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake b/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake new file mode 100644 index 0000000..d034534 --- /dev/null +++ b/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake @@ -0,0 +1,14 @@ +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/a" + COMMAND b + ) +add_custom_target(CollapseFullPath + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/a" + BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/c" + COMMAND d + ) +get_source_file_property(GENERATED_A "${CMAKE_CURRENT_BINARY_DIR}/a" GENERATED) +get_source_file_property(GENERATED_C "${CMAKE_CURRENT_BINARY_DIR}/c" GENERATED) +if(NOT GENERATED_A OR NOT GENERATED_C) + message(FATAL_ERROR "failed") +endif() diff --git a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake index 2caed03..d80ca19 100644 --- a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake @@ -1,6 +1,7 @@ include(RunCMake) run_cmake(CommandExpandsEmpty) +run_cmake(GeneratedProperty) run_cmake(NoArguments) run_cmake(BadTargetName) run_cmake(ByproductsNoCommand) -- cgit v0.12