diff options
-rw-r--r-- | CMakeSystemConfig.cmake.in | 2 | ||||
-rw-r--r-- | Source/CMakeBuildTargets.cxx | 24 | ||||
-rw-r--r-- | Source/Makefile.in | 2 | ||||
-rw-r--r-- | Source/cmCacheManager.cxx | 32 | ||||
-rw-r--r-- | Source/cmCommands.cxx | 10 | ||||
-rw-r--r-- | Source/cmConfigureFileCommand.cxx (renamed from Source/cmConfigureFile.cxx) | 49 | ||||
-rw-r--r-- | Source/cmConfigureFileCommand.h (renamed from Source/cmConfigureFile.h) | 14 | ||||
-rw-r--r-- | Source/cmExecProgramCommand.cxx | 71 | ||||
-rw-r--r-- | Source/cmExecProgramCommand.h (renamed from Source/cmExecProgram.h) | 14 | ||||
-rw-r--r-- | Source/cmMakeDirectoryCommand.cxx (renamed from Source/cmExecProgram.cxx) | 12 | ||||
-rw-r--r-- | Source/cmMakeDirectoryCommand.h | 101 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 62 | ||||
-rw-r--r-- | Source/cmMakefile.h | 7 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 22 | ||||
-rw-r--r-- | Source/cmUnixMakefileGenerator.cxx | 105 | ||||
-rw-r--r-- | Source/cmUnixMakefileGenerator.h | 23 |
16 files changed, 409 insertions, 141 deletions
diff --git a/CMakeSystemConfig.cmake.in b/CMakeSystemConfig.cmake.in index c7a04c7..c68d768 100644 --- a/CMakeSystemConfig.cmake.in +++ b/CMakeSystemConfig.cmake.in @@ -3,8 +3,6 @@ # in, which need not be the source directory # SET (WORDS_BIGENDIAN @CMAKE_WORDS_BIGENDIAN@) -SET (HAVE_LIMITS_H @HAVE_LIMITS_H@) -SET (HAVE_UNISTD_H @HAVE_UNISTD_H@) SET (CMAKE_USE_SPROC @CMAKE_USE_SPROC@) SET (CMAKE_USE_PTHREADS @CMAKE_USE_PTHREADS@) SET (CMAKE_HP_PTHREADS @CMAKE_HP_PTHREADS@) diff --git a/Source/CMakeBuildTargets.cxx b/Source/CMakeBuildTargets.cxx index 0fa4086..d813f35 100644 --- a/Source/CMakeBuildTargets.cxx +++ b/Source/CMakeBuildTargets.cxx @@ -104,14 +104,23 @@ int main(int ac, char** av) std::string path = arg.substr(2); mf.SetHomeOutputDirectory(path.c_str()); } + if(arg.find("-D",0) == 0) + { + std::string value = arg.substr(2); + mf.AddDefinition(value.c_str(), true); + } } } // Only generate makefiles if not trying to make the cache - if(!makeCache) + cmUnixMakefileGenerator* gen = new cmUnixMakefileGenerator; + mf.SetMakefileGenerator(gen); + if(makeCache) { - mf.SetMakefileGenerator(new cmUnixMakefileGenerator); + // generate only enough for the cache + gen->SetCacheOnlyOn(); + // generate for this makefile and all below it + gen->SetRecurseOn(); } - // Read and parse the input makefile mf.MakeStartDirectoriesCurrent(); @@ -137,14 +146,7 @@ int main(int ac, char** av) Usage(av[0]); return -1; } - if(makeCache) - { - mf.GenerateCacheOnly(); - } - else - { - mf.GenerateMakefile(); - } + mf.GenerateMakefile(); cmCacheManager::GetInstance()->SaveCache(&mf); if(makeCache) { diff --git a/Source/Makefile.in b/Source/Makefile.in index aff3e90..ba65e25 100644 --- a/Source/Makefile.in +++ b/Source/Makefile.in @@ -40,7 +40,7 @@ cmSourceFile.o : $(DEPENDS) cmDirectory.o : $(DEPENDS) cmCustomCommand.o : $(DEPENDS) cmUnixMakefileGenerator.o : $(DEPENDS) -cmCommands.o : $(DEPENDS) $(srcdir)/*.cxx +cmCommands.o : $(DEPENDS) $(srcdir)/*Command*.cxx cmTarget.o : $(DEPENDS) cmCacheManager.o : $(DEPENDS) cmSourceGroup.o : $(DEPENDS) diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index cdffb56..7582f37 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -185,13 +185,30 @@ bool cmCacheManager::SaveCache(const char* path) const for( std::map<std::string, CacheEntry>::const_iterator i = m_Cache.begin(); i != m_Cache.end(); ++i) { + const CacheEntry& ce = (*i).second; + CacheEntryType t = ce.m_Type; + if(t != INTERNAL) + { + // Format is key:type=value + cmCacheManager::OutputHelpString(fout, ce.m_HelpString); + fout << (*i).first.c_str() << ":" + << cmCacheManagerTypes[t] << "=" + << ce.m_Value << "\n"; + } + } + for( std::map<std::string, CacheEntry>::const_iterator i = m_Cache.begin(); + i != m_Cache.end(); ++i) + { const CacheEntry& ce = (*i).second; CacheEntryType t = ce.m_Type; - // Format is key:type=value - cmCacheManager::OutputHelpString(fout, ce.m_HelpString); - fout << (*i).first.c_str() << ":" - << cmCacheManagerTypes[t] << "=" - << ce.m_Value << "\n"; + if(t == INTERNAL) + { + // Format is key:type=value + cmCacheManager::OutputHelpString(fout, ce.m_HelpString); + fout << (*i).first.c_str() << ":" + << cmCacheManagerTypes[t] << "=" + << ce.m_Value << "\n"; + } } fout << "\n"; fout.close(); @@ -279,7 +296,10 @@ void cmCacheManager::PrintCache(std::ostream& out) const for(std::map<std::string, CacheEntry>::const_iterator i = m_Cache.begin(); i != m_Cache.end(); ++i) { - out << (*i).first.c_str() << " = " << (*i).second.m_Value.c_str() << std::endl; + if((*i).second.m_Type != INTERNAL) + { + out << (*i).first.c_str() << " = " << (*i).second.m_Value.c_str() << std::endl; + } } out << "\n\n"; out << "To change values in the CMakeCache, \nedit CMakeCache.txt in your output directory.\n"; diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 3da08aa..4ecb917 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -23,11 +23,11 @@ #include "cmCablePackageEntryCommand.cxx" #include "cmCableSourceFilesCommand.cxx" #include "cmCableWrapCommand.cxx" -#include "cmConfigureFile.cxx" +#include "cmConfigureFileCommand.cxx" #include "cmConfigureFileNoAutoconf.cxx" #include "cmElseCommand.cxx" #include "cmEndIfCommand.cxx" -#include "cmExecProgram.cxx" +#include "cmExecProgramCommand.cxx" #include "cmFindFileCommand.cxx" #include "cmFindIncludeCommand.cxx" #include "cmFindLibraryCommand.cxx" @@ -39,6 +39,7 @@ #include "cmIncludeRegularExpressionCommand.cxx" #include "cmLinkDirectoriesCommand.cxx" #include "cmLinkLibrariesCommand.cxx" +#include "cmMakeDirectoryCommand.cxx" #include "cmOptionCommand.cxx" #include "cmProjectCommand.cxx" #include "cmSetCommand.cxx" @@ -74,11 +75,11 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands) commands.push_back(new cmCablePackageCommand); commands.push_back(new cmCableSourceFilesCommand); commands.push_back(new cmCableWrapCommand); - commands.push_back(new cmConfigureFile); + commands.push_back(new cmConfigureFileCommand); commands.push_back(new cmConfigureFileNoAutoconf); commands.push_back(new cmElseCommand); commands.push_back(new cmEndIfCommand); - commands.push_back(new cmExecProgram); + commands.push_back(new cmExecProgramCommand); commands.push_back(new cmFindFileCommand); commands.push_back(new cmFindIncludeCommand); commands.push_back(new cmFindLibraryCommand); @@ -90,6 +91,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands) commands.push_back(new cmIncludeRegularExpressionCommand); commands.push_back(new cmLinkDirectoriesCommand); commands.push_back(new cmLinkLibrariesCommand); + commands.push_back(new cmMakeDirectoryCommand); commands.push_back(new cmOptionCommand); commands.push_back(new cmProjectCommand); commands.push_back(new cmSetCommand); diff --git a/Source/cmConfigureFile.cxx b/Source/cmConfigureFileCommand.cxx index 8171faf..77171a2 100644 --- a/Source/cmConfigureFile.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -38,22 +38,28 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ -#include "cmConfigureFile.h" +#include "cmConfigureFileCommand.h" -// cmConfigureFile -bool cmConfigureFile::Invoke(std::vector<std::string>& args) +// cmConfigureFileCommand +bool cmConfigureFileCommand::Invoke(std::vector<std::string>& args) { - if(args.size() != 2 ) + if(args.size() < 2 ) { this->SetError("called with incorrect number of arguments, expected 2"); return false; } m_InputFile = args[0]; m_OuputFile = args[1]; + m_CopyOnly = false; + if(args[2] == "COPYONLY") + { + m_CopyOnly = true; + } + return true; } -void cmConfigureFile::FinalPass() +void cmConfigureFileCommand::FinalPass() { m_Makefile->ExpandVariablesInString(m_InputFile); m_Makefile->ExpandVariablesInString(m_OuputFile); @@ -92,24 +98,25 @@ void cmConfigureFile::FinalPass() if(fin) { inLine = buffer; - m_Makefile->ExpandVariablesInString(inLine); - // This call will remove all tcl variable substitutions of the form ${Foo} - // m_Makefile->RemoveVariablesInString(inLine); - - // look for special cmakedefine symbol and handle it - // is the symbol defined - if (cmdefine.find(inLine)) + if(!m_CopyOnly) { - const char *def = m_Makefile->GetDefinition(cmdefine.match(1).c_str()); - if(!cmSystemTools::IsOff(def)) - { - cmSystemTools::ReplaceString(inLine, - "#cmakedefine", "#define"); - } - else + m_Makefile->ExpandVariablesInString(inLine); + m_Makefile->RemoveVariablesInString(inLine); + // look for special cmakedefine symbol and handle it + // is the symbol defined + if (cmdefine.find(inLine)) { - cmSystemTools::ReplaceString(inLine, - "#cmakedefine", "#undef"); + const char *def = m_Makefile->GetDefinition(cmdefine.match(1).c_str()); + if(!cmSystemTools::IsOff(def)) + { + cmSystemTools::ReplaceString(inLine, + "#cmakedefine", "#define"); + } + else + { + cmSystemTools::ReplaceString(inLine, + "#cmakedefine", "#undef"); + } } } fout << inLine << "\n"; diff --git a/Source/cmConfigureFile.h b/Source/cmConfigureFileCommand.h index 54d3e5d..e827f92 100644 --- a/Source/cmConfigureFile.h +++ b/Source/cmConfigureFileCommand.h @@ -38,18 +38,18 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ -#ifndef cmConfigureFile_h -#define cmConfigureFile_h +#ifndef cmConfigureFileCommand_h +#define cmConfigureFileCommand_h #include "cmStandardIncludes.h" #include "cmCommand.h" -class cmConfigureFile : public cmCommand +class cmConfigureFileCommand : public cmCommand { public: virtual cmCommand* Clone() { - return new cmConfigureFile; + return new cmConfigureFileCommand; } /** @@ -77,12 +77,13 @@ public: virtual const char* GetFullDocumentation() { return - "CONFIGURE_FILE(InputFile OutputFile)\n" + "CONFIGURE_FILE(InputFile OutputFile [COPYONLY])\n" "The Input and Ouput files have to have full paths.\n" "They can also use variables like CMAKE_BINARY_DIR,CMAKE_SOURCE_DIR.\n" "This command replaces any variables in the input file with their\n" "values as determined by CMake. If a variables in not defined, it\n" - "will be replaced with nothing."; + "will be replaced with nothing. If COPYONLY is passed in, then\n" + "then no varible expansion will take place.\n"; } /** @@ -93,6 +94,7 @@ public: private: std::string m_InputFile; std::string m_OuputFile; + bool m_CopyOnly; }; diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx new file mode 100644 index 0000000..b9f94ca --- /dev/null +++ b/Source/cmExecProgramCommand.cxx @@ -0,0 +1,71 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + +Copyright (c) 2001 Insight Consortium +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name of the Insight Consortium, nor the names of any consortium members, + nor of any contributors, may be used to endorse or promote products derived + from this software without specific prior written permission. + + * Modified source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=========================================================================*/ +#include "cmExecProgramCommand.h" +#include "cmSystemTools.h" + +// cmExecProgramCommand +bool cmExecProgramCommand::Invoke(std::vector<std::string>& args) +{ + if(args.size() < 1 ) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + std::string output; + m_Makefile->ExpandVariablesInString(args[0]); + m_Makefile->ExpandVariablesInString(args[1]); + if(args.size() == 2) + { + cmSystemTools::MakeDirectory(args[1].c_str()); + std::string command; + command = "cd "; + command += args[1].c_str(); + command += "; "; + command += args[0].c_str(); + cmSystemTools::RunCommand(command.c_str(), output); + } + else + { + cmSystemTools::RunCommand(args[0].c_str(), output); + } + return true; +} + diff --git a/Source/cmExecProgram.h b/Source/cmExecProgramCommand.h index 26044f4..5e2ea5e 100644 --- a/Source/cmExecProgram.h +++ b/Source/cmExecProgramCommand.h @@ -38,20 +38,20 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ -#ifndef cmExecProgram_h -#define cmExecProgram_h +#ifndef cmExecProgramCommand_h +#define cmExecProgramCommand_h #include "cmStandardIncludes.h" #include "cmCommand.h" -/** \class cmExecProgram +/** \class cmExecProgramCommand * \brief Command that adds a target to the build system. * - * cmExecProgram adds an extra target to the build system. + * cmExecProgramCommand adds an extra target to the build system. * This is useful when you would like to add special * targets like "install,", "clean," and so on. */ -class cmExecProgram : public cmCommand +class cmExecProgramCommand : public cmCommand { public: /** @@ -59,7 +59,7 @@ public: */ virtual cmCommand* Clone() { - return new cmExecProgram; + return new cmExecProgramCommand; } /** @@ -91,7 +91,7 @@ public: "EXEC_PROGRAM(Executble )"; } - cmTypeMacro(cmExecProgram, cmCommand); + cmTypeMacro(cmExecProgramCommand, cmCommand); }; #endif diff --git a/Source/cmExecProgram.cxx b/Source/cmMakeDirectoryCommand.cxx index a1850ff..4ccefc5 100644 --- a/Source/cmExecProgram.cxx +++ b/Source/cmMakeDirectoryCommand.cxx @@ -38,19 +38,19 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ -#include "cmExecProgram.h" -#include "cmSystemTools.h" +#include "cmMakeDirectoryCommand.h" +#include "cmDirectory.h" -// cmExecProgram -bool cmExecProgram::Invoke(std::vector<std::string>& args) +// cmMakeDirectoryCommand +bool cmMakeDirectoryCommand::Invoke(std::vector<std::string>& args) { if(args.size() < 1 ) { this->SetError("called with incorrect number of arguments"); return false; } - std::string output; - cmSystemTools::RunCommand(args[0].c_str(), output); + m_Makefile->ExpandVariablesInString(args[0]); + cmSystemTools::MakeDirectory(args[0].c_str()); return true; } diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h new file mode 100644 index 0000000..3f9db4c --- /dev/null +++ b/Source/cmMakeDirectoryCommand.h @@ -0,0 +1,101 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + +Copyright (c) 2001 Insight Consortium +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name of the Insight Consortium, nor the names of any consortium members, + nor of any contributors, may be used to endorse or promote products derived + from this software without specific prior written permission. + + * Modified source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=========================================================================*/ +#ifndef cmMakeDirectoryCommand_h +#define cmMakeDirectoryCommand_h + +#include "cmStandardIncludes.h" +#include "cmCommand.h" + +/** \class cmMakeDirectoryCommand + * \brief Specify auxiliary source code directories. + * + * cmMakeDirectoryCommand specifies source code directories + * that must be built as part of this build process. This directories + * are not recursively processed like the SUBDIR command (cmSubdirCommand). + * A side effect of this command is to create a subdirectory in the build + * directory structure. + */ +class cmMakeDirectoryCommand : public cmCommand +{ +public: + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + return new cmMakeDirectoryCommand; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool Invoke(std::vector<std::string>& args); + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual const char* GetName() { return "MAKE_DIRECTORY";} + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() + { + return "Create a directory in the build tree if it does not exist.\n" + "Parent directories will be created if the do not exist.."; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() + { + return + "MAKE_DIRECTORY(directory)"; + } + + cmTypeMacro(cmMakeDirectoryCommand, cmCommand); +}; + + + +#endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d8dfe2f..c5d566e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -75,7 +75,7 @@ void cmMakefile::AddDefaultCommands() { this->AddCommand(*i); } -#ifdef _WIN32 +#if defined(_WIN32) || defined(__CYGWIN__) this->AddDefinition("WIN32", "1"); #else this->AddDefinition("UNIX", "1"); @@ -729,66 +729,6 @@ cmMakefile::FindSubDirectoryCMakeListsFiles(std::vector<cmMakefile*>& } } - -void cmMakefile::GenerateCacheOnly() -{ - std::vector<cmMakefile*> makefiles; - this->FindSubDirectoryCMakeListsFiles(makefiles); - for(std::vector<cmMakefile*>::iterator i = makefiles.begin(); - i != makefiles.end(); ++i) - { - cmMakefile* mf = *i; - std::string source = mf->GetHomeDirectory(); - source += "/CMake/CMakeMakefileTemplate.in"; - cmSystemTools::MakeDirectory(mf->GetStartOutputDirectory()); - std::string dest = mf->GetStartOutputDirectory(); - dest += "/Makefile"; - std::ofstream fout(dest.c_str()); - std::cout << "cmake: creating : " << dest.c_str() << "\n"; - if(!fout) - { - cmSystemTools::Error("Failed to open file for write " , dest.c_str()); - } - else - { - if(strcmp(mf->GetHomeDirectory(), - mf->GetHomeOutputDirectory()) == 0) - { - fout << "srcdir = .\n\n"; - } - else - { - fout << "srcdir = " << mf->GetStartDirectory() << "\n"; - fout << "VPATH = " << mf->GetStartDirectory() << "\n"; - } - } - fout << "include " - << mf->GetHomeOutputDirectory() << "/CMake/CMakeMaster.make\n"; - dest = mf->GetStartOutputDirectory(); - dest += "/CMakeTargets.make"; - // make sure there is a CMakeTargets.make file as some - // makes require it to exist - if(!cmSystemTools::FileExists(dest.c_str())) - { - std::cout << "cmake: creating : " << dest.c_str() << "\n"; - std::ofstream fout(dest.c_str()); - if(!fout) - { - cmSystemTools::Error("Failed to open file for write " , dest.c_str()); - } - fout << "#Initial CMakeTargets.make file created only to keep \n"; - fout << "#certain makes happy that don't like to include makefiles\n"; - fout << "#that do not exist\n"; - } - } - - // CLEAN up the makefiles created - for(unsigned int i =0; i < makefiles.size(); ++i) - { - delete makefiles[i]; - } -} - /** * Add the default definitions to the makefile. These values must not diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 4823d36..6692c68 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -466,13 +466,6 @@ public: */ void FindSubDirectoryCMakeListsFiles(std::vector<cmMakefile*>& makefiles); - /** Generate the cache file only. This is done - * by calling FindSubDirectoryCMakeListsFiles which - * will cause all the rules to fire, and the cache to - * be filled. - */ - void GenerateCacheOnly(); - /** * find what source group this source is in */ diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7e01101..afc92e8 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -563,6 +563,10 @@ bool cmSystemTools::IsOff(const char* val) bool cmSystemTools::RunCommand(const char* command, std::string& output) { + const int BUFFER_SIZE = 4096; + char buffer[BUFFER_SIZE]; + +#if defined(WIN32) && !defined(__CYGWIN__) std::string commandToFile = command; commandToFile += " > "; std::string tempFile; @@ -576,8 +580,6 @@ bool cmSystemTools::RunCommand(const char* command, tempFile.c_str()); return false; } - const int BUFFER_SIZE = 4096; - char buffer[BUFFER_SIZE]; while(fin) { fin.getline(buffer, BUFFER_SIZE); @@ -585,6 +587,22 @@ bool cmSystemTools::RunCommand(const char* command, } cmSystemTools::RemoveFile(tempFile.c_str()); return true; +#else + std::cout << "runing " << command << std::endl; + FILE* cpipe = popen(command, "r"); + if(!cpipe) + { + return false; + } + fgets(buffer, BUFFER_SIZE, cpipe); + while(!feof(cpipe)) + { + std::cout << buffer; + output += buffer; + fgets(buffer, BUFFER_SIZE, cpipe); + } + fclose(cpipe); +#endif } #ifdef _MSC_VER diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index be72113..14339f5 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -46,14 +46,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "cmMakeDepend.h" #include "cmCacheManager.h" +cmUnixMakefileGenerator::cmUnixMakefileGenerator() +{ + m_CacheOnly = false; + m_Recurse = false; +} + void cmUnixMakefileGenerator::GenerateMakefile() { - // Generate depends - cmMakeDepend md; - md.SetMakefile(m_Makefile); - md.DoDepends(); - // output the makefile fragment - this->OutputMakefile("CMakeTargets.make"); + if(m_CacheOnly) + { + // Generate the cache only stuff + this->GenerateCacheOnly(); + // if recurse then generate for all sub- makefiles + if(m_Recurse) + { + this->RecursiveGenerateCacheOnly(); + } + } + // normal makefile output + else + { + // Generate depends + cmMakeDepend md; + md.SetMakefile(m_Makefile); + md.DoDepends(); + // output the makefile fragment + this->OutputMakefile("CMakeTargets.make"); + } } @@ -539,3 +559,76 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) } } } + + +void cmUnixMakefileGenerator::GenerateCacheOnly() +{ + + std::string source = m_Makefile->GetHomeDirectory(); + source += "/CMake/CMakeMakefileTemplate.in"; + cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory()); + std::string dest = m_Makefile->GetStartOutputDirectory(); + dest += "/Makefile"; + std::ofstream fout(dest.c_str()); + std::cout << "cmake: creating : " << dest.c_str() << "\n"; + if(!fout) + { + cmSystemTools::Error("Failed to open file for write " , dest.c_str()); + } + else + { + if(strcmp(m_Makefile->GetHomeDirectory(), + m_Makefile->GetHomeOutputDirectory()) == 0) + { + fout << "srcdir = .\n\n"; + } + else + { + fout << "srcdir = " << m_Makefile->GetStartDirectory() << "\n"; + fout << "VPATH = " << m_Makefile->GetStartDirectory() << "\n"; + } + } + fout << "include " + << m_Makefile->GetHomeOutputDirectory() << "/CMake/CMakeMaster.make\n"; + dest = m_Makefile->GetStartOutputDirectory(); + dest += "/CMakeTargets.make"; + // make sure there is a CMakeTargets.make file as some + // makes require it to exist + if(!cmSystemTools::FileExists(dest.c_str())) + { + std::cout << "cmake: creating : " << dest.c_str() << "\n"; + std::ofstream fout(dest.c_str()); + if(!fout) + { + cmSystemTools::Error("Failed to open file for write " , dest.c_str()); + } + fout << "#Initial CMakeTargets.make file created only to keep \n"; + fout << "#certain makes happy that don't like to include makefiles\n"; + fout << "#that do not exist\n"; + } +} + +void cmUnixMakefileGenerator::RecursiveGenerateCacheOnly() +{ + std::vector<cmMakefile*> makefiles; + m_Makefile->FindSubDirectoryCMakeListsFiles(makefiles); + for(std::vector<cmMakefile*>::iterator i = makefiles.begin(); + i != makefiles.end(); ++i) + { + cmMakefile* mf = *i; + if(m_Makefile->GetDefinition("RUN_CONFIGURE")) + { + mf->AddDefinition("RUN_CONFIGURE", true); + } + cmUnixMakefileGenerator* gen = new cmUnixMakefileGenerator; + gen->SetCacheOnlyOn(); + gen->SetRecurseOff(); + mf->SetMakefileGenerator(gen); + mf->GenerateMakefile(); + } + // CLEAN up the makefiles created + for(unsigned int i =0; i < makefiles.size(); ++i) + { + delete makefiles[i]; + } +} diff --git a/Source/cmUnixMakefileGenerator.h b/Source/cmUnixMakefileGenerator.h index 4e8b069..ca13919 100644 --- a/Source/cmUnixMakefileGenerator.h +++ b/Source/cmUnixMakefileGenerator.h @@ -53,6 +53,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class cmUnixMakefileGenerator : public cmMakefileGenerator { public: + ///! Set cache only and recurse to false by default. + cmUnixMakefileGenerator(); + + /** + * If cache only is on. + * and only stub makefiles are generated, and no depends, for speed. + * The default is OFF. + **/ + void SetCacheOnlyOn() {m_CacheOnly = true;} + void SetCacheOnlyOff() {m_CacheOnly = false;} + /** + * If recurse is on, then all the makefiles below this one are parsed as well. + */ + void SetRecurseOn() {m_Recurse = true;} + void SetRecurseOff() {m_Recurse = false;} + /** * Produce the makefile (in this case a Unix makefile). */ @@ -65,7 +81,9 @@ public: */ void OutputObjectDepends(std::ostream&); -protected: +private: + void RecursiveGenerateCacheOnly(); + void GenerateCacheOnly(); void OutputMakefile(const char* file); void OutputMakeFlags(std::ostream&); void OutputVerbatim(std::ostream&); @@ -76,6 +94,9 @@ protected: void OutputDependInformation(std::ostream&); void OutputDependencies(std::ostream&); void OutputCustomRules(std::ostream&); +private: + bool m_CacheOnly; + bool m_Recurse; }; #endif |