diff options
-rw-r--r-- | Source/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Source/cmGlobalBorlandMakefileGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmGlobalNMakeMakefileGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmGlobalNMakeMakefileGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmGlobalUnixMakefileGenerator3.cxx | 5 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 6 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator2.cxx | 12 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator2.h | 4 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 43 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.h | 4 | ||||
-rw-r--r-- | Source/cmake.cxx | 35 |
11 files changed, 91 insertions, 38 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 4d2bfc73c8..01f786af84 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -52,12 +52,15 @@ SET(SRCS cmGlobalGenerator.h cmGlobalUnixMakefileGenerator.cxx cmGlobalUnixMakefileGenerator.h + cmGlobalUnixMakefileGenerator3.cxx + cmGlobalUnixMakefileGenerator3.h cmListFileCache.cxx cmListFileCache.h cmListFileLexer.c cmLocalGenerator.cxx cmLocalGenerator.h cmLocalUnixMakefileGenerator2.cxx + cmLocalUnixMakefileGenerator3.cxx cmMakeDepend.cxx cmMakeDepend.h cmMakefile.cxx diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 46fdec33c2..2693cc752c 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -15,7 +15,7 @@ =========================================================================*/ #include "cmGlobalBorlandMakefileGenerator.h" -#include "cmLocalUnixMakefileGenerator2.h" +#include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmake.h" @@ -33,14 +33,13 @@ void cmGlobalBorlandMakefileGenerator::EnableLanguage(std::vector<std::string>co mf->AddDefinition("BORLAND", "1"); mf->AddDefinition("CMAKE_GENERATOR_CC", "bcc32"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "bcc32"); - this->cmGlobalUnixMakefileGenerator::EnableLanguage(l, mf); + this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf); } ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator() { - cmLocalUnixMakefileGenerator2* lg = new cmLocalUnixMakefileGenerator2; - lg->SetEmptyCommand("@REM Borland Make needs a command here."); + cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3; lg->SetEchoNeedsQuote(false); lg->SetIncludeDirective("!include"); lg->SetWindowsShell(true); diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index fad31c3069..3e6be38307 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -15,7 +15,7 @@ =========================================================================*/ #include "cmGlobalNMakeMakefileGenerator.h" -#include "cmLocalUnixMakefileGenerator2.h" +#include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator() @@ -30,13 +30,13 @@ void cmGlobalNMakeMakefileGenerator::EnableLanguage(std::vector<std::string>cons // pick a default mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); - this->cmGlobalUnixMakefileGenerator::EnableLanguage(l, mf); + this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf); } ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalNMakeMakefileGenerator::CreateLocalGenerator() { - cmLocalUnixMakefileGenerator2* lg = new cmLocalUnixMakefileGenerator2; + cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3; lg->SetEchoNeedsQuote(false); lg->SetWindowsShell(true); lg->SetMakeSilentFlag("/nologo"); diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index 863d0b82c0..71dc6a3e1e 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -17,14 +17,14 @@ #ifndef cmGlobalNMakeMakefileGenerator_h #define cmGlobalNMakeMakefileGenerator_h -#include "cmGlobalUNIXMakefileGenerator.h" +#include "cmGlobalUNIXMakefileGenerator3.h" /** \class cmGlobalNMakeMakefileGenerator * \brief Write a NMake makefiles. * * cmGlobalNMakeMakefileGenerator manages nmake build process for a tree */ -class cmGlobalNMakeMakefileGenerator : public cmGlobalUnixMakefileGenerator +class cmGlobalNMakeMakefileGenerator : public cmGlobalUnixMakefileGenerator3 { public: cmGlobalNMakeMakefileGenerator(); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index ae278e3631..52838fd59b 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -187,6 +187,11 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // Write the do not edit header. lg->WriteDisclaimer(cmakefileStream); + // Save the generator name + cmakefileStream + << "# The generator used is:\n" + << "SET(CMAKE_DEPENDS_GENERATOR \"" << this->GetName() << "\")\n\n"; + // for each cmMakefile get its list of dependencies unsigned int i; std::vector<std::string> lfiles; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 989cc69d10..859a799941 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -134,6 +134,12 @@ public: ///! for existing files convert to output path and short path if spaces std::string ConvertToOutputForExisting(const char* p); + /** Called from command-line hook to check dependencies. */ + virtual void CheckDependencies(cmMakefile* /* mf */, bool /* verbose */) {}; + + /** Called from command-line hook to scan dependencies. */ + virtual bool ScanDependencies(std::vector<std::string> const& /* args */) {return true;}; + protected: /** Construct a script from the given list of command lines. */ std::string ConstructScript(const cmCustomCommandLines& commandLines, diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx index 4a8f6e2394..c8d2f17d9b 100644 --- a/Source/cmLocalUnixMakefileGenerator2.cxx +++ b/Source/cmLocalUnixMakefileGenerator2.cxx @@ -535,7 +535,9 @@ cmLocalUnixMakefileGenerator2 cmOStringStream depCmd; // TODO: Account for source file properties and directory-level // definitions when scanning for dependencies. - depCmd << "$(CMAKE_COMMAND) -E cmake_depends " << lang << " " + depCmd << "$(CMAKE_COMMAND) -E cmake_depends \"" + << m_GlobalGenerator->GetName() << "\" " + << lang << " " << this->ConvertToRelativeOutputPath(obj.c_str()) << " " << this->ConvertToRelativeOutputPath(source.GetFullPath().c_str()); commands.push_back(depCmd.str()); @@ -3131,17 +3133,17 @@ cmLocalUnixMakefileGenerator2 ::ScanDependencies(std::vector<std::string> const& args) { // Format of arguments is: - // $(CMAKE_COMMAND), cmake_depends, <lang>, <obj>, <src> + // $(CMAKE_COMMAND), cmake_depends, GeneratorName, <lang>, <obj>, <src> // The caller has ensured that all required arguments exist. // The language for which we are scanning dependencies. - std::string const& lang = args[2]; + std::string const& lang = args[3]; // The file to which to write dependencies. - const char* objFile = args[3].c_str(); + const char* objFile = args[4].c_str(); // The source file at which to start the scan. - const char* srcFile = args[4].c_str(); + const char* srcFile = args[5].c_str(); // Read the directory information file. cmake cm; diff --git a/Source/cmLocalUnixMakefileGenerator2.h b/Source/cmLocalUnixMakefileGenerator2.h index 645bb9e772..ac07a5eeea 100644 --- a/Source/cmLocalUnixMakefileGenerator2.h +++ b/Source/cmLocalUnixMakefileGenerator2.h @@ -94,10 +94,10 @@ public: virtual void Generate(); /** Called from command-line hook to scan dependencies. */ - static bool ScanDependencies(std::vector<std::string> const& args); + virtual bool ScanDependencies(std::vector<std::string> const& args); /** Called from command-line hook to check dependencies. */ - static void CheckDependencies(cmMakefile* mf, bool verbose); + virtual void CheckDependencies(cmMakefile* mf, bool verbose); protected: diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index a6dcb7668e..6e88284fd5 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -489,7 +489,9 @@ cmLocalUnixMakefileGenerator3 cmOStringStream depCmd; // TODO: Account for source file properties and directory-level // definitions when scanning for dependencies. - depCmd << "$(CMAKE_COMMAND) -E cmake_depends " << lang << " " + depCmd << "$(CMAKE_COMMAND) -E cmake_depends \"" + << m_GlobalGenerator->GetName() << "\" " + << lang << " " << relativeObj.c_str() << " " << m_GlobalGenerator->ConvertToHomeRelativeOutputPath (source.GetFullPath().c_str()); @@ -576,8 +578,12 @@ cmLocalUnixMakefileGenerator3 this->AppendFlags(flags, this->GetIncludeFlags(lang)); // Get the output paths for source and object files. - std::string sourceFile = - this->ConvertToOptionallyRelativeOutputPath(source.GetFullPath().c_str()); + std::string sourceFile = source.GetFullPath(); + if(m_UseRelativePaths) + { + sourceFile = m_GlobalGenerator->ConvertToHomeRelativePath(sourceFile.c_str()); + } + sourceFile = cmSystemTools::ConvertToOutputPath(sourceFile.c_str()); std::string objectFile = this->ConvertToRelativeOutputPath(obj.c_str()); @@ -2844,21 +2850,27 @@ cmLocalUnixMakefileGenerator3::GetDependsChecker(const std::string& lang, const char* objFile, bool verbose) { + cmDepends *ret = 0; if(lang == "C" || lang == "CXX" || lang == "RC") { - return new cmDependsC(dir, objFile, verbose); + ret = new cmDependsC(); } #ifdef CMAKE_BUILD_WITH_CMAKE else if(lang == "Fortran") { - return new cmDependsFortran(dir, objFile, verbose); + ret = new cmDependsFortran(); } else if(lang == "Java") { - return new cmDependsJava(dir, objFile, verbose); + ret = new cmDependsJava(); } #endif - return 0; + if (ret) + { + ret->SetTargetFile(dir, objFile, ".depend",".build.depend.make"); + ret->SetVerbose(verbose); + } + return ret; } //---------------------------------------------------------------------------- @@ -2867,17 +2879,17 @@ cmLocalUnixMakefileGenerator3 ::ScanDependencies(std::vector<std::string> const& args) { // Format of arguments is: - // $(CMAKE_COMMAND), cmake_depends, <lang>, <obj>, <src> + // $(CMAKE_COMMAND), cmake_depends, GeneratorName, <lang>, <obj>, <src> // The caller has ensured that all required arguments exist. // The language for which we are scanning dependencies. - std::string const& lang = args[2]; + std::string const& lang = args[3]; // The file to which to write dependencies. - const char* objFile = args[3].c_str(); + const char* objFile = args[4].c_str(); // The source file at which to start the scan. - const char* srcFile = args[4].c_str(); + const char* srcFile = args[5].c_str(); // Read the directory information file. cmake cm; @@ -2943,19 +2955,22 @@ cmLocalUnixMakefileGenerator3 if(lang == "C" || lang == "CXX" || lang == "RC") { // TODO: Handle RC (resource files) dependencies correctly. - cmDependsC scanner(".", objFile, srcFile, includes, + cmDependsC scanner(srcFile, includes, includeRegexScan.c_str(), includeRegexComplain.c_str()); + scanner.SetTargetFile(".",objFile,".depend",".build.depend.make"); return scanner.Write(); } #ifdef CMAKE_BUILD_WITH_CMAKE else if(lang == "Fortran") { - cmDependsFortran scanner(".", objFile, srcFile, includes); + cmDependsFortran scanner(srcFile, includes); + scanner.SetTargetFile(".",objFile,".depend",".build.depend.make"); return scanner.Write(); } else if(lang == "Java") { - cmDependsJava scanner(".", objFile, srcFile); + cmDependsJava scanner(srcFile); + scanner.SetTargetFile(".",objFile,".depend",".build.depend.make"); return scanner.Write(); } #endif diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 3b7ce12adc..78847b7859 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -119,10 +119,10 @@ public: /** Called from command-line hook to scan dependencies. */ - static bool ScanDependencies(std::vector<std::string> const& args); + virtual bool ScanDependencies(std::vector<std::string> const& args); /** Called from command-line hook to check dependencies. */ - static void CheckDependencies(cmMakefile* mf, bool verbose); + virtual void CheckDependencies(cmMakefile* mf, bool verbose); /** write some extra rules suahc as make test etc */ void WriteSpecialTargetsTop(std::ostream& makefileStream); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 9a77c1ff4f..898b6f214e 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -28,8 +28,6 @@ # include "cmVersion.h" #endif -#include "cmLocalUnixMakefileGenerator2.h" // For -E cmake_depends callback. - // only build kdevelop generator on non-windows platforms // when not bootstrapping cmake #if !defined(_WIN32) @@ -52,6 +50,7 @@ #else #endif #include "cmGlobalUnixMakefileGenerator.h" +#include "cmGlobalUnixMakefileGenerator3.h" #ifdef CMAKE_USE_KDEVELOP # include "cmGlobalKdevelopGenerator.h" @@ -827,9 +826,18 @@ int cmake::CMakeCommand(std::vector<std::string>& args) } // Internal CMake dependency scanning support. - else if (args[1] == "cmake_depends" && args.size() >= 5) + else if (args[1] == "cmake_depends" && args.size() >= 6) { - return cmLocalUnixMakefileGenerator2::ScanDependencies(args)? 0 : 1; + cmake cm; + cmGlobalGenerator *ggd = cm.CreateGlobalGenerator(args[2].c_str()); + ggd->SetCMakeInstance(&cm); + if (ggd) + { + std::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); + lgd->SetGlobalGenerator(ggd); + return lgd->ScanDependencies(args)? 0 : 1; + } + return 1; } #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -1103,7 +1111,7 @@ int cmake::Configure() } this->SetGlobalGenerator(gen); #else - this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator); + this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator2); #endif } if(!m_GlobalGenerator) @@ -1419,6 +1427,8 @@ void cmake::AddDefaultGenerators() #endif m_Generators[cmGlobalUnixMakefileGenerator::GetActualName()] = &cmGlobalUnixMakefileGenerator::New; + m_Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] = + &cmGlobalUnixMakefileGenerator3::New; #ifdef CMAKE_USE_XCODE m_Generators[cmGlobalXCodeGenerator::GetActualName()] = &cmGlobalXCodeGenerator::New; @@ -1618,7 +1628,20 @@ int cmake::CheckBuildSystem() // the make system's VERBOSE environment variable to enable verbose // output. bool verbose = cmSystemTools::GetEnv("VERBOSE") != 0; - cmLocalUnixMakefileGenerator2::CheckDependencies(mf, verbose); + + // compute depends based on the generator specified + const char* genName = mf->GetDefinition("CMAKE_DEPENDS_GENERATOR"); + if (!genName || genName[0] == '\0') + { + genName = "Unix Makefiles"; + } + cmGlobalGenerator *ggd = this->CreateGlobalGenerator(genName); + if (ggd) + { + std::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator()); + lgd->SetGlobalGenerator(ggd); + lgd->CheckDependencies(mf, verbose); + } // No need to rerun. return 0; |