diff options
author | Brad King <brad.king@kitware.com> | 2001-03-09 15:53:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2001-03-09 15:53:32 (GMT) |
commit | 5fc83004761394476f22d38fb75ed69bd6d7b16d (patch) | |
tree | 98765948d265b50366e992f1e40883fb0c7a5381 | |
parent | 60507258c786eb7b04f9248825659b47dc617c63 (diff) | |
download | CMake-5fc83004761394476f22d38fb75ed69bd6d7b16d.zip CMake-5fc83004761394476f22d38fb75ed69bd6d7b16d.tar.gz CMake-5fc83004761394476f22d38fb75ed69bd6d7b16d.tar.bz2 |
ENH: Added utility dependency support. Now a project can depend on other executables as well as link libraries.
-rw-r--r-- | Source/cmDSWMakefile.cxx | 15 | ||||
-rw-r--r-- | Source/cmDSWWriter.cxx | 15 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 12 | ||||
-rw-r--r-- | Source/cmMakefile.h | 28 | ||||
-rw-r--r-- | Source/cmUnixMakefileGenerator.cxx | 31 | ||||
-rw-r--r-- | Source/cmUnixMakefileGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmUtilitySourceCommand.cxx | 17 |
7 files changed, 108 insertions, 14 deletions
diff --git a/Source/cmDSWMakefile.cxx b/Source/cmDSWMakefile.cxx index 6534570..a61e2e9 100644 --- a/Source/cmDSWMakefile.cxx +++ b/Source/cmDSWMakefile.cxx @@ -130,7 +130,7 @@ void cmDSWMakefile::WriteProject(std::ostream& fout, { for(;i!= end; ++i) { - if (strcmp(i->c_str(),dspname)) + if(*i != dspname) { fout << "Begin Project Dependency\n"; fout << "Project_Dep_Name " << *i << "\n"; @@ -138,6 +138,19 @@ void cmDSWMakefile::WriteProject(std::ostream& fout, } } } + + // write utility dependencies. + i = project->GetMakefile()->GetUtilities().begin(); + end = project->GetMakefile()->GetUtilities().end(); + for(;i!= end; ++i) + { + if(*i != dspname) + { + fout << "Begin Project Dependency\n"; + fout << "Project_Dep_Name " << *i << "\n"; + fout << "End Project Dependency\n"; + } + } fout << "}}}\n\n"; } diff --git a/Source/cmDSWWriter.cxx b/Source/cmDSWWriter.cxx index 6534570..a61e2e9 100644 --- a/Source/cmDSWWriter.cxx +++ b/Source/cmDSWWriter.cxx @@ -130,7 +130,7 @@ void cmDSWMakefile::WriteProject(std::ostream& fout, { for(;i!= end; ++i) { - if (strcmp(i->c_str(),dspname)) + if(*i != dspname) { fout << "Begin Project Dependency\n"; fout << "Project_Dep_Name " << *i << "\n"; @@ -138,6 +138,19 @@ void cmDSWMakefile::WriteProject(std::ostream& fout, } } } + + // write utility dependencies. + i = project->GetMakefile()->GetUtilities().begin(); + end = project->GetMakefile()->GetUtilities().end(); + for(;i!= end; ++i) + { + if(*i != dspname) + { + fout << "Begin Project Dependency\n"; + fout << "Project_Dep_Name " << *i << "\n"; + fout << "End Project Dependency\n"; + } + } fout << "}}}\n\n"; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 673762d..f38cda2 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -106,6 +106,8 @@ void cmMakefile::Print() this->PrintStringVector("m_LinkLibraries", m_LinkLibraries); this->PrintStringVector("m_LinkLibrariesWin32", m_LinkLibrariesWin32); this->PrintStringVector("m_LinkLibrariesUnix", m_LinkLibrariesUnix); + this->PrintStringVector("m_Utilities", m_Utilities); + this->PrintStringVector("m_UtilityDirectories", m_UtilityDirectories); } // Parse the given CMakeLists.txt file into a list of classes. @@ -285,6 +287,16 @@ bool cmMakefile::HasExecutables() return false; } +void cmMakefile::AddUtility(const char* util) +{ + m_Utilities.push_back(util); +} + +void cmMakefile::AddUtilityDirectory(const char* dir) +{ + m_UtilityDirectories.push_back(dir); +} + void cmMakefile::AddLinkLibrary(const char* lib) { m_LinkLibraries.push_back(lib); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 7dee07b..62961e8 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -88,6 +88,16 @@ public: void AddExecutable(cmClassFile&); /** + * Add a utility on which this project depends. + */ + void AddUtility(const char*); + + /** + * Add a directory in which a utility may be built. + */ + void AddUtilityDirectory(const char*); + + /** * Add a link library to the build. */ void AddLinkLibrary(const char*); @@ -274,6 +284,22 @@ public: } /** + * Get a list of utilities on which the project depends. + */ + std::vector<std::string>& GetUtilities() + { + return m_Utilities; + } + + /** + * Get a list of directories that may contain the Utilities. + */ + std::vector<std::string>& GetUtilityDirectories() + { + return m_UtilityDirectories; + } + + /** * Get a list of link libraries in the build. */ std::vector<std::string>& GetLinkLibraries() @@ -396,6 +422,8 @@ protected: std::vector<std::string> m_MakeVerbatim; // lines copied from input file std::vector<std::string> m_IncludeDirectories; std::vector<std::string> m_LinkDirectories; + std::vector<std::string> m_Utilities; + std::vector<std::string> m_UtilityDirectories; std::vector<std::string> m_LinkLibraries; std::vector<std::string> m_LinkLibrariesWin32; std::vector<std::string> m_LinkLibrariesUnix; diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index e80d663..955b108 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -58,7 +58,7 @@ void cmUnixMakefileGenerator::OutputMakefile(const char* file) this->OutputVerbatim(fout); this->OutputExecutableRules(fout); this->OutputSubDirectoryRules(fout); - this->OutputDepends(fout); + this->OutputObjectDepends(fout); this->OutputCustomRules(fout); } @@ -102,7 +102,7 @@ void cmUnixMakefileGenerator::OutputSourceToObjectList(std::ostream& fout) // output the list of libraries that the executables // in this makefile will depend on. -void cmUnixMakefileGenerator::OutputDependLibraries(std::ostream& fout) +void cmUnixMakefileGenerator::OutputDependencies(std::ostream& fout) { std::vector<std::string>& libs = m_Makefile->GetLinkLibraries(); std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories(); @@ -130,6 +130,29 @@ void cmUnixMakefileGenerator::OutputDependLibraries(std::ostream& fout) } } } + + std::vector<std::string>& utils = m_Makefile->GetUtilities(); + std::vector<std::string>& utildirs = m_Makefile->GetUtilityDirectories(); + std::vector<std::string>::iterator util; + // Search the list of utilities that may be used to generate code for + // this project. + for(util = utils.begin(); util != utils.end(); ++util) + { + bool found = false; + // loop over the list of directories that the utilities might + // be in, looking for an EXECUTABLES=(util) line. + for(dir = utildirs.begin(); dir != utildirs.end() && !found; ++dir) + { + std::string expression = "EXECUTABLES.*=.*"; + expression += util->c_str(); + if(cmSystemTools::Grep(dir->c_str(), "CMakeTargets.make", + expression.c_str())) + { + fout << *util << " "; + found = true; + } + } + } fout << "\n"; } @@ -217,7 +240,7 @@ void cmUnixMakefileGenerator::OutputExecutableRules(std::ostream& fout) // each executable will depend on. This will have all the // libraries that the executable uses fout << "CMAKE_DEPEND_LIBS = "; - this->OutputDependLibraries(fout); + this->OutputDependencies(fout); // Now create rules for all of the executables to be built std::vector<cmClassFile>& Classes = m_Makefile->GetClasses(); for(unsigned int i = 0; i < Classes.size(); i++) @@ -340,7 +363,7 @@ void cmUnixMakefileGenerator::OutputSubDirectoryRules(std::ostream& fout) // Output the depend information for all the classes // in the makefile. These would have been generated // by the class cmMakeDepend GenerateMakefile -void cmUnixMakefileGenerator::OutputDepends(std::ostream& fout) +void cmUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout) { std::vector<cmClassFile>& Classes = m_Makefile->GetClasses(); for(unsigned int i = 0; i < Classes.size(); i++) diff --git a/Source/cmUnixMakefileGenerator.h b/Source/cmUnixMakefileGenerator.h index 0a5b17a..5a3925d 100644 --- a/Source/cmUnixMakefileGenerator.h +++ b/Source/cmUnixMakefileGenerator.h @@ -38,7 +38,7 @@ public: * in the makefile. These would have been generated * by the class cmMakeDepend. */ - void OutputDepends(std::ostream&); + void OutputObjectDepends(std::ostream&); protected: void OutputMakefile(const char* file); @@ -48,7 +48,7 @@ protected: void OutputExecutableRules(std::ostream&); void OutputSubDirectoryRules(std::ostream&); void OutputDependInformation(std::ostream&); - void OutputDependLibraries(std::ostream&); + void OutputDependencies(std::ostream&); void OutputCustomRules(std::ostream&); }; diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 32506d0..0cb83dd 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -60,13 +60,18 @@ bool cmUtilitySourceCommand::Invoke(std::vector<std::string>& args) { return true; } } - // The source exists. Construct the cache entry for the executable's - // location. + // The source exists. std::string cmakeCFGout = m_Makefile->GetDefinition("CMAKE_CFG_OUTDIR"); - std::string utilityExecutable = m_Makefile->GetCurrentOutputDirectory(); - utilityExecutable = - (utilityExecutable+"/"+relativeSource+"/"+cmakeCFGout+"/" - +utilityName+cmSystemTools::GetExecutableExtension()); + std::string utilityDirectory = m_Makefile->GetCurrentOutputDirectory(); + utilityDirectory += "/"+relativeSource; + + // Tell the makefile where to look for this utility. + m_Makefile->AddUtilityDirectory(utilityDirectory.c_str()); + + // Construct the cache entry for the executable's location. + std::string utilityExecutable = + utilityDirectory+"/"+cmakeCFGout+"/" + +utilityName+cmSystemTools::GetExecutableExtension(); // Enter the value into the cache. cmCacheManager::GetInstance()->AddCacheEntry(cacheEntry.c_str(), |