summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2021-08-01 09:46:20 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2021-08-01 13:24:16 (GMT)
commit213fec4908a13bb0f414533eddfd72481bc50694 (patch)
tree06f958fb47d0152fc302261479f304be0592eff7 /Source/cmMakefileTargetGenerator.cxx
parent516ac348c7b14d8221e3f579454a8356e62d28d3 (diff)
downloadCMake-213fec4908a13bb0f414533eddfd72481bc50694.zip
CMake-213fec4908a13bb0f414533eddfd72481bc50694.tar.gz
CMake-213fec4908a13bb0f414533eddfd72481bc50694.tar.bz2
add_custom_command(DEPFILE) independent from CMAKE_DEPENDS_USE_COMPILER
Fixes: #22486
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx22
1 files changed, 20 insertions, 2 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 98c61fe..a3e5553 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -324,9 +324,25 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
this->LocalGenerator->MaybeRelativeToTopBinDir(dependFileNameFull))
<< "\n";
+ // Scan any custom commands to check if DEPFILE option is specified
+ bool ccGenerateDeps = false;
+ std::vector<cmSourceFile const*> customCommands;
+ this->GeneratorTarget->GetCustomCommands(customCommands,
+ this->GetConfigName());
+ for (cmSourceFile const* sf : customCommands) {
+ if (!sf->GetCustomCommand()->GetDepfile().empty()) {
+ ccGenerateDeps = true;
+ break;
+ }
+ }
+
std::string depsUseCompiler = "CMAKE_DEPENDS_USE_COMPILER";
- if (!this->Makefile->IsDefinitionSet(depsUseCompiler) ||
- this->Makefile->IsOn(depsUseCompiler)) {
+ bool compilerGenerateDeps =
+ this->GlobalGenerator->SupportsCompilerDependencies() &&
+ (!this->Makefile->IsDefinitionSet(depsUseCompiler) ||
+ this->Makefile->IsOn(depsUseCompiler));
+
+ if (compilerGenerateDeps || ccGenerateDeps) {
std::string compilerDependFile =
cmStrCat(this->TargetBuildDirectoryFull, "/compiler_depend.make");
*this->BuildFileStream << "# Include any dependencies generated by the "
@@ -361,7 +377,9 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
"management for "
<< this->GeneratorTarget->GetName() << ".\n";
}
+ }
+ if (compilerGenerateDeps) {
// deactivate no longer needed legacy dependency files
// Write an empty dependency file.
cmGeneratedFileStream legacyDepFileStream(