diff options
author | Brad King <brad.king@kitware.com> | 2001-12-10 16:03:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2001-12-10 16:03:44 (GMT) |
commit | ee31c3e0a433c8ed31eac4d8ae898c67c7a51b17 (patch) | |
tree | 38243b41866b811c6ec18c7f444d097881da60df /Source | |
parent | a946931f91bfffe8ce06a9924beb424cb0233907 (diff) | |
download | CMake-ee31c3e0a433c8ed31eac4d8ae898c67c7a51b17.zip CMake-ee31c3e0a433c8ed31eac4d8ae898c67c7a51b17.tar.gz CMake-ee31c3e0a433c8ed31eac4d8ae898c67c7a51b17.tar.bz2 |
ENH: SUBDIR_DEPENDS command now does nothing. The parallel build functionality is now automatic. Dependencies are setup to force the same build order as a single threaded build, but multiple files in the same directory can be built simultaneously. Also fixed bug with inheriting CMakeLists.txt files when a directory level is skipped.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmMakefile.cxx | 28 | ||||
-rw-r--r-- | Source/cmMakefile.h | 15 | ||||
-rw-r--r-- | Source/cmSubdirDependsCommand.cxx | 12 | ||||
-rw-r--r-- | Source/cmSubdirDependsCommand.h | 19 | ||||
-rw-r--r-- | Source/cmUnixMakefileGenerator.cxx | 14 |
5 files changed, 34 insertions, 54 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 696b89b..81b4b33 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -560,12 +560,6 @@ void cmMakefile::AddSubDirectory(const char* sub) m_SubDirectories.push_back(sub); } -void cmMakefile::AddSubdirDependency(const char* subdir, - const char* dependency) -{ - m_SubdirDepends[subdir].insert(dependency); -} - void cmMakefile::AddIncludeDirectory(const char* inc, bool before) { // Don't add an include directory that is already present. Yes, @@ -812,12 +806,26 @@ std::string cmMakefile::GetParentListFileName(const char *currentFileName) // is there a CMakeLists.txt file in the parent directory ? parentFile = listsDir; parentFile += "/CMakeLists.txt"; - if(!cmSystemTools::FileExists(parentFile.c_str())) + while(!cmSystemTools::FileExists(parentFile.c_str())) { - parentFile = ""; - return parentFile; + // There is no CMakeLists.txt file in the parent directory. This + // can occur when coming out of a subdirectory resulting from a + // SUBDIRS(Foo/Bar) command (coming out of Bar into Foo). Try + // walking up until a CMakeLists.txt is found or the home + // directory is hit. + + // if we are in the home directory then stop, return 0 + if(m_cmHomeDirectory == listsDir) { return ""; } + + // is there a parent directory we can check + pos = listsDir.rfind('/'); + // if we could not find the directory return 0 + if(pos == std::string::npos) { return ""; } + listsDir = listsDir.substr(0, pos); + parentFile = listsDir; + parentFile += "/CMakeLists.txt"; } - + return parentFile; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index d3e9835..44d4d61 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -211,11 +211,6 @@ public: void AddSubDirectory(const char*); /** - * Add a subdirectory dependency. - */ - void AddSubdirDependency(const char* subdir, const char* dependency); - - /** * Add an include directory to the build. */ void AddIncludeDirectory(const char*, bool before = false); @@ -405,14 +400,6 @@ public: } /** - * Get the subdirectory dependencies for the given subdirectory. - */ - const std::set<cmStdString>& GetSubdirDepends(const char* subdir) - { - return m_SubdirDepends[subdir]; - } - - /** * Get a list of include directories in the build. */ std::vector<std::string>& GetIncludeDirectories() @@ -571,8 +558,6 @@ protected: { }; - std::map<cmStdString, StringSet > m_SubdirDepends; - // The include and link-library paths. These may have order // dependency, so they must be vectors (not set). std::vector<std::string> m_IncludeDirectories; diff --git a/Source/cmSubdirDependsCommand.cxx b/Source/cmSubdirDependsCommand.cxx index 9d92da4..3fbcc55 100644 --- a/Source/cmSubdirDependsCommand.cxx +++ b/Source/cmSubdirDependsCommand.cxx @@ -43,18 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // cmSubdirDependsCommand bool cmSubdirDependsCommand::InitialPass(std::vector<std::string> const& args) { - if(args.size() < 2) - { - this->SetError("called with incorrect number of arguments"); - return false; - } - std::vector<std::string>::const_iterator i = args.begin(); - std::string subdir = *i; - - for(++i; i != args.end(); ++i) - { - m_Makefile->AddSubdirDependency(subdir.c_str(), i->c_str()); - } return true; } diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h index 523a47b..a3fbd26 100644 --- a/Source/cmSubdirDependsCommand.h +++ b/Source/cmSubdirDependsCommand.h @@ -45,15 +45,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "cmCommand.h" /** \class cmSubdirDependsCommand - * \brief Specify a set of subdirectories which must be built before the - * given subdirectory. + * \brief Legacy command. Do not use. * - * cmSubdirDependsCommand specifies for one entry of a SUBDIRS command - * a set of the other entries that must be built before it. CMake - * will still walk the subdirectories in the order in which they - * appear in a SUBDIRS command, but the generated makefiles will be - * setup to be sure one directory is finished before another begins. - * This allows parallel builds to work correctly. + * cmSubdirDependsCommand has been left in CMake for compatability with + * projects already using it. Its functionality in supporting parallel + * builds is now automatic. The command does not do anything. */ class cmSubdirDependsCommand : public cmCommand { @@ -82,7 +78,7 @@ public: */ virtual const char* GetTerseDocumentation() { - return "Add a set of subdirectories on which another subdirectory depends."; + return "Legacy command. Does nothing."; } /** @@ -92,9 +88,8 @@ public: { return "SUBDIR_DEPENDS(subdir dep1 dep2 ...)\n" - "Add a set of subdirectories on which \"subdir\" depends.\n" - "This sets up the generated makefiles to build the subdirectries dep1, " - "dep2, ... before \"subdir\" itself."; + "Does not do anything. This command used to help projects order\n" + "parallel builds correctly. This functionality is now automatic."; } cmTypeMacro(cmSubdirDependsCommand, cmCommand); diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index 1a1c48f..0461723 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -1013,18 +1013,22 @@ OutputSubDirectoryVars(std::ostream& fout, } } fout << "# Targets for making " << target << " in subdirectories.\n"; + std::string last = ""; for(unsigned int i =0; i < SubDirectories.size(); i++) { std::string subdir = FixDirectoryName(SubDirectories[i].c_str()); fout << target << "_" << subdir.c_str() << ":"; - const std::set<cmStdString>& subdirDepends = m_Makefile->GetSubdirDepends(SubDirectories[i].c_str()); - for(std::set<cmStdString>::const_iterator d = subdirDepends.begin(); - d != subdirDepends.end(); ++d) + + // Make each subdirectory depend on previous one. This forces + // parallel builds (make -j 2) to build in same order as a single + // threaded build to avoid dependency problems. + if(i > 0) { - std::string fixed_d = FixDirectoryName(d->c_str()); - fout << " " << target << "_" << fixed_d.c_str(); + fout << " " << target << "_" << last.c_str(); } + fout << "\n"; + last = subdir; this->BuildInSubDirectory(fout, SubDirectories[i].c_str(), target1, target2); } |