diff options
author | Brad King <brad.king@kitware.com> | 2024-01-10 15:14:03 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-01-10 15:14:23 (GMT) |
commit | 3d14d84443e22a799c521edf543bb85b7f03823e (patch) | |
tree | 672973bdc3951a22f2af27416dd9f3e133ac14a9 | |
parent | 67ba114875ba66cbf6dd810ce89bde58ecaaae47 (diff) | |
parent | 7198f0d149a05cae8dec3da601e4dd4fc8526276 (diff) | |
download | CMake-3d14d84443e22a799c521edf543bb85b7f03823e.zip CMake-3d14d84443e22a799c521edf543bb85b7f03823e.tar.gz CMake-3d14d84443e22a799c521edf543bb85b7f03823e.tar.bz2 |
Merge topic 'makefile-depfile' into release-3.28
7198f0d149 Makefile: Fix double escaping when DEPFILE is used
5162ff64d4 Makefile: Reduce string copies
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9138
4 files changed, 25 insertions, 4 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 74b4b75..90afb1b 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1722,11 +1722,10 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile( if (!ccg.GetCC().GetDepfile().empty()) { // Add dependency over timestamp file for dependencies management - auto dependTimestamp = cmSystemTools::ConvertToOutputPath( - this->LocalGenerator->MaybeRelativeToTopBinDir( - cmStrCat(this->TargetBuildDirectoryFull, "/compiler_depend.ts"))); + auto dependTimestamp = this->LocalGenerator->MaybeRelativeToTopBinDir( + cmStrCat(this->TargetBuildDirectoryFull, "/compiler_depend.ts")); - depends.push_back(dependTimestamp); + depends.emplace_back(std::move(dependTimestamp)); } // Write the rule. diff --git a/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake b/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake index 19c09c8..c3725a4 100644 --- a/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake +++ b/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake @@ -24,6 +24,17 @@ add_library(toplib STATIC toplib.c) add_subdirectory(DepfileSubdir) +set(TEST_SPACE 1) +if(CMAKE_GENERATOR STREQUAL "Unix Makefiles") + execute_process(COMMAND "${CMAKE_MAKE_PROGRAM}" no_such_target --version RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) + if(NOT res EQUAL 0 OR NOT out MATCHES "GNU") + set(TEST_SPACE 0) + endif() +endif() +if(TEST_SPACE) + add_subdirectory(DepfileSubdirWithSpace) +endif() + add_custom_command( OUTPUT toplib2.c DEPFILE toplib2.c.d diff --git a/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt new file mode 100644 index 0000000..204f740 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory("path with space") diff --git a/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt new file mode 100644 index 0000000..37c0a57 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt" + COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt" + DEPFILE dummy.txt.d +) + +add_custom_target(subdir_space ALL + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt" +) |