mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 20:00:38 -06:00
add_custom_command(DEPFILE) independent from CMAKE_DEPENDS_USE_COMPILER
Fixes: #22486
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
enable_language(C)
|
||||
|
||||
add_custom_command(OUTPUT main.c
|
||||
DEPFILE main.c.d
|
||||
COMMAND "${CMAKE_COMMAND}" -DINFILE=${CMAKE_CURRENT_SOURCE_DIR}/main.c -DOUTFILE=main.c -DDEPFILE=main.c.d
|
||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/GenerateDepFile.cmake"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.c)
|
||||
@@ -170,6 +170,10 @@ endif()
|
||||
|
||||
if (RunCMake_GENERATOR MATCHES "Makefiles")
|
||||
run_cmake(CustomCommandDependencies-BadArgs)
|
||||
run_cmake_with_options(CustomCommandDependencies-compiler-deps-legacy -DCMAKE_DEPENDS_USE_COMPILER=FALSE)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
run_cmake_command(CustomCommandDependencies-compiler-deps-legacy ${CMAKE_COMMAND} --build . --config Debug)
|
||||
unset(RunCMake_TEST_NO_CLEAN)
|
||||
endif()
|
||||
|
||||
if(RunCMake_GENERATOR MATCHES "Make|Ninja|Visual Studio|Xcode" AND
|
||||
|
||||
Reference in New Issue
Block a user