From 58818d5168bb9b6402a1c3651a3a97173123e4ae Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 18 Sep 2009 14:22:20 -0400 Subject: Add detection of gcc versions that do not support isysroot option and do not use it for them. --- Modules/Platform/Darwin.cmake | 14 ++++++++++++++ Source/cmLocalGenerator.cxx | 20 +++++++++++++------- 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 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; -- cgit v0.12