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:
parent
38ae47456c
commit
b1147e37b4
1 changed files with 60 additions and 6 deletions
|
@ -387,6 +387,11 @@ MACRO(NL_SETUP_BUILD)
|
|||
MESSAGE(STATUS "Using Clang compiler")
|
||||
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("${HOST_CPU}" STREQUAL "${TARGET_CPU}")
|
||||
# x86-compatible CPU
|
||||
|
@ -491,6 +496,19 @@ MACRO(NL_SETUP_BUILD)
|
|||
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}")
|
||||
ELSE(MSVC)
|
||||
IF(WIN32)
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DWIN32 -D_WIN32")
|
||||
ENDIF(WIN32)
|
||||
|
||||
IF(APPLE)
|
||||
IF(TARGET_CPU STREQUAL "x86")
|
||||
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")
|
||||
|
@ -498,6 +516,7 @@ MACRO(NL_SETUP_BUILD)
|
|||
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")
|
||||
|
||||
|
@ -513,6 +532,41 @@ MACRO(NL_SETUP_BUILD)
|
|||
SET(PLATFORM_CFLAGS "-gdwarf-2 ${PLATFORM_CFLAGS}")
|
||||
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
|
||||
IF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS)
|
||||
SET(PLATFORM_CFLAGS "-fPIC ${PLATFORM_CFLAGS}")
|
||||
|
|
Loading…
Reference in a new issue