Added: Xcode checks and specific flags

Changed: Target by default Mac OS X 10.6 if not specified
Changed: Add -isysroot, -arch and -mmacosx-version-min flags if needed
This commit is contained in:
kervala 2012-05-08 00:07:14 +02:00
parent ef6a79450e
commit d5366b1776

View file

@ -387,6 +387,11 @@ MACRO(NL_SETUP_BUILD)
MESSAGE(STATUS "Using Clang compiler") MESSAGE(STATUS "Using Clang compiler")
ENDIF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") ENDIF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
IF(CMAKE_GENERATOR MATCHES "Xcode")
SET(XCODE ON)
MESSAGE(STATUS "Generating Xcode project")
ENDIF(CMAKE_GENERATOR MATCHES "Xcode")
# If target and host CPU are the same # If target and host CPU are the same
IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}") IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}")
# x86-compatible CPU # x86-compatible CPU
@ -491,13 +496,27 @@ MACRO(NL_SETUP_BUILD)
SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt /INCREMENTAL:YES ${NL_DEBUG_LINKFLAGS}") SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt /INCREMENTAL:YES ${NL_DEBUG_LINKFLAGS}")
SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}") SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}")
ELSE(MSVC) ELSE(MSVC)
IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86") IF(WIN32)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -m32 -march=i686") SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DWIN32 -D_WIN32")
ENDIF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86") ENDIF(WIN32)
IF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64") IF(APPLE)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -m64") IF(TARGET_CPU STREQUAL "x86")
ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64") SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -arch i386")
ENDIF(TARGET_CPU STREQUAL "x86")
IF(TARGET_CPU STREQUAL "x86_64")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -arch x86_64")
ENDIF(TARGET_CPU STREQUAL "x86_64")
ELSE(APPLE)
IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -m32 -march=i686")
ENDIF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86")
IF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -m64")
ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
ENDIF(APPLE)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -D_REENTRANT -pipe -ftemplate-depth-48 -Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused -fno-strict-aliasing") SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -D_REENTRANT -pipe -ftemplate-depth-48 -Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused -fno-strict-aliasing")
@ -513,6 +532,41 @@ MACRO(NL_SETUP_BUILD)
SET(PLATFORM_CFLAGS "-gdwarf-2 ${PLATFORM_CFLAGS}") SET(PLATFORM_CFLAGS "-gdwarf-2 ${PLATFORM_CFLAGS}")
ENDIF(APPLE) ENDIF(APPLE)
IF(APPLE AND XCODE)
SET(CMAKE_OSX_SYSROOT "macosx" CACHE PATH "" FORCE)
ELSEIF(APPLE AND NOT XCODE)
IF(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.6")
ENDIF(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
FOREACH(_SDK ${_CMAKE_OSX_SDKS})
IF(${_SDK} MATCHES "MacOSX${CMAKE_OSX_DEPLOYMENT_TARGET}\\.sdk")
SET(CMAKE_OSX_SYSROOT ${_SDK} CACHE PATH "" FORCE)
ENDIF(${_SDK} MATCHES "MacOSX${CMAKE_OSX_DEPLOYMENT_TARGET}\\.sdk")
ENDFOREACH(_SDK)
IF(CMAKE_OSX_SYSROOT)
SET(PLATFORM_CFLAGS "-isysroot ${CMAKE_OSX_SYSROOT} ${PLATFORM_CFLAGS}")
ELSE(CMAKE_OSX_SYSROOT)
MESSAGE(FATAL_ERROR "CMAKE_OSX_SYSROOT can't be determinated")
ENDIF(CMAKE_OSX_SYSROOT)
IF(CMAKE_OSX_ARCHITECTURES)
FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES})
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -arch ${_ARCH}")
ENDFOREACH(_ARCH)
ENDIF(CMAKE_OSX_ARCHITECTURES)
IF(CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
ENDIF(CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-headerpad_max_install_names")
IF(HAVE_FLAG_SEARCH_PATHS_FIRST)
SET(PLATFORM_LINKFLAGS "-Wl,-search_paths_first ${PLATFORM_LINKFLAGS}")
ENDIF(HAVE_FLAG_SEARCH_PATHS_FIRST)
ENDIF(APPLE AND XCODE)
# Fix "relocation R_X86_64_32 against.." error on x64 platforms # Fix "relocation R_X86_64_32 against.." error on x64 platforms
IF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS) IF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS)
SET(PLATFORM_CFLAGS "-fPIC ${PLATFORM_CFLAGS}") SET(PLATFORM_CFLAGS "-fPIC ${PLATFORM_CFLAGS}")