ENH: remove the rule to run make depend from the top with each change in any cmakelist file. Instead, run make depend in the current directory if a source file changes, or if a .h file changes or is removed
This commit is contained in:
parent
a9cdcba660
commit
e4843d83a4
|
@ -260,7 +260,7 @@ void cmNMakeMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
|
||||||
}
|
}
|
||||||
std::string currentDir = m_Makefile->GetCurrentOutputDirectory();
|
std::string currentDir = m_Makefile->GetCurrentOutputDirectory();
|
||||||
cmSystemTools::ConvertToWindowsSlashes(currentDir);
|
cmSystemTools::ConvertToWindowsSlashes(currentDir);
|
||||||
fout << "\tcd " << cmSystemTools::EscapeSpaces(currentDir.c_str()) << "\n";
|
fout << "\tcd " << cmSystemTools::EscapeSpaces(currentDir.c_str()) << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -720,8 +720,11 @@ void cmNMakeMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
|
||||||
std::string currentDir = m_Makefile->GetCurrentOutputDirectory();
|
std::string currentDir = m_Makefile->GetCurrentOutputDirectory();
|
||||||
cmSystemTools::ConvertToWindowsSlashes(currentDir);
|
cmSystemTools::ConvertToWindowsSlashes(currentDir);
|
||||||
fout << cmSystemTools::EscapeSpaces(fullpath)
|
fout << cmSystemTools::EscapeSpaces(fullpath)
|
||||||
<< ":\n\tcd " << cmSystemTools::EscapeSpaces(path)
|
<< ":\n\tcd " << cmSystemTools::EscapeSpaces(path) << "\n"
|
||||||
<< "\n\t$(MAKE) $(MAKESILENT) " << cmSystemTools::EscapeSpaces(fullpath)
|
<< "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.depends\n"
|
||||||
|
<< "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.check_depends\n"
|
||||||
|
<< "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) -f cmake.check_depends\n"
|
||||||
|
<< "\t$(MAKE) $(MAKESILENT) " << cmSystemTools::EscapeSpaces(fullpath)
|
||||||
<< "\n\tcd " <<
|
<< "\n\tcd " <<
|
||||||
cmSystemTools::EscapeSpaces(currentDir.c_str()) << "\n";
|
cmSystemTools::EscapeSpaces(currentDir.c_str()) << "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,13 +247,16 @@ void cmUnixMakefileGenerator::OutputMakefile(const char* file)
|
||||||
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->OutputMakeRule(fout,
|
this->
|
||||||
"Default target executed when no arguments are given to make",
|
OutputMakeRule(fout,
|
||||||
"default_target",
|
"Default target executed when no arguments are given to make, first make sure cmake.depends is up-to-date, then check the sources, then build the all target",
|
||||||
0,
|
"default_target",
|
||||||
"$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.depends_mark",
|
0,
|
||||||
"$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) all");
|
"$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.depends",
|
||||||
|
"$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.check_depends",
|
||||||
|
"$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) -f cmake.check_depends",
|
||||||
|
"$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) all");
|
||||||
|
|
||||||
this->OutputTargetRules(fout);
|
this->OutputTargetRules(fout);
|
||||||
this->OutputDependLibs(fout);
|
this->OutputDependLibs(fout);
|
||||||
this->OutputTargets(fout);
|
this->OutputTargets(fout);
|
||||||
|
@ -269,7 +272,26 @@ void cmUnixMakefileGenerator::OutputMakefile(const char* file)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dependout << "# .o dependencies in this directory." << std::endl;
|
dependout << "# .o dependencies in this directory." << std::endl;
|
||||||
this->OutputObjectDepends(dependout);
|
|
||||||
|
std::string checkDepend = m_Makefile->GetStartOutputDirectory();
|
||||||
|
checkDepend += "/cmake.check_depends";
|
||||||
|
std::ofstream checkdependout(checkDepend.c_str());
|
||||||
|
if(!checkdependout)
|
||||||
|
{
|
||||||
|
cmSystemTools::Error("Error can not open for write: ", checkDepend.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
checkdependout << "# This file is used as a tag file, that all sources depend on. If a source changes, then the rule to rebuild this file will cause cmake.depends to be rebuilt." << std::endl;
|
||||||
|
// if there were any depends output, then output the check depends
|
||||||
|
// information inot checkdependout
|
||||||
|
if(this->OutputObjectDepends(dependout))
|
||||||
|
{
|
||||||
|
this->OutputCheckDepends(checkdependout);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
checkdependout << "all:\n\tcd .\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this->OutputCustomRules(fout);
|
this->OutputCustomRules(fout);
|
||||||
this->OutputMakeRules(fout);
|
this->OutputMakeRules(fout);
|
||||||
|
@ -878,7 +900,10 @@ void cmUnixMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
|
||||||
}
|
}
|
||||||
fout << cmSystemTools::EscapeSpaces(fullpath)
|
fout << cmSystemTools::EscapeSpaces(fullpath)
|
||||||
<< ":\n\tcd " << cmSystemTools::EscapeSpaces(path)
|
<< ":\n\tcd " << cmSystemTools::EscapeSpaces(path)
|
||||||
<< "; $(MAKE) $(MAKESILENT) " << makeTarget << "\n\n";
|
<< "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.depends"
|
||||||
|
<< "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) cmake.check_depends"
|
||||||
|
<< "; $(MAKE) -$(MAKEFLAGS) $(MAKESILENT) -f cmake.check_depends"
|
||||||
|
<< "; $(MAKE) $(MAKESILENT) " << makeTarget << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmUnixMakefileGenerator::SamePath(const char* path1, const char* path2)
|
bool cmUnixMakefileGenerator::SamePath(const char* path1, const char* path2)
|
||||||
|
@ -984,6 +1009,7 @@ void cmUnixMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
|
||||||
fout << "\t@cd " << directory
|
fout << "\t@cd " << directory
|
||||||
<< "; $(MAKE) -$(MAKEFLAGS) " << target2 << "\n";
|
<< "; $(MAKE) -$(MAKEFLAGS) " << target2 << "\n";
|
||||||
}
|
}
|
||||||
|
fout << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1054,9 +1080,11 @@ void cmUnixMakefileGenerator::OutputSubDirectoryRules(std::ostream& fout)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->OutputSubDirectoryVars(fout, "SUBDIR_BUILD", "build",
|
this->OutputSubDirectoryVars(fout,
|
||||||
"cmake.depends_mark",
|
"SUBDIR_BUILD",
|
||||||
"all",
|
"default_target",
|
||||||
|
"default_target",
|
||||||
|
0,
|
||||||
SubDirectories);
|
SubDirectories);
|
||||||
this->OutputSubDirectoryVars(fout, "SUBDIR_CLEAN", "clean",
|
this->OutputSubDirectoryVars(fout, "SUBDIR_CLEAN", "clean",
|
||||||
"clean",
|
"clean",
|
||||||
|
@ -1078,8 +1106,9 @@ void cmUnixMakefileGenerator::OutputSubDirectoryRules(std::ostream& fout)
|
||||||
// Output the depend information for all the classes
|
// Output the depend information for all the classes
|
||||||
// in the makefile. These would have been generated
|
// in the makefile. These would have been generated
|
||||||
// by the class cmMakeDepend GenerateMakefile
|
// by the class cmMakeDepend GenerateMakefile
|
||||||
void cmUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout)
|
bool cmUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout)
|
||||||
{
|
{
|
||||||
|
bool ret = false;
|
||||||
// Iterate over every target.
|
// Iterate over every target.
|
||||||
std::map<cmStdString, cmTarget>& targets = m_Makefile->GetTargets();
|
std::map<cmStdString, cmTarget>& targets = m_Makefile->GetTargets();
|
||||||
for(std::map<cmStdString, cmTarget>::const_iterator target = targets.begin();
|
for(std::map<cmStdString, cmTarget>::const_iterator target = targets.begin();
|
||||||
|
@ -1100,16 +1129,80 @@ void cmUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout)
|
||||||
source->GetDepends().begin();
|
source->GetDepends().begin();
|
||||||
dep != source->GetDepends().end(); ++dep)
|
dep != source->GetDepends().end(); ++dep)
|
||||||
{
|
{
|
||||||
fout << " \\\n" << cmSystemTools::EscapeSpaces(dep->c_str());
|
fout << " \\\n"
|
||||||
|
<< this->ConvertToNativePath(cmSystemTools::EscapeSpaces(
|
||||||
|
dep->c_str()).c_str());
|
||||||
|
ret = true;
|
||||||
}
|
}
|
||||||
fout << "\n\n";
|
fout << "\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Output the depend information for all the classes
|
||||||
|
// in the makefile. These would have been generated
|
||||||
|
// by the class cmMakeDepend GenerateMakefile
|
||||||
|
void cmUnixMakefileGenerator::OutputCheckDepends(std::ostream& fout)
|
||||||
|
{
|
||||||
|
std::set<std::string> emitted;
|
||||||
|
// Iterate over every target.
|
||||||
|
std::map<cmStdString, cmTarget>& targets = m_Makefile->GetTargets();
|
||||||
|
this->OutputMakeVariables(fout);
|
||||||
|
fout << "default:\n";
|
||||||
|
fout << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) -f cmake.check_depends all\n"
|
||||||
|
<< "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) -f cmake.check_depends cmake.depends\n\n";
|
||||||
|
fout << "all: ";
|
||||||
|
for(std::map<cmStdString, cmTarget>::const_iterator target = targets.begin();
|
||||||
|
target != targets.end(); ++target)
|
||||||
|
{
|
||||||
|
// Iterate over every source for this target.
|
||||||
|
const std::vector<cmSourceFile>& sources = target->second.GetSourceFiles();
|
||||||
|
for(std::vector<cmSourceFile>::const_iterator source = sources.begin();
|
||||||
|
source != sources.end(); ++source)
|
||||||
|
{
|
||||||
|
if(!source->IsAHeaderFileOnly())
|
||||||
|
{
|
||||||
|
if(!source->GetDepends().empty())
|
||||||
|
{
|
||||||
|
for(std::vector<std::string>::const_iterator dep =
|
||||||
|
source->GetDepends().begin();
|
||||||
|
dep != source->GetDepends().end(); ++dep)
|
||||||
|
{
|
||||||
|
std::string dependfile =
|
||||||
|
this->ConvertToNativePath(cmSystemTools::EscapeSpaces(
|
||||||
|
dep->c_str()).c_str());
|
||||||
|
if(emitted.insert(dependfile).second)
|
||||||
|
{
|
||||||
|
fout << " \\\n" << dependfile ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fout << "\n\n# if any of these files changes run make dependlocal\n";
|
||||||
|
fout << "cmake.depends: ";
|
||||||
|
std::set<std::string>::iterator i;
|
||||||
|
for(i = emitted.begin(); i != emitted.end(); ++i)
|
||||||
|
{
|
||||||
|
fout << " \\\n" << *i;
|
||||||
|
}
|
||||||
|
fout << "\n\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) dependlocal\n\n";
|
||||||
|
fout << "\n\n";
|
||||||
|
fout << "# if a .h file is removed then run make dependlocal\n\n";
|
||||||
|
for(std::set<std::string>::iterator i = emitted.begin();
|
||||||
|
i != emitted.end(); ++i)
|
||||||
|
{
|
||||||
|
fout << *i << ":\n"
|
||||||
|
<< "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) dependlocal\n\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Output each custom rule in the following format:
|
// Output each custom rule in the following format:
|
||||||
// output: source depends...
|
// output: source depends...
|
||||||
// (tab) command...
|
// (tab) command...
|
||||||
|
@ -1482,7 +1575,7 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
|
||||||
this->OutputMakeRule(fout,
|
this->OutputMakeRule(fout,
|
||||||
"Default build rule",
|
"Default build rule",
|
||||||
"all",
|
"all",
|
||||||
"cmake.depends_mark $(TARGETS) $(SUBDIR_BUILD)",
|
"cmake.depends $(TARGETS) $(SUBDIR_BUILD)",
|
||||||
0);
|
0);
|
||||||
if (m_Makefile->IsOn("QT_WRAP_CPP") ||
|
if (m_Makefile->IsOn("QT_WRAP_CPP") ||
|
||||||
m_Makefile->IsOn("QT_WRAP_UI") ||
|
m_Makefile->IsOn("QT_WRAP_UI") ||
|
||||||
|
@ -1506,33 +1599,56 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
|
||||||
"-@ $(RM) $(CLEAN_OBJECT_FILES) $(EXECUTABLES)"
|
"-@ $(RM) $(CLEAN_OBJECT_FILES) $(EXECUTABLES)"
|
||||||
" $(TARGETS)");
|
" $(TARGETS)");
|
||||||
}
|
}
|
||||||
fout << "\n#Rule to build the cmake.depends and Makefile as side effect\n";
|
this->OutputMakeRule(fout,
|
||||||
fout << "cmake.depends_mark: $(CMAKE_MAKEFILE_SOURCES)\n";
|
"Rule to build the cmake.depends and Makefile as side effect, if a source cmakelist file is out of date.",
|
||||||
this->BuildInSubDirectory(fout,
|
"cmake.depends",
|
||||||
m_Makefile->GetHomeOutputDirectory(),
|
"$(CMAKE_MAKEFILE_SOURCES) ",
|
||||||
"depend", 0);
|
"$(CMAKE_COMMAND) "
|
||||||
const char* depend_subdirs = 0;
|
"-S$(CMAKE_CURRENT_SOURCE) -O$(CMAKE_CURRENT_BINARY) "
|
||||||
if(!m_Makefile->GetSubDirectories().empty())
|
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"
|
||||||
{
|
);
|
||||||
this->OutputMakeRule(fout,
|
|
||||||
"Rule to force build of cmake.depend in subdirectories",
|
|
||||||
"depend_subdirs",
|
|
||||||
"$(SUBDIR_DEPEND)",
|
|
||||||
0
|
|
||||||
);
|
|
||||||
depend_subdirs = "$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) depend_subdirs";
|
|
||||||
}
|
|
||||||
this->OutputMakeRule(fout,
|
this->OutputMakeRule(fout,
|
||||||
"Rule to force the build of cmake.depends",
|
"Rule to force the build of cmake.depends",
|
||||||
"depend",
|
"depend",
|
||||||
|
"$(SUBDIR_DEPEND)",
|
||||||
|
"$(CMAKE_COMMAND) "
|
||||||
|
"-S$(CMAKE_CURRENT_SOURCE) -O$(CMAKE_CURRENT_BINARY) "
|
||||||
|
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
|
||||||
|
this->OutputMakeRule(fout,
|
||||||
|
"Rule to force the build of cmake.depends "
|
||||||
|
"in the current directory only.",
|
||||||
|
"dependlocal",
|
||||||
0,
|
0,
|
||||||
"$(CMAKE_COMMAND) "
|
"$(CMAKE_COMMAND) "
|
||||||
"-S$(CMAKE_CURRENT_SOURCE) -O$(CMAKE_CURRENT_BINARY) "
|
"-S$(CMAKE_CURRENT_SOURCE) -O$(CMAKE_CURRENT_BINARY) "
|
||||||
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)",
|
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
|
||||||
"-$(RM) cmake.depends_mark",
|
|
||||||
"echo mark > cmake.depends_mark",
|
// collect up all the sources
|
||||||
depend_subdirs
|
std::string allsources;
|
||||||
);
|
std::map<cmStdString, cmTarget>& targets = m_Makefile->GetTargets();
|
||||||
|
for(std::map<cmStdString, cmTarget>::const_iterator target = targets.begin();
|
||||||
|
target != targets.end(); ++target)
|
||||||
|
{
|
||||||
|
// Iterate over every source for this target.
|
||||||
|
const std::vector<cmSourceFile>& sources = target->second.GetSourceFiles();
|
||||||
|
for(std::vector<cmSourceFile>::const_iterator source = sources.begin();
|
||||||
|
source != sources.end(); ++source)
|
||||||
|
{
|
||||||
|
if(!source->IsAHeaderFileOnly())
|
||||||
|
{
|
||||||
|
allsources += source->GetFullPath();
|
||||||
|
allsources += " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->OutputMakeRule(fout,
|
||||||
|
"rule to rebuild cmake.depends if a source file is changed.",
|
||||||
|
"cmake.check_depends",
|
||||||
|
allsources.c_str(),
|
||||||
|
"$(CMAKE_COMMAND) "
|
||||||
|
"-S$(CMAKE_CURRENT_SOURCE) -O$(CMAKE_CURRENT_BINARY) "
|
||||||
|
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)");
|
||||||
|
|
||||||
this->OutputMakeRule(fout,
|
this->OutputMakeRule(fout,
|
||||||
"Rebuild CMakeCache.txt file",
|
"Rebuild CMakeCache.txt file",
|
||||||
"rebuild_cache",
|
"rebuild_cache",
|
||||||
|
|
|
@ -91,7 +91,14 @@ public:
|
||||||
* in the makefile. These would have been generated
|
* in the makefile. These would have been generated
|
||||||
* by the class cmMakeDepend.
|
* by the class cmMakeDepend.
|
||||||
*/
|
*/
|
||||||
virtual void OutputObjectDepends(std::ostream&);
|
virtual bool OutputObjectDepends(std::ostream&);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the check depend information for all the classes
|
||||||
|
* in the makefile. These would have been generated
|
||||||
|
* by the class cmMakeDepend.
|
||||||
|
*/
|
||||||
|
virtual void OutputCheckDepends(std::ostream&);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to determine system infomation such as shared library
|
* Try to determine system infomation such as shared library
|
||||||
|
|
Loading…
Reference in New Issue