ENH: allow users to set sysroot
This commit is contained in:
parent
9bc893eb16
commit
d4fdbeed64
@ -57,6 +57,7 @@ IF(_CMAKE_OSX_SDKS)
|
|||||||
LIST(SORT _CMAKE_OSX_SDKS)
|
LIST(SORT _CMAKE_OSX_SDKS)
|
||||||
LIST(REVERSE _CMAKE_OSX_SDKS)
|
LIST(REVERSE _CMAKE_OSX_SDKS)
|
||||||
LIST(GET _CMAKE_OSX_SDKS 0 _CMAKE_OSX_SDKS)
|
LIST(GET _CMAKE_OSX_SDKS 0 _CMAKE_OSX_SDKS)
|
||||||
|
SET(CMAKE_OSX_SYSROOT_DEFAULT "${_CMAKE_OSX_SDKS}")
|
||||||
# use the environment variable CMAKE_OSX_SYSROOT if it is set
|
# use the environment variable CMAKE_OSX_SYSROOT if it is set
|
||||||
IF(NOT "$ENV{CMAKE_OSX_SYSROOT}" STREQUAL "")
|
IF(NOT "$ENV{CMAKE_OSX_SYSROOT}" STREQUAL "")
|
||||||
SET(_CMAKE_OSX_SDKS "$ENV{CMAKE_OSX_SYSROOT}")
|
SET(_CMAKE_OSX_SDKS "$ENV{CMAKE_OSX_SYSROOT}")
|
||||||
|
@ -2451,14 +2451,29 @@ void cmGlobalXCodeGenerator
|
|||||||
this->CurrentMakefile->GetDefinition("CMAKE_OSX_ARCHITECTURES");
|
this->CurrentMakefile->GetDefinition("CMAKE_OSX_ARCHITECTURES");
|
||||||
const char* sysroot =
|
const char* sysroot =
|
||||||
this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
||||||
|
const char* sysrootDefault =
|
||||||
|
this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT");
|
||||||
if(osxArch && sysroot)
|
if(osxArch && sysroot)
|
||||||
{
|
{
|
||||||
|
bool flagsUsed = false;
|
||||||
// recompute this as it may have been changed since enable language
|
// recompute this as it may have been changed since enable language
|
||||||
this->Architectures.clear();
|
this->Architectures.clear();
|
||||||
cmSystemTools::ExpandListArgument(std::string(osxArch),
|
cmSystemTools::ExpandListArgument(std::string(osxArch),
|
||||||
this->Architectures);
|
this->Architectures);
|
||||||
if(this->Architectures.size() > 1)
|
bool addArchFlag = true;
|
||||||
|
if(this->Architectures.size() == 1)
|
||||||
{
|
{
|
||||||
|
const char* archOrig =
|
||||||
|
this->
|
||||||
|
CurrentMakefile->GetSafeDefinition("CMAKE_OSX_ARCHITECTURES_DEFAULT");
|
||||||
|
if(this->Architectures[0] == archOrig)
|
||||||
|
{
|
||||||
|
addArchFlag = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(addArchFlag)
|
||||||
|
{
|
||||||
|
flagsUsed = true;
|
||||||
buildSettings->AddAttribute("SDKROOT",
|
buildSettings->AddAttribute("SDKROOT",
|
||||||
this->CreateString(sysroot));
|
this->CreateString(sysroot));
|
||||||
std::string archString;
|
std::string archString;
|
||||||
@ -2472,6 +2487,12 @@ void cmGlobalXCodeGenerator
|
|||||||
buildSettings->AddAttribute("ARCHS",
|
buildSettings->AddAttribute("ARCHS",
|
||||||
this->CreateString(archString.c_str()));
|
this->CreateString(archString.c_str()));
|
||||||
}
|
}
|
||||||
|
if(!flagsUsed && sysrootDefault &&
|
||||||
|
strcmp(sysroot, sysrootDefault) != 0)
|
||||||
|
{
|
||||||
|
buildSettings->AddAttribute("SDKROOT",
|
||||||
|
this->CreateString(sysroot));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for( std::vector<cmXCodeObject*>::iterator i = configs.begin();
|
for( std::vector<cmXCodeObject*>::iterator i = configs.begin();
|
||||||
i != configs.end(); ++i)
|
i != configs.end(); ++i)
|
||||||
|
@ -1627,6 +1627,9 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
|
|||||||
this->Makefile->GetDefinition("CMAKE_OSX_ARCHITECTURES");
|
this->Makefile->GetDefinition("CMAKE_OSX_ARCHITECTURES");
|
||||||
const char* sysroot =
|
const char* sysroot =
|
||||||
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
|
||||||
|
const char* sysrootDefault =
|
||||||
|
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT");
|
||||||
|
bool flagsUsed = false;
|
||||||
if(osxArch && sysroot && lang && lang[0] =='C')
|
if(osxArch && sysroot && lang && lang[0] =='C')
|
||||||
{
|
{
|
||||||
std::vector<std::string> archs;
|
std::vector<std::string> archs;
|
||||||
@ -1656,10 +1659,17 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
|
|||||||
}
|
}
|
||||||
flags += " -isysroot ";
|
flags += " -isysroot ";
|
||||||
flags += sysroot;
|
flags += sysroot;
|
||||||
|
flagsUsed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!flagsUsed && sysroot && sysrootDefault &&
|
||||||
|
strcmp(sysroot, sysrootDefault) != 0)
|
||||||
|
{
|
||||||
|
flags += " -isysroot ";
|
||||||
|
flags += sysroot;
|
||||||
|
}
|
||||||
|
this->AddConfigVariableFlags(flags, flagsVar.c_str(), config);
|
||||||
}
|
}
|
||||||
this->AddConfigVariableFlags(flags, flagsVar.c_str(), config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user