diff options
28 files changed, 77 insertions, 42 deletions
diff --git a/Source/cmEnableLanguageCommand.cxx b/Source/cmEnableLanguageCommand.cxx index c778884..2713b62 100644 --- a/Source/cmEnableLanguageCommand.cxx +++ b/Source/cmEnableLanguageCommand.cxx @@ -20,13 +20,29 @@ bool cmEnableLanguageCommand ::InitialPass(std::vector<std::string> const& args) { + bool optional = false; + std::vector<std::string> languages; if(args.size() < 1 ) { this->SetError ("ENABLE_LANGUAGE called with incorrect number of arguments"); return false; } - this->Makefile->EnableLanguage(args); + for (std::vector<std::string>::const_iterator it = args.begin(); + it != args.end(); + ++it) + { + if ((*it) == "OPTIONAL") + { + optional = true; + } + else + { + languages.push_back(*it); + } + } + + this->Makefile->EnableLanguage(languages, optional); return true; } diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h index decb788..c1c99d1 100644 --- a/Source/cmEnableLanguageCommand.h +++ b/Source/cmEnableLanguageCommand.h @@ -63,11 +63,13 @@ public: virtual const char* GetFullDocumentation() { return - " ENABLE_LANGUAGE(languageName)\n" + " ENABLE_LANGUAGE(languageName [OPTIONAL] )\n" "This command enables support for the named language in CMake. " "This is the same as the project command but does not create " "any of the extra varaibles that are created by the project command. " - "Example languages are CXX, C, Fortran."; + "Example languages are CXX, C, Fortran.\n" + "If OPTIONAL is used, use the CMAKE_<languageName>_COMPILER_WORKS " + "variable to check whether the language has been enabled successfully."; } cmTypeMacro(cmEnableLanguageCommand, cmCommand); diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 959cbe8..8f66924 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -30,13 +30,15 @@ cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator() void cmGlobalBorlandMakefileGenerator -::EnableLanguage(std::vector<std::string>const& l, cmMakefile *mf) +::EnableLanguage(std::vector<std::string>const& l, + cmMakefile *mf, + bool optional) { std::string outdir = this->CMakeInstance->GetStartOutputDirectory(); mf->AddDefinition("BORLAND", "1"); mf->AddDefinition("CMAKE_GENERATOR_CC", "bcc32"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "bcc32"); - this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf); + this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } ///! Create a local generator appropriate to this Global Generator diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index a6ec084..b77a644 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -47,7 +47,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *); + cmMakefile *, bool optional); }; #endif diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 75c946f..df46f49 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -196,7 +196,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) void cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *mf) + cmMakefile *mf, bool optional) { if(languages.size() == 0) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 7785c9a..959945c 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -77,7 +77,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *); + cmMakefile *, bool optional); /** * Try to determine system infomation, get it from another generator diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index 0c76625..084d85b 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -50,7 +50,9 @@ cmGlobalMSYSMakefileGenerator::FindMinGW(std::string const& makeloc) } void cmGlobalMSYSMakefileGenerator -::EnableLanguage(std::vector<std::string>const& l, cmMakefile *mf) +::EnableLanguage(std::vector<std::string>const& l, + cmMakefile *mf, + bool optional) { this->FindMakeProgram(mf); std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); @@ -75,7 +77,7 @@ void cmGlobalMSYSMakefileGenerator mf->AddDefinition("MSYS", "1"); mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str()); mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str()); - this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf); + this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); if(!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile()) { cmSystemTools::Error diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h index 9baecf2..cdedb3b 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.h +++ b/Source/cmGlobalMSYSMakefileGenerator.h @@ -47,7 +47,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *); + cmMakefile *, bool optional); private: std::string FindMinGW(std::string const& makeloc); diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index 89a01d8..5aeb74b 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -27,7 +27,9 @@ cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator() } void cmGlobalMinGWMakefileGenerator -::EnableLanguage(std::vector<std::string>const& l, cmMakefile *mf) +::EnableLanguage(std::vector<std::string>const& l, + cmMakefile *mf, + bool optional) { this->FindMakeProgram(mf); std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); @@ -49,7 +51,7 @@ void cmGlobalMinGWMakefileGenerator } mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str()); mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str()); - this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf); + this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } ///! Create a local generator appropriate to this Global Generator diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h index 3459459..8af3d34 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.h +++ b/Source/cmGlobalMinGWMakefileGenerator.h @@ -46,7 +46,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *); + cmMakefile *, bool optional); }; #endif diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index e86c7c6..5ae3ebb 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -27,12 +27,14 @@ cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator() } void cmGlobalNMakeMakefileGenerator -::EnableLanguage(std::vector<std::string>const& l, cmMakefile *mf) +::EnableLanguage(std::vector<std::string>const& l, + cmMakefile *mf, + bool optional) { // pick a default mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); - this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf); + this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } ///! Create a local generator appropriate to this Global Generator diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index 511ee89..efdd3f6 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -46,7 +46,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *); + cmMakefile *, bool optional); }; #endif diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index ef6fa90..6945b0d 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -39,9 +39,11 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3() } void cmGlobalUnixMakefileGenerator3 -::EnableLanguage(std::vector<std::string>const& languages, cmMakefile *mf) +::EnableLanguage(std::vector<std::string>const& languages, + cmMakefile *mf, + bool optional) { - this->cmGlobalGenerator::EnableLanguage(languages, mf); + this->cmGlobalGenerator::EnableLanguage(languages, mf, optional); std::string path; for(std::vector<std::string>::const_iterator l = languages.begin(); l != languages.end(); ++l) @@ -70,7 +72,8 @@ void cmGlobalUnixMakefileGenerator3 { path = name; } - if(path.size() == 0 || !cmSystemTools::FileExists(path.c_str())) + if((path.size() == 0 || !cmSystemTools::FileExists(path.c_str())) + && (optional==false)) { std::string message = "your "; message += lang; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 02a1c44..512618e 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -77,7 +77,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *); + cmMakefile *, bool optional); /** * Generate the all required files for building this project/tree. This diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 2ed4f40..b980aa2 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -25,7 +25,9 @@ cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() } void cmGlobalVisualStudio6Generator -::EnableLanguage(std::vector<std::string>const& lang, cmMakefile *mf) +::EnableLanguage(std::vector<std::string>const& lang, + cmMakefile *mf, + bool options) { mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); @@ -34,7 +36,7 @@ void cmGlobalVisualStudio6Generator mf->AddDefinition("CMAKE_GENERATOR_Fortran", "ifort"); mf->AddDefinition("MSVC60", "1"); this->GenerateConfigurations(mf); - this->cmGlobalGenerator::EnableLanguage(lang, mf); + this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); } void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf) diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index ce330c7..935ee60 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -49,7 +49,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *); + cmMakefile *, bool optional); /** * Try running cmake and building a file. This is used for dynalically diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 8ccdb84..c190c35 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -29,7 +29,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator() void cmGlobalVisualStudio7Generator ::EnableLanguage(std::vector<std::string>const & lang, - cmMakefile *mf) + cmMakefile *mf, bool optional) { mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); @@ -40,7 +40,7 @@ void cmGlobalVisualStudio7Generator this->AddPlatformDefinitions(mf); // Create list of configurations requested by user's cache, if any. - this->cmGlobalGenerator::EnableLanguage(lang, mf); + this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); this->GenerateConfigurations(mf); // if this environment variable is set, then copy it to diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 7bdc378..e90b4db 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -50,7 +50,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *); + cmMakefile *, bool optional); /** * Try running cmake and building a file. This is used for dynalically diff --git a/Source/cmGlobalVisualStudio8Win64Generator.cxx b/Source/cmGlobalVisualStudio8Win64Generator.cxx index 71639e8..ced30a1 100644 --- a/Source/cmGlobalVisualStudio8Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio8Win64Generator.cxx @@ -49,8 +49,8 @@ void cmGlobalVisualStudio8Win64Generator void cmGlobalVisualStudio8Win64Generator ::EnableLanguage(std::vector<std::string>const & lang, - cmMakefile *mf) + cmMakefile *mf, bool optional) { mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); - cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf); + cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional); } diff --git a/Source/cmGlobalVisualStudio8Win64Generator.h b/Source/cmGlobalVisualStudio8Win64Generator.h index e489785..3b69356 100644 --- a/Source/cmGlobalVisualStudio8Win64Generator.h +++ b/Source/cmGlobalVisualStudio8Win64Generator.h @@ -49,6 +49,6 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *); + cmMakefile *, bool optional); }; #endif diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 5505be7..506c729 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -28,7 +28,9 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator() } void cmGlobalWatcomWMakeGenerator -::EnableLanguage(std::vector<std::string>const& l, cmMakefile *mf) +::EnableLanguage(std::vector<std::string>const& l, + cmMakefile *mf, + bool optional) { // pick a default mf->AddDefinition("WATCOM", "1"); @@ -39,7 +41,7 @@ void cmGlobalWatcomWMakeGenerator mf->AddDefinition("CMAKE_NO_QUOTED_OBJECTS", "1"); mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl386"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl386"); - this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf); + this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } ///! Create a local generator appropriate to this Global Generator diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index 6806277..92dacb6 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -45,7 +45,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *); + cmMakefile *, bool optional); }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6c6299f..7a66cf5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -104,7 +104,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::New() //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const& lang, - cmMakefile * mf) + cmMakefile * mf, bool optional) { mf->AddDefinition("XCODE","1"); if(this->XcodeVersion == 15) @@ -125,7 +125,7 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const& mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); // initialize Architectures so it can be used by // GetTargetObjectFileDirectories - this->cmGlobalGenerator::EnableLanguage(lang, mf); + this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); const char* osxArch = mf->GetDefinition("CMAKE_OSX_ARCHITECTURES"); const char* sysroot = diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 9bfc62d..306b7ea 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -53,7 +53,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vector<std::string>const& languages, - cmMakefile *); + cmMakefile *, bool optional); /** * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 313bac6..a3e0769 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1044,7 +1044,7 @@ void cmLocalVisualStudio6Generator // Compute the proper name to use to link this library. std::string lib; std::string libDebug; - cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str(), + cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str(), false); if(tgt) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3c0078f..0487313 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2150,11 +2150,13 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName, } } -void cmMakefile::EnableLanguage(std::vector<std::string> const & lang) +void cmMakefile::EnableLanguage(std::vector<std::string> const & lang, + bool optional) { this->AddDefinition("CMAKE_CFG_INTDIR", - this->LocalGenerator->GetGlobalGenerator()->GetCMakeCFGInitDirectory()); - this->LocalGenerator->GetGlobalGenerator()->EnableLanguage(lang, this); + this->LocalGenerator->GetGlobalGenerator()->GetCMakeCFGInitDirectory()); + this->LocalGenerator->GetGlobalGenerator()->EnableLanguage(lang, this, + optional); } void cmMakefile::ExpandSourceListArguments( diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index bc6bd5b..47fb955 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -633,7 +633,7 @@ public: ///! Enable support for named language, if nil then all languages are ///enabled. - void EnableLanguage(std::vector<std::string>const& languages); + void EnableLanguage(std::vector<std::string>const& languages, bool optional); /** * Set/Get the name of the parent directories CMakeLists file diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 5ae4c16..31d878a 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -72,7 +72,7 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args) languages.push_back("C"); languages.push_back("CXX"); } - this->Makefile->EnableLanguage(languages); + this->Makefile->EnableLanguage(languages, false); return true; } |