Add detection of gcc versions that do not support isysroot option and do not use it for them.
This commit is contained in:
parent
3c32c904b3
commit
58818d5168
|
@ -182,6 +182,20 @@ IF(XCODE)
|
||||||
SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX)
|
SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX)
|
||||||
ENDIF(XCODE)
|
ENDIF(XCODE)
|
||||||
|
|
||||||
|
IF(NOT CMAKE_OSX_GCC_SUPPORT_ISYSROOT)
|
||||||
|
IF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
|
||||||
|
EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} "--version"
|
||||||
|
OUTPUT_VARIABLE GCC_VERSION)
|
||||||
|
ENDIF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
|
||||||
|
STRING(REGEX REPLACE "^[^ ]+[ ][^ ]+[ ]([^ ]+).*$" "\\1"
|
||||||
|
gcc_version_tmp "${GCC_VERSION}")
|
||||||
|
IF(${gcc_version_tmp} VERSION_GREATER 3.9)
|
||||||
|
SET(CMAKE_OSX_GCC_SUPPORT_ISYSROOT TRUE CACHE INTERNAL "GCC supports isysroot")
|
||||||
|
ELSE(${gcc_version_tmp} VERSION_GREATER 3.9)
|
||||||
|
SET(CMAKE_OSX_GCC_SUPPORT_ISYSROOT FALSE CACHE INTERNAL "GCC supports isysroot")
|
||||||
|
ENDIF(${gcc_version_tmp} VERSION_GREATER 3.9)
|
||||||
|
ENDIF(NOT CMAKE_OSX_GCC_SUPPORT_ISYSROOT)
|
||||||
|
|
||||||
# Need to list dependent shared libraries on link line. When building
|
# Need to list dependent shared libraries on link line. When building
|
||||||
# with -isysroot (for universal binaries), the linker always looks for
|
# with -isysroot (for universal binaries), the linker always looks for
|
||||||
# dependent libraries under the sysroot. Listing them on the link
|
# dependent libraries under the sysroot. Listing them on the link
|
||||||
|
|
|
@ -1759,9 +1759,14 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
|
||||||
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT");
|
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT");
|
||||||
const char* deploymentTarget =
|
const char* deploymentTarget =
|
||||||
this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
|
this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
|
||||||
|
const char* gccHasIsysroot =
|
||||||
|
this->Makefile->GetRequiredDefinition("CMAKE_OSX_GCC_SUPPORT_ISYSROOT");
|
||||||
|
bool hasIsysroot = true;
|
||||||
|
if(cmSystemTools::IsOff(gccHasIsysroot))
|
||||||
|
{
|
||||||
|
hasIsysroot = false;
|
||||||
|
}
|
||||||
bool flagsUsed = false;
|
bool flagsUsed = false;
|
||||||
|
|
||||||
if(osxArch && sysroot && lang && (lang[0] =='C' || lang[0] == 'F'))
|
if(osxArch && sysroot && lang && (lang[0] =='C' || lang[0] == 'F'))
|
||||||
{
|
{
|
||||||
std::vector<std::string> archs;
|
std::vector<std::string> archs;
|
||||||
|
@ -1787,16 +1792,17 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
|
||||||
flags += " -arch ";
|
flags += " -arch ";
|
||||||
flags += *i;
|
flags += *i;
|
||||||
}
|
}
|
||||||
|
if(hasIsysroot)
|
||||||
|
{
|
||||||
flags += " -isysroot ";
|
flags += " -isysroot ";
|
||||||
flags += sysroot;
|
flags += sysroot;
|
||||||
|
}
|
||||||
flagsUsed = true;
|
flagsUsed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!flagsUsed && sysroot && sysrootDefault &&
|
if(!flagsUsed && sysroot && sysrootDefault &&
|
||||||
strcmp(sysroot, sysrootDefault) != 0)
|
strcmp(sysroot, sysrootDefault) != 0 && hasIsysroot)
|
||||||
{
|
{
|
||||||
flags += " -isysroot ";
|
flags += " -isysroot ";
|
||||||
flags += sysroot;
|
flags += sysroot;
|
||||||
|
|
Loading…
Reference in New Issue