diff --git a/Source/cmEnableLanguageCommand.cxx b/Source/cmEnableLanguageCommand.cxx index c7788840e..2713b623b 100644 --- a/Source/cmEnableLanguageCommand.cxx +++ b/Source/cmEnableLanguageCommand.cxx @@ -20,13 +20,29 @@ bool cmEnableLanguageCommand ::InitialPass(std::vector const& args) { + bool optional = false; + std::vector languages; if(args.size() < 1 ) { this->SetError ("ENABLE_LANGUAGE called with incorrect number of arguments"); return false; } - this->Makefile->EnableLanguage(args); + for (std::vector::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 decb788b1..c1c99d116 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__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 959cbe863..8f66924d3 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -30,13 +30,15 @@ cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator() void cmGlobalBorlandMakefileGenerator -::EnableLanguage(std::vectorconst& l, cmMakefile *mf) +::EnableLanguage(std::vectorconst& 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 a6ec084b0..b77a6448c 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -47,7 +47,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vectorconst& languages, - cmMakefile *); + cmMakefile *, bool optional); }; #endif diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 75c946f47..df46f4970 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -196,7 +196,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) void cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, - cmMakefile *mf) + cmMakefile *mf, bool optional) { if(languages.size() == 0) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 7785c9a17..959945c98 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -77,7 +77,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vectorconst& 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 0c76625e0..084d85b0f 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -50,7 +50,9 @@ cmGlobalMSYSMakefileGenerator::FindMinGW(std::string const& makeloc) } void cmGlobalMSYSMakefileGenerator -::EnableLanguage(std::vectorconst& l, cmMakefile *mf) +::EnableLanguage(std::vectorconst& 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 9baecf2e3..cdedb3bee 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.h +++ b/Source/cmGlobalMSYSMakefileGenerator.h @@ -47,7 +47,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vectorconst& languages, - cmMakefile *); + cmMakefile *, bool optional); private: std::string FindMinGW(std::string const& makeloc); diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index 89a01d800..5aeb74bb3 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -27,7 +27,9 @@ cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator() } void cmGlobalMinGWMakefileGenerator -::EnableLanguage(std::vectorconst& l, cmMakefile *mf) +::EnableLanguage(std::vectorconst& 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 345945945..8af3d3403 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.h +++ b/Source/cmGlobalMinGWMakefileGenerator.h @@ -46,7 +46,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vectorconst& languages, - cmMakefile *); + cmMakefile *, bool optional); }; #endif diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index e86c7c642..5ae3ebb9a 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -27,12 +27,14 @@ cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator() } void cmGlobalNMakeMakefileGenerator -::EnableLanguage(std::vectorconst& l, cmMakefile *mf) +::EnableLanguage(std::vectorconst& 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 511ee8984..efdd3f654 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -46,7 +46,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vectorconst& languages, - cmMakefile *); + cmMakefile *, bool optional); }; #endif diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index ef6fa9091..6945b0d35 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -39,9 +39,11 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3() } void cmGlobalUnixMakefileGenerator3 -::EnableLanguage(std::vectorconst& languages, cmMakefile *mf) +::EnableLanguage(std::vectorconst& languages, + cmMakefile *mf, + bool optional) { - this->cmGlobalGenerator::EnableLanguage(languages, mf); + this->cmGlobalGenerator::EnableLanguage(languages, mf, optional); std::string path; for(std::vector::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 02a1c444d..512618ed6 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -77,7 +77,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vectorconst& 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 2ed4f40da..b980aa232 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -25,7 +25,9 @@ cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator() } void cmGlobalVisualStudio6Generator -::EnableLanguage(std::vectorconst& lang, cmMakefile *mf) +::EnableLanguage(std::vectorconst& 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 ce330c7c7..935ee6011 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -49,7 +49,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vectorconst& 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 8ccdb849a..c190c353b 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -29,7 +29,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator() void cmGlobalVisualStudio7Generator ::EnableLanguage(std::vectorconst & 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 7bdc37894..e90b4dbc4 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -50,7 +50,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vectorconst& 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 71639e8a3..ced30a158 100644 --- a/Source/cmGlobalVisualStudio8Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio8Win64Generator.cxx @@ -49,8 +49,8 @@ void cmGlobalVisualStudio8Win64Generator void cmGlobalVisualStudio8Win64Generator ::EnableLanguage(std::vectorconst & 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 e4897858a..3b69356f5 100644 --- a/Source/cmGlobalVisualStudio8Win64Generator.h +++ b/Source/cmGlobalVisualStudio8Win64Generator.h @@ -49,6 +49,6 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vectorconst& languages, - cmMakefile *); + cmMakefile *, bool optional); }; #endif diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 5505be732..506c729fd 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -28,7 +28,9 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator() } void cmGlobalWatcomWMakeGenerator -::EnableLanguage(std::vectorconst& l, cmMakefile *mf) +::EnableLanguage(std::vectorconst& 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 6806277c3..92dacb6ed 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -45,7 +45,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vectorconst& languages, - cmMakefile *); + cmMakefile *, bool optional); }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6c6299f7e..7a66cf5bd 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -104,7 +104,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::New() //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::EnableLanguage(std::vectorconst& lang, - cmMakefile * mf) + cmMakefile * mf, bool optional) { mf->AddDefinition("XCODE","1"); if(this->XcodeVersion == 15) @@ -125,7 +125,7 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vectorconst& 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 9bfc62dea..306b7eabf 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -53,7 +53,7 @@ public: * extension, pthreads, byte order etc. */ virtual void EnableLanguage(std::vectorconst& 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 313bac6aa..a3e07693b 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 3c0078ffc..04873130d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2150,11 +2150,13 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName, } } -void cmMakefile::EnableLanguage(std::vector const & lang) +void cmMakefile::EnableLanguage(std::vector 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 bc6bd5b84..47fb95547 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::vectorconst& languages); + void EnableLanguage(std::vectorconst& languages, bool optional); /** * Set/Get the name of the parent directories CMakeLists file diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 5ae4c16ee..31d878a78 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -72,7 +72,7 @@ bool cmProjectCommand::InitialPass(std::vector const& args) languages.push_back("C"); languages.push_back("CXX"); } - this->Makefile->EnableLanguage(languages); + this->Makefile->EnableLanguage(languages, false); return true; }