From 4130116a852374c675a34e92cd88230848402127 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Thu, 22 Mar 2012 18:11:45 -0700 Subject: [PATCH] fix building on OS X when no OSX SDK is installed. (i.e. just commandline tools) --- CMakeLists.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a801f77fa..fe40c84e02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,12 +146,17 @@ if (APPLE) # features can be used, not the minimum required version to run. set(OSX_MIN_VERSION "10.5.4") set(TARGET_FLAGS "${TARGET_FLAGS} -mmacosx-version-min=${OSX_MIN_VERSION}") - set(TARGET_SYSROOT "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk") - if (NOT EXISTS "${TARGET_SYSROOT}/") - set(TARGET_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk") + set(SYSROOT_LEGACY_PATH "/Developer/SDKs/MacOSX10.6.sdk") + set(SYSROOT_PATH "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk") + if (EXISTS "${SYSROOT_PATH}/") + set(TARGET_SYSROOT ${SYSROOT_PATH}) + elif (EXISTS "${SYSROOT_LEGACY_PATH}/") + set(TARGET_SYSROOT ${SYSROOT_LEGACY_PATH}) + endif() + if (${TARGET_SYSROOT}) + set(TARGET_FLAGS "${TARGET_FLAGS} -isysroot ${TARGET_SYSROOT}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-syslibroot,${TARGET_SYSROOT}") endif() - set(TARGET_FLAGS "${TARGET_FLAGS} -isysroot ${TARGET_SYSROOT}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk") # Do not warn about frameworks that are not available on all architectures. # This avoids a warning when linking with QuickTime. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_arch_warnings")