summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/Platform/Darwin.cmake14
-rw-r--r--Source/cmLocalGenerator.cxx20
2 files changed, 27 insertions, 7 deletions
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index 825f218..fff091f 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -182,6 +182,20 @@ IF(XCODE)
SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX)
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
# with -isysroot (for universal binaries), the linker always looks for
# dependent libraries under the sysroot. Listing them on the link
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 1b4cea3..e685b5a 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1759,9 +1759,14 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT");
const char* deploymentTarget =
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;
-
if(osxArch && sysroot && lang && (lang[0] =='C' || lang[0] == 'F'))
{
std::vector<std::string> archs;
@@ -1787,16 +1792,17 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
flags += " -arch ";
flags += *i;
}
-
- flags += " -isysroot ";
- flags += sysroot;
-
+ if(hasIsysroot)
+ {
+ flags += " -isysroot ";
+ flags += sysroot;
+ }
flagsUsed = true;
}
}
if(!flagsUsed && sysroot && sysrootDefault &&
- strcmp(sysroot, sysrootDefault) != 0)
+ strcmp(sysroot, sysrootDefault) != 0 && hasIsysroot)
{
flags += " -isysroot ";
flags += sysroot;