ENH: try to initialize all languages at the same time
This commit is contained in:
parent
ad4f98f3cf
commit
731369ef9c
|
@ -24,7 +24,8 @@ cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator()
|
|||
m_ForceUnixPaths = false;
|
||||
}
|
||||
|
||||
void cmGlobalBorlandMakefileGenerator::EnableLanguage(const char* l,
|
||||
|
||||
void cmGlobalBorlandMakefileGenerator::EnableLanguage(std::vector<std::string>const& l,
|
||||
cmMakefile *mf)
|
||||
{
|
||||
std::string outdir = m_CMakeInstance->GetStartOutputDirectory();
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
* Try to determine system infomation such as shared library
|
||||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(const char*,cmMakefile *mf);
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "cmake.h"
|
||||
#include "cmTarget.h"
|
||||
|
||||
void cmGlobalCodeWarriorGenerator::EnableLanguage(const char*,
|
||||
void cmGlobalCodeWarriorGenerator::EnableLanguage(std::vector<std::string>const& l,
|
||||
cmMakefile *mf)
|
||||
{
|
||||
// now load the settings
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
* Try to determine system infomation such as shared library
|
||||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(const char*, cmMakefile *mf);
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *);
|
||||
|
||||
/**
|
||||
* Try running cmake and building a file. This is used for dynalically
|
||||
|
|
|
@ -98,10 +98,10 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
|
|||
|
||||
|
||||
// enable the given language
|
||||
void cmGlobalGenerator::EnableLanguage(const char* lang,
|
||||
void cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
||||
cmMakefile *mf)
|
||||
{
|
||||
if(!lang)
|
||||
if(languages.size() == 0)
|
||||
{
|
||||
cmSystemTools::Error("EnableLanguage must have a lang specified!");
|
||||
cmSystemTools::SetFatalErrorOccured();
|
||||
|
@ -126,7 +126,7 @@ void cmGlobalGenerator::EnableLanguage(const char* lang,
|
|||
|
||||
// **** Step 2, Load the CMakeDetermineSystem.cmake file and find out
|
||||
// what platform we are running on
|
||||
if (!isLocal && !this->GetLanguageEnabled(lang))
|
||||
if (!isLocal && !mf->GetDefinition("CMAKE_SYSTEM_NAME"))
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Windows version number data. */
|
||||
|
@ -151,8 +151,13 @@ void cmGlobalGenerator::EnableLanguage(const char* lang,
|
|||
fpath += "/CMakeSystem.cmake";
|
||||
mf->ReadListFile(0,fpath.c_str());
|
||||
}
|
||||
// **** Step 4, load the CMakeDetermine(LANG)Compiler.cmake file to find
|
||||
// **** Step 4, foreach language
|
||||
// load the CMakeDetermine(LANG)Compiler.cmake file to find
|
||||
// the compiler
|
||||
for(std::vector<std::string>::const_iterator l = languages.begin();
|
||||
l != languages.end(); ++l)
|
||||
{
|
||||
const char* lang = l->c_str();
|
||||
if(!isLocal && !this->GetLanguageEnabled(lang) )
|
||||
{
|
||||
if (m_CMakeInstance->GetIsInTryCompile())
|
||||
|
@ -210,6 +215,8 @@ void cmGlobalGenerator::EnableLanguage(const char* lang,
|
|||
}
|
||||
this->SetLanguageEnabled(lang);
|
||||
}
|
||||
}
|
||||
|
||||
// **** Step 6, Load the system specific information if not yet loaded
|
||||
if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED"))
|
||||
{
|
||||
|
@ -219,6 +226,10 @@ void cmGlobalGenerator::EnableLanguage(const char* lang,
|
|||
cmSystemTools::Error("Could not find cmake module file:", fpath.c_str());
|
||||
}
|
||||
}
|
||||
for(std::vector<std::string>::const_iterator l = languages.begin();
|
||||
l != languages.end(); ++l)
|
||||
{
|
||||
const char* lang = l->c_str();
|
||||
std::string langLoadedVar = "CMAKE_";
|
||||
langLoadedVar += lang;
|
||||
langLoadedVar += "_INFORMATION_LOADED";
|
||||
|
@ -274,6 +285,7 @@ void cmGlobalGenerator::EnableLanguage(const char* lang,
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
* Try to determine system infomation such as shared library
|
||||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(const char*, cmMakefile *);
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *);
|
||||
|
||||
/**
|
||||
* Try to determine system infomation, get it from another generator
|
||||
|
|
|
@ -25,7 +25,7 @@ cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator()
|
|||
m_ForceUnixPaths = false;
|
||||
}
|
||||
|
||||
void cmGlobalNMakeMakefileGenerator::EnableLanguage(const char* l,
|
||||
void cmGlobalNMakeMakefileGenerator::EnableLanguage(std::vector<std::string>const& l,
|
||||
cmMakefile *mf)
|
||||
{
|
||||
// pick a default
|
||||
|
|
|
@ -44,8 +44,7 @@ public:
|
|||
* Try to determine system infomation such as shared library
|
||||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(const char*,cmMakefile *mf);
|
||||
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,24 +27,32 @@ cmGlobalUnixMakefileGenerator::cmGlobalUnixMakefileGenerator()
|
|||
m_FindMakeProgramFile = "CMakeUnixFindMake.cmake";
|
||||
}
|
||||
|
||||
void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
|
||||
void cmGlobalUnixMakefileGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
||||
cmMakefile *mf)
|
||||
{
|
||||
mf->AddDefinition("CMAKE_CFG_INTDIR",".");
|
||||
this->cmGlobalGenerator::EnableLanguage(lang, mf);
|
||||
this->cmGlobalGenerator::EnableLanguage(languages, mf);
|
||||
std::string path;
|
||||
if(strcmp(lang, "C") == 0)
|
||||
for(std::vector<std::string>::const_iterator l = languages.begin();
|
||||
l != languages.end(); ++l)
|
||||
{
|
||||
if(!mf->GetDefinition("CMAKE_C_COMPILER"))
|
||||
const char* lang = l->c_str();
|
||||
std::string langComp = "CMAKE_";
|
||||
langComp += lang;
|
||||
langComp += "_COMPILER";
|
||||
|
||||
if(!mf->GetDefinition(langComp.c_str()))
|
||||
{
|
||||
cmSystemTools::Error("CMAKE_C_COMPILER not set, after EnableLanguage");
|
||||
return;
|
||||
cmSystemTools::Error(langComp.c_str(), " not set, after EnableLanguage");
|
||||
continue;
|
||||
}
|
||||
const char* cc = mf->GetRequiredDefinition("CMAKE_C_COMPILER");
|
||||
const char* cc = mf->GetRequiredDefinition(langComp.c_str());
|
||||
path = cmSystemTools::FindProgram(cc);
|
||||
if(path.size() == 0)
|
||||
{
|
||||
std::string message = "your C compiler: ";
|
||||
std::string message = "your ";
|
||||
message += lang;
|
||||
message += " compiler: ";
|
||||
if(cc)
|
||||
{
|
||||
message += cc;
|
||||
|
@ -60,29 +68,6 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang,
|
|||
cmSystemTools::Error(message.c_str());
|
||||
}
|
||||
}
|
||||
if(strcmp(lang, "CXX") == 0)
|
||||
{
|
||||
const char* cxx = mf->GetRequiredDefinition("CMAKE_CXX_COMPILER");
|
||||
path = cmSystemTools::FindProgram(cxx);
|
||||
if(path.size() == 0)
|
||||
{
|
||||
std::string message = "your C++ compiler: ";
|
||||
if(cxx)
|
||||
{
|
||||
message += cxx;
|
||||
}
|
||||
else
|
||||
{
|
||||
message += "(NULL)";
|
||||
}
|
||||
|
||||
message += " was not found in your path. "
|
||||
"For CMake to correctly use try compile commands, the compiler must "
|
||||
"be in your path. Please add the compiler to your PATH environment,"
|
||||
" and re-run CMake.";
|
||||
cmSystemTools::Error(message.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///! Create a local generator appropriate to this Global Generator
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
* Try to determine system infomation such as shared library
|
||||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(const char*, cmMakefile *mf);
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ cmGlobalVisualStudio6Generator::cmGlobalVisualStudio6Generator()
|
|||
m_FindMakeProgramFile = "CMakeVS6FindMake.cmake";
|
||||
}
|
||||
|
||||
void cmGlobalVisualStudio6Generator::EnableLanguage(const char* lang,
|
||||
void cmGlobalVisualStudio6Generator::EnableLanguage(std::vector<std::string>const& lang,
|
||||
cmMakefile *mf)
|
||||
{
|
||||
mf->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)");
|
||||
|
|
|
@ -47,8 +47,7 @@ public:
|
|||
* Try to determine system infomation such as shared library
|
||||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(const char*, cmMakefile *mf);
|
||||
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *);
|
||||
/**
|
||||
* Try running cmake and building a file. This is used for dynalically
|
||||
* loaded commands, not as part of the usual build process.
|
||||
|
|
|
@ -28,7 +28,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator()
|
|||
}
|
||||
|
||||
|
||||
void cmGlobalVisualStudio7Generator::EnableLanguage(const char* lang,
|
||||
void cmGlobalVisualStudio7Generator::EnableLanguage(std::vector<std::string>const & lang,
|
||||
cmMakefile *mf)
|
||||
{
|
||||
mf->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)");
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
* Try to determine system infomation such as shared library
|
||||
* extension, pthreads, byte order etc.
|
||||
*/
|
||||
virtual void EnableLanguage(const char*, cmMakefile *mf);
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *);
|
||||
|
||||
/**
|
||||
* Try running cmake and building a file. This is used for dynalically
|
||||
|
|
|
@ -2006,7 +2006,7 @@ cmSourceFile* cmMakefile::AddSource(cmSourceFile const&sf)
|
|||
}
|
||||
|
||||
|
||||
void cmMakefile::EnableLanguage(const char* lang)
|
||||
void cmMakefile::EnableLanguage(std::vector<std::string> const & lang)
|
||||
{
|
||||
m_LocalGenerator->GetGlobalGenerator()->EnableLanguage(lang, this);
|
||||
}
|
||||
|
|
|
@ -611,7 +611,7 @@ public:
|
|||
void AddCommand(cmCommand* );
|
||||
|
||||
///! Enable support for the named language, if null then all languages are enabled.
|
||||
void EnableLanguage(const char* );
|
||||
virtual void EnableLanguage(std::vector<std::string>const& languages);
|
||||
|
||||
/**
|
||||
* Set/Get the name of the parent directories CMakeLists file
|
||||
|
|
|
@ -48,19 +48,21 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args)
|
|||
|
||||
m_Makefile->AddDefinition("PROJECT_NAME", args[0].c_str());
|
||||
|
||||
std::vector<std::string> languages;
|
||||
if(args.size() > 1)
|
||||
{
|
||||
for(size_t i =1; i < args.size(); ++i)
|
||||
{
|
||||
m_Makefile->EnableLanguage(args[i].c_str());
|
||||
languages.push_back(args[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// if no language is specified do c and c++
|
||||
m_Makefile->EnableLanguage("C");
|
||||
m_Makefile->EnableLanguage("CXX");
|
||||
languages.push_back("C");
|
||||
languages.push_back("CXX");
|
||||
}
|
||||
m_Makefile->EnableLanguage(languages);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue