summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-02-07 19:18:54 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-02-07 19:18:54 (GMT)
commit67102d3252f744987762ae19c4bfffeb11cdd46e (patch)
tree90714a5acbd052779b36cf56940ebf2032068bbf
parentad17c37d345cd143a131e4b5f26196e0e749ec0e (diff)
downloadCMake-67102d3252f744987762ae19c4bfffeb11cdd46e.zip
CMake-67102d3252f744987762ae19c4bfffeb11cdd46e.tar.gz
CMake-67102d3252f744987762ae19c4bfffeb11cdd46e.tar.bz2
Ninja Multi-Config: Add support for DEPFILE option in add_custom_command()
And give other generators a path forward to add support in the future.
-rw-r--r--Source/cmAddCustomCommandCommand.cxx2
-rw-r--r--Source/cmGlobalGenerator.h2
-rw-r--r--Source/cmGlobalNinjaGenerator.h2
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile-check.cmake5
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile.cmake9
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake4
6 files changed, 23 insertions, 1 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index 5deba8b..231a2d6 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -174,7 +174,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
doing = doing_comment;
} else if (copy == keyDEPFILE) {
doing = doing_depfile;
- if (mf.GetGlobalGenerator()->GetName() != "Ninja") {
+ if (!mf.GetGlobalGenerator()->SupportsCustomCommandDepfile()) {
status.SetError("Option DEPFILE not supported by " +
mf.GetGlobalGenerator()->GetName());
return false;
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index e6ab1dd..0e7e03d 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -448,6 +448,8 @@ public:
MacFolder. */
virtual bool ShouldStripResourcePath(cmMakefile*) const;
+ virtual bool SupportsCustomCommandDepfile() const { return false; }
+
std::string GetSharedLibFlagsForLanguage(std::string const& lang) const;
/** Generate an <output>.rule file path for a given command output. */
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 0e53c0e..a59859e 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -211,6 +211,8 @@ public:
}
const char* GetCleanTargetName() const override { return "clean"; }
+ bool SupportsCustomCommandDepfile() const override { return true; }
+
virtual cmGeneratedFileStream* GetImplFileStream(
const std::string& /*config*/) const
{
diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile-check.cmake
new file mode 100644
index 0000000..c595b10
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile-check.cmake
@@ -0,0 +1,5 @@
+set(log "${RunCMake_BINARY_DIR}/CustomCommandDepfile-build/CMakeFiles/impl-Debug.ninja")
+file(READ "${log}" build_file)
+if(NOT "${build_file}" MATCHES "depfile = test\\.d")
+ set(RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: depfile = test.d")
+endif()
diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile.cmake
new file mode 100644
index 0000000..1a42670
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile.cmake
@@ -0,0 +1,9 @@
+add_custom_command(
+ OUTPUT main.copy.c
+ COMMAND "${CMAKE_COMMAND}" -E copy
+ "${CMAKE_CURRENT_SOURCE_DIR}/main.c"
+ main.copy.c
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+ DEPFILE "test.d"
+ )
+add_custom_target(copy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/main.copy.c")
diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
index 827e560..3626a29 100644
--- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
@@ -224,6 +224,10 @@ run_ninja(CustomCommandsAndTargets release-postbuild build-Release.ninja SubdirP
run_cmake_build(CustomCommandsAndTargets debug-targetpostbuild Debug TopTargetPostBuild)
run_ninja(CustomCommandsAndTargets release-targetpostbuild build-Release.ninja SubdirTargetPostBuild)
+unset(RunCMake_TEST_BINARY_DIR)
+
+run_cmake(CustomCommandDepfile)
+
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PostfixAndLocation-build)
set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_NMC_CROSS_CONFIGS=all")
run_cmake_configure(PostfixAndLocation)