ENH: split cmGlobalGenerator::SetLanguageEnabled() in two parts, where the
second part copies the values from the cmake variables into internal maps. So this can now be done after the compiler-specific information has been loaded, which can now overwrite more settings. Alex
This commit is contained in:
parent
1a71290836
commit
422dc631b6
|
@ -22,7 +22,6 @@ SET(CMAKE_C_COMPILER_ID_RUN 1)
|
|||
SET(CMAKE_C_SOURCE_FILE_EXTENSIONS c)
|
||||
SET(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
|
||||
SET(CMAKE_C_LINKER_PREFERENCE None)
|
||||
SET(CMAKE_C_OUTPUT_EXTENSION @CMAKE_C_OUTPUT_EXTENSION@)
|
||||
|
||||
# save the size of void* in case where cache is removed
|
||||
# and the this file is still around
|
||||
|
|
|
@ -5,6 +5,14 @@
|
|||
# It also loads a system - compiler - processor (or target hardware)
|
||||
# specific file, which is mainly useful for crosscompiling and embedded systems.
|
||||
|
||||
# some compilers use different extensions (e.g. sdcc uses .rel)
|
||||
# so set the extension here first so it can be overridden by the compiler specific file
|
||||
IF(UNIX)
|
||||
SET(CMAKE_C_OUTPUT_EXTENSION .o)
|
||||
ELSE(UNIX)
|
||||
SET(CMAKE_C_OUTPUT_EXTENSION .obj)
|
||||
ENDIF(UNIX)
|
||||
|
||||
GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_C_COMPILER} NAME_WE)
|
||||
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||
SET(CMAKE_BASE_NAME gcc)
|
||||
|
|
|
@ -22,7 +22,6 @@ SET(CMAKE_CXX_COMPILER_ID_RUN 1)
|
|||
SET(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;H;o;O;obj;OBJ;def;DEF;rc;RC)
|
||||
SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm)
|
||||
SET(CMAKE_CXX_LINKER_PREFERENCE Prefered)
|
||||
SET(CMAKE_CXX_OUTPUT_EXTENSION @CMAKE_CXX_OUTPUT_EXTENSION@)
|
||||
|
||||
# save the size of void* in case where cache is removed
|
||||
# and the this file is still around
|
||||
|
|
|
@ -5,6 +5,15 @@
|
|||
# It also loads a system - compiler - processor (or target hardware)
|
||||
# specific file, which is mainly useful for crosscompiling and embedded systems.
|
||||
|
||||
# some compilers use different extensions (e.g. sdcc uses .rel)
|
||||
# so set the extension here first so it can be overridden by the compiler specific file
|
||||
IF(UNIX)
|
||||
SET(CMAKE_CXX_OUTPUT_EXTENSION .o)
|
||||
ELSE(UNIX)
|
||||
SET(CMAKE_CXX_OUTPUT_EXTENSION .obj)
|
||||
ENDIF(UNIX)
|
||||
|
||||
|
||||
GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_CXX_COMPILER} NAME_WE)
|
||||
# since the gnu compiler has several names force g++
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
|
|
@ -105,17 +105,6 @@ IF (NOT _CMAKE_TOOLCHAIN_SUFFIX)
|
|||
ENDIF (COMPILER_BASENAME MATCHES "^cl(.+)\\.exe$")
|
||||
ENDIF (NOT _CMAKE_TOOLCHAIN_SUFFIX)
|
||||
|
||||
# some exotic compilers have different extensions (e.g. sdcc uses .rel)
|
||||
# so don't overwrite it if it has been already defined by the user
|
||||
IF(NOT CMAKE_C_OUTPUT_EXTENSION)
|
||||
IF(UNIX)
|
||||
SET(CMAKE_C_OUTPUT_EXTENSION .o)
|
||||
ELSE(UNIX)
|
||||
SET(CMAKE_C_OUTPUT_EXTENSION .obj)
|
||||
ENDIF(UNIX)
|
||||
ENDIF(NOT CMAKE_C_OUTPUT_EXTENSION)
|
||||
|
||||
|
||||
# Build a small source file to identify the compiler.
|
||||
IF(${CMAKE_GENERATOR} MATCHES "Visual Studio")
|
||||
SET(CMAKE_C_COMPILER_ID_RUN 1)
|
||||
|
|
|
@ -103,17 +103,6 @@ IF (NOT _CMAKE_TOOLCHAIN_SUFFIX)
|
|||
ENDIF (NOT _CMAKE_TOOLCHAIN_SUFFIX)
|
||||
|
||||
|
||||
# some exotic compilers have different extensions (e.g. sdcc uses .rel)
|
||||
# so don't overwrite it if it has been already defined by the user
|
||||
IF(NOT CMAKE_CXX_OUTPUT_EXTENSION)
|
||||
IF(UNIX)
|
||||
SET(CMAKE_CXX_OUTPUT_EXTENSION .o)
|
||||
ELSE(UNIX)
|
||||
SET(CMAKE_CXX_OUTPUT_EXTENSION .obj)
|
||||
ENDIF(UNIX)
|
||||
ENDIF(NOT CMAKE_CXX_OUTPUT_EXTENSION)
|
||||
|
||||
|
||||
# This block was used before the compiler was identified by building a
|
||||
# source file. Unless g++ crashes when building a small C++
|
||||
# executable this should no longer be needed.
|
||||
|
|
|
@ -255,6 +255,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
|||
mf->ReadListFile(0,fpath.c_str());
|
||||
}
|
||||
std::map<cmStdString, bool> needTestLanguage;
|
||||
std::map<cmStdString, bool> needSetLanguageEnabledMaps;
|
||||
// foreach language
|
||||
// load the CMakeDetermine(LANG)Compiler.cmake file to find
|
||||
// the compiler
|
||||
|
@ -263,6 +264,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
|||
l != languages.end(); ++l)
|
||||
{
|
||||
const char* lang = l->c_str();
|
||||
needSetLanguageEnabledMaps[lang] = false;
|
||||
if(*l == "NONE")
|
||||
{
|
||||
this->SetLanguageEnabled("NONE", mf);
|
||||
|
@ -296,7 +298,8 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
|||
// if this file was found then the language was already determined
|
||||
// to be working
|
||||
needTestLanguage[lang] = false;
|
||||
this->SetLanguageEnabled(lang, mf);
|
||||
this->SetLanguageEnabledFlag(lang, mf);
|
||||
needSetLanguageEnabledMaps[lang] = true;
|
||||
// this can only be called after loading CMake(LANG)Compiler.cmake
|
||||
}
|
||||
}
|
||||
|
@ -356,7 +359,8 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
|||
cmSystemTools::Error("Could not find cmake module file:",
|
||||
fpath.c_str());
|
||||
}
|
||||
this->SetLanguageEnabled(lang, mf);
|
||||
this->SetLanguageEnabledFlag(lang, mf);
|
||||
needSetLanguageEnabledMaps[lang] = true;
|
||||
// this can only be called after loading CMake(LANG)Compiler.cmake
|
||||
// the language must be enabled for try compile to work, but we do
|
||||
// not know if it is a working compiler yet so set the test language
|
||||
|
@ -401,6 +405,11 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
|||
fpath.c_str());
|
||||
}
|
||||
}
|
||||
if (needSetLanguageEnabledMaps[lang])
|
||||
{
|
||||
this->SetLanguageEnabledMaps(lang, mf);
|
||||
}
|
||||
|
||||
// Test the compiler for the language just setup
|
||||
// At this point we should have enough info for a try compile
|
||||
// which is used in the backward stuff
|
||||
|
@ -527,10 +536,35 @@ const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext)
|
|||
|
||||
void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf)
|
||||
{
|
||||
if(this->LanguageEnabled.count(l) > 0)
|
||||
this->SetLanguageEnabledFlag(l, mf);
|
||||
this->SetLanguageEnabledMaps(l, mf);
|
||||
}
|
||||
|
||||
void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile* mf)
|
||||
{
|
||||
this->LanguageEnabled[l] = true;
|
||||
}
|
||||
|
||||
void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf)
|
||||
{
|
||||
// use LanguageToLinkerPreference to detect whether this functions has
|
||||
// run before
|
||||
if (this->LanguageToLinkerPreference.find(l) !=
|
||||
this->LanguageToLinkerPreference.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::string linkerPrefVar = std::string("CMAKE_") +
|
||||
std::string(l) + std::string("_LINKER_PREFERENCE");
|
||||
const char* linkerPref = mf->GetDefinition(linkerPrefVar.c_str());
|
||||
if(!linkerPref)
|
||||
{
|
||||
linkerPref = "None";
|
||||
}
|
||||
this->LanguageToLinkerPreference[l] = linkerPref;
|
||||
|
||||
|
||||
std::string outputExtensionVar = std::string("CMAKE_") +
|
||||
std::string(l) + std::string("_OUTPUT_EXTENSION");
|
||||
const char* outputExtension = mf->GetDefinition(outputExtensionVar.c_str());
|
||||
|
@ -544,15 +578,6 @@ void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf)
|
|||
}
|
||||
}
|
||||
|
||||
std::string linkerPrefVar = std::string("CMAKE_") +
|
||||
std::string(l) + std::string("_LINKER_PREFERENCE");
|
||||
const char* linkerPref = mf->GetDefinition(linkerPrefVar.c_str());
|
||||
if(!linkerPref)
|
||||
{
|
||||
linkerPref = "None";
|
||||
}
|
||||
this->LanguageToLinkerPreference[l] = linkerPref;
|
||||
|
||||
std::string extensionsVar = std::string("CMAKE_") +
|
||||
std::string(l) + std::string("_SOURCE_FILE_EXTENSIONS");
|
||||
std::string ignoreExtensionsVar = std::string("CMAKE_") +
|
||||
|
@ -572,9 +597,9 @@ void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf)
|
|||
{
|
||||
this->IgnoreExtensions[*i] = true;
|
||||
}
|
||||
this->LanguageEnabled[l] = true;
|
||||
|
||||
}
|
||||
|
||||
bool cmGlobalGenerator::IgnoreFile(const char* l)
|
||||
{
|
||||
if(this->GetLanguageFromExtension(l))
|
||||
|
|
|
@ -208,6 +208,9 @@ public:
|
|||
|
||||
const std::map<cmStdString, std::vector<cmLocalGenerator*> >& GetProjectMap() const {return this->ProjectMap;}
|
||||
protected:
|
||||
void SetLanguageEnabledFlag(const char* l, cmMakefile* mf);
|
||||
void SetLanguageEnabledMaps(const char* l, cmMakefile* mf);
|
||||
|
||||
// Fill the ProjectMap, this must be called after LocalGenerators
|
||||
// has been populated.
|
||||
void FillProjectMap();
|
||||
|
|
Loading…
Reference in New Issue