ENH: add a rule to automatically re-run cmake from the top if the CMakeCache.txt file is changed
This commit is contained in:
parent
83f596ee9d
commit
7985bc118e
|
@ -456,8 +456,18 @@ bool cmCacheManager::SaveCache(const char* path)
|
||||||
cmSystemTools::CopyFileIfDifferent(tempFile.c_str(),
|
cmSystemTools::CopyFileIfDifferent(tempFile.c_str(),
|
||||||
cacheFile.c_str());
|
cacheFile.c_str());
|
||||||
cmSystemTools::RemoveFile(tempFile.c_str());
|
cmSystemTools::RemoveFile(tempFile.c_str());
|
||||||
return true;
|
std::string checkCacheFile = path;
|
||||||
|
checkCacheFile += "/cmake.check_cache";
|
||||||
|
std::ofstream checkCache(checkCacheFile.c_str());
|
||||||
|
if(!checkCache)
|
||||||
|
{
|
||||||
|
cmSystemTools::Error("Unable to open check cache file for write. ",
|
||||||
|
checkCacheFile.c_str());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
checkCache << "# This file is generated by cmake for dependency checking of the CMakeCache.txt file\n";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void cmCacheManager::OutputHelpString(std::ofstream& fout,
|
void cmCacheManager::OutputHelpString(std::ofstream& fout,
|
||||||
const std::string& helpString)
|
const std::string& helpString)
|
||||||
|
|
|
@ -215,12 +215,13 @@ void cmLocalUnixMakefileGenerator::OutputMakefile(const char* file,
|
||||||
fout << " " << cmSystemTools::ConvertToOutputPath(cacheFile.c_str());
|
fout << " " << cmSystemTools::ConvertToOutputPath(cacheFile.c_str());
|
||||||
fout << "\n\n\n";
|
fout << "\n\n\n";
|
||||||
this->OutputMakeVariables(fout);
|
this->OutputMakeVariables(fout);
|
||||||
|
|
||||||
// Set up the default target as the VERY first target, so that make with no arguments will run it
|
// Set up the default target as the VERY first target, so that make with no arguments will run it
|
||||||
this->
|
this->
|
||||||
OutputMakeRule(fout,
|
OutputMakeRule(fout,
|
||||||
"Default target executed when no arguments are given to make, first make sure cmake.depends exists, cmake.check_depends is up-to-date, check the sources, then build the all target",
|
"Default target executed when no arguments are given to make, first make sure cmake.depends exists, cmake.check_depends is up-to-date, check the sources, then build the all target",
|
||||||
"default_target",
|
"default_target",
|
||||||
0,
|
"$(CMAKE_BINARY_DIR)/cmake.check_cache",
|
||||||
"$(MAKE) $(MAKESILENT) cmake.depends",
|
"$(MAKE) $(MAKESILENT) cmake.depends",
|
||||||
"$(MAKE) $(MAKESILENT) cmake.check_depends",
|
"$(MAKE) $(MAKESILENT) cmake.check_depends",
|
||||||
"$(MAKE) $(MAKESILENT) -f cmake.check_depends",
|
"$(MAKE) $(MAKESILENT) -f cmake.check_depends",
|
||||||
|
@ -1568,6 +1569,7 @@ void cmLocalUnixMakefileGenerator::OutputSubDirectoryRules(std::ostream& fout)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->OutputSubDirectoryVars(fout,
|
this->OutputSubDirectoryVars(fout,
|
||||||
"SUBDIR_BUILD",
|
"SUBDIR_BUILD",
|
||||||
"default_target",
|
"default_target",
|
||||||
|
@ -2120,6 +2122,12 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
|
||||||
"$(CMAKE_BINARY_DIR)/CMakeCache.txt",
|
"$(CMAKE_BINARY_DIR)/CMakeCache.txt",
|
||||||
"$(CMAKE_COMMAND) "
|
"$(CMAKE_COMMAND) "
|
||||||
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
|
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
|
||||||
|
this->OutputMakeRule(fout,
|
||||||
|
"CMakeCache.txt because out-of-date:",
|
||||||
|
"$(CMAKE_BINARY_DIR)/cmake.check_cache",
|
||||||
|
"$(CMAKE_BINARY_DIR)/CMakeCache.txt",
|
||||||
|
"$(CMAKE_COMMAND) "
|
||||||
|
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
|
||||||
// if CMAKE_EDIT_COMMAND is defined then add a rule to run it
|
// if CMAKE_EDIT_COMMAND is defined then add a rule to run it
|
||||||
// called edit_cache
|
// called edit_cache
|
||||||
if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
|
if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND"))
|
||||||
|
|
Loading…
Reference in New Issue