ENH: add OPTIONAL keyword to ENABLE_LANGUAGE, so it will be possible to do
something like this: ENABLE_LANGUAGE(ASM-ATT) IF(CMAKE_ASM-ATT_COMPILER_WORKS) ... do assembler stufff ELSE(CMAKE_ASM-ATT_COMPILER_WORKS) ... fallback to generic C/C++ ENDIF(CMAKE_ASM-ATT_COMPILER_WORKS) Alex
This commit is contained in:
parent
53f39ad566
commit
43de8c8628
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages,
|
||||
cmMakefile *);
|
||||
cmMakefile *, bool optional);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages,
|
||||
cmMakefile *);
|
||||
cmMakefile *, bool optional);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages,
|
||||
cmMakefile *);
|
||||
cmMakefile *, bool optional);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,6 @@ public:
|
|||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages,
|
||||
cmMakefile *);
|
||||
cmMakefile *, bool optional);
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages,
|
||||
cmMakefile *);
|
||||
cmMakefile *, bool optional);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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()->EnableLanguage(lang, this,
|
||||
optional);
|
||||
}
|
||||
|
||||
void cmMakefile::ExpandSourceListArguments(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue