mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-19 13:46:13 +00:00
Changed: Use of CMAKE_OSX_ARCHITECTURES to compile universal binaries under Mac OS X
This commit is contained in:
parent
61ebbe6858
commit
e5679e38e9
2 changed files with 269 additions and 100 deletions
|
@ -34,18 +34,18 @@ ENDIF(MSVC)
|
|||
|
||||
MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
|
||||
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
|
||||
SET(${_out_compile_flags} ${${_flags_var_name}} )
|
||||
SET(_FLAGS ${${_flags_var_name}} )
|
||||
|
||||
IF(NOT MSVC)
|
||||
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
|
||||
IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
|
||||
LIST(APPEND ${_out_compile_flags} "-fPIC")
|
||||
LIST(APPEND _FLAGS "-fPIC")
|
||||
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
|
||||
ENDIF(NOT MSVC)
|
||||
|
||||
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES )
|
||||
FOREACH(item ${DIRINC})
|
||||
LIST(APPEND ${_out_compile_flags} " ${_PCH_include_prefix}\"${item}\"")
|
||||
LIST(APPEND _FLAGS " ${_PCH_include_prefix}\"${item}\"")
|
||||
ENDFOREACH(item)
|
||||
|
||||
# Required for CMake 2.6
|
||||
|
@ -57,13 +57,32 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
|
|||
|
||||
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
|
||||
GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
|
||||
LIST(APPEND ${_out_compile_flags} ${GLOBAL_DEFINITIONS})
|
||||
LIST(APPEND ${_out_compile_flags} ${_directory_flags})
|
||||
LIST(APPEND ${_out_compile_flags} ${_directory_definitions})
|
||||
LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS})
|
||||
LIST(APPEND _FLAGS ${GLOBAL_DEFINITIONS})
|
||||
LIST(APPEND _FLAGS ${_directory_flags})
|
||||
LIST(APPEND _FLAGS ${_directory_definitions})
|
||||
LIST(APPEND _FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
# Format definitions
|
||||
SEPARATE_ARGUMENTS(${_out_compile_flags})
|
||||
SEPARATE_ARGUMENTS(_FLAGS)
|
||||
|
||||
IF(CLANG)
|
||||
SET(_IGNORE_NEXT OFF)
|
||||
FOREACH(item ${_FLAGS})
|
||||
IF(_IGNORE_NEXT)
|
||||
SET(_IGNORE_NEXT OFF)
|
||||
ELSE(_IGNORE_NEXT)
|
||||
IF(item MATCHES "^-Xarch")
|
||||
SET(_IGNORE_NEXT ON)
|
||||
ELSEIF(item MATCHES "^-arch")
|
||||
SET(_IGNORE_NEXT ON)
|
||||
ELSE(item MATCHES "^-Xarch")
|
||||
LIST(APPEND ${_out_compile_flags} ${item})
|
||||
ENDIF(item MATCHES "^-Xarch")
|
||||
ENDIF(_IGNORE_NEXT)
|
||||
ENDFOREACH(item)
|
||||
ELSE(CLANG)
|
||||
SET(${_out_compile_flags} ${_FLAGS})
|
||||
ENDIF(CLANG)
|
||||
ENDMACRO(_PCH_GET_COMPILE_FLAGS)
|
||||
|
||||
MACRO(_PCH_GET_PDB_FILENAME out_filename _target)
|
||||
|
|
|
@ -326,6 +326,11 @@ MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
|
|||
OPTION(WITH_SNOWBALLS_SERVER "Build Snowballs Services" ON )
|
||||
ENDMACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
|
||||
|
||||
MACRO(ADD_PLATFORM_FLAGS _FLAGS)
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} ${_FLAGS}")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${_FLAGS}")
|
||||
ENDMACRO(ADD_PLATFORM_FLAGS)
|
||||
|
||||
MACRO(NL_SETUP_BUILD)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -422,19 +427,27 @@ MACRO(NL_SETUP_BUILD)
|
|||
STRING(STRIP ${PLATFORM_CXXFLAGS} PLATFORM_CXXFLAGS)
|
||||
STRING(STRIP ${PLATFORM_LINKFLAGS} PLATFORM_LINKFLAGS)
|
||||
|
||||
IF(TARGET_CPU STREQUAL "x86_64")
|
||||
SET(TARGET_X64 1)
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DHAVE_X86_64")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -DHAVE_X86_64")
|
||||
ELSEIF(TARGET_CPU STREQUAL "x86")
|
||||
SET(TARGET_X86 1)
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DHAVE_X86")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -DHAVE_X86")
|
||||
ELSEIF(TARGET_CPU STREQUAL "arm")
|
||||
SET(TARGET_ARM 1)
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DHAVE_ARM")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -DHAVE_ARM")
|
||||
ENDIF(TARGET_CPU STREQUAL "x86_64")
|
||||
IF(NOT CMAKE_OSX_ARCHITECTURES)
|
||||
IF(TARGET_CPU STREQUAL "x86_64")
|
||||
SET(TARGET_X64 1)
|
||||
ELSEIF(TARGET_CPU STREQUAL "x86")
|
||||
SET(TARGET_X86 1)
|
||||
ELSEIF(TARGET_CPU STREQUAL "armv7s")
|
||||
SET(TARGET_ARM 1)
|
||||
SET(TARGET_ARMV7S 1)
|
||||
ELSEIF(TARGET_CPU STREQUAL "armv7")
|
||||
SET(TARGET_ARM 1)
|
||||
SET(TARGET_ARMV7 1)
|
||||
ELSEIF(TARGET_CPU STREQUAL "armv6")
|
||||
SET(TARGET_ARM 1)
|
||||
SET(TARGET_ARMV6 1)
|
||||
ELSEIF(TARGET_CPU STREQUAL "armv5")
|
||||
SET(TARGET_ARM 1)
|
||||
SET(TARGET_ARMV5 1)
|
||||
ELSEIF(TARGET_CPU STREQUAL "arm")
|
||||
SET(TARGET_ARM 1)
|
||||
ENDIF(TARGET_CPU STREQUAL "x86_64")
|
||||
ENDIF(NOT CMAKE_OSX_ARCHITECTURES)
|
||||
|
||||
# Fix library paths suffixes for Debian MultiArch
|
||||
IF(LIBRARY_ARCHITECTURE)
|
||||
|
@ -447,35 +460,65 @@ MACRO(NL_SETUP_BUILD)
|
|||
ENDIF(TARGET_X86)
|
||||
ENDIF(LIBRARY_ARCHITECTURE)
|
||||
|
||||
IF(APPLE AND NOT IOS)
|
||||
SET(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH})
|
||||
SET(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
|
||||
ENDIF(APPLE AND NOT IOS)
|
||||
|
||||
IF(TARGET_ARM)
|
||||
IF(TARGET_ARMV7)
|
||||
ADD_PLATFORM_FLAGS("-DHAVE_ARMV7")
|
||||
ENDIF(TARGET_ARMV7)
|
||||
|
||||
IF(TARGET_ARMV6)
|
||||
ADD_PLATFORM_FLAGS("-HAVE_ARMV6")
|
||||
ENDIF(TARGET_ARMV6)
|
||||
|
||||
ADD_PLATFORM_FLAGS("-DHAVE_ARM")
|
||||
ENDIF(TARGET_ARM)
|
||||
|
||||
IF(TARGET_X86)
|
||||
ADD_PLATFORM_FLAGS("-DHAVE_X86")
|
||||
ENDIF(TARGET_X86)
|
||||
|
||||
IF(TARGET_X64)
|
||||
ADD_PLATFORM_FLAGS("-DHAVE_X64 -DHAVE_X86_64")
|
||||
ENDIF(TARGET_X64)
|
||||
|
||||
IF(WITH_LOGGING)
|
||||
ADD_PLATFORM_FLAGS("-DENABLE_LOGS")
|
||||
ENDIF(WITH_LOGGING)
|
||||
|
||||
IF(MSVC)
|
||||
IF(MSVC10)
|
||||
ADD_PLATFORM_FLAGS("/Gy- /MP")
|
||||
# /Ox is working with VC++ 2010, but custom optimizations don't exist
|
||||
SET(SPEED_OPTIMIZATIONS "/Ox /GF /GS-")
|
||||
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
|
||||
# without inlining it's unusable, use custom optimizations again
|
||||
SET(MIN_OPTIMIZATIONS "/Od /Ob1")
|
||||
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
|
||||
ELSEIF(MSVC90)
|
||||
ADD_PLATFORM_FLAGS("/Gy- /MP")
|
||||
# don't use a /O[012x] flag if you want custom optimizations
|
||||
SET(SPEED_OPTIMIZATIONS "/Ob2 /Oi /Ot /Oy /GT /GF /GS-")
|
||||
SET(RELEASE_CFLAGS "/Ob2 /Oi /Ot /Oy /GT /GF /GS- ${RELEASE_CFLAGS}")
|
||||
# without inlining it's unusable, use custom optimizations again
|
||||
SET(MIN_OPTIMIZATIONS "/Ob1")
|
||||
SET(DEBUG_CFLAGS "/Ob1 /GF- ${DEBUG_CFLAGS}")
|
||||
ELSEIF(MSVC80)
|
||||
ADD_PLATFORM_FLAGS("/Gy- /Wp64")
|
||||
# don't use a /O[012x] flag if you want custom optimizations
|
||||
SET(SPEED_OPTIMIZATIONS "/Ox /GF /GS-")
|
||||
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
|
||||
# without inlining it's unusable, use custom optimizations again
|
||||
SET(MIN_OPTIMIZATIONS "/Od /Ob1")
|
||||
SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}")
|
||||
ELSE(MSVC10)
|
||||
MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
|
||||
ENDIF(MSVC10)
|
||||
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zm1000 /MP /Gy-")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zm1000 /MP /Gy-")
|
||||
ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250")
|
||||
|
||||
IF(TARGET_X64)
|
||||
# Fix a bug with Intellisense
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} /D_WIN64")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} /D_WIN64")
|
||||
ADD_PLATFORM_FLAGS("/D_WIN64")
|
||||
# Fix a compilation error for some big C++ files
|
||||
SET(MIN_OPTIMIZATIONS "${MIN_OPTIMIZATIONS} /bigobj")
|
||||
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} /bigobj")
|
||||
ELSE(TARGET_X64)
|
||||
# Allows 32 bits applications to use 3 GB of RAM
|
||||
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /LARGEADDRESSAWARE")
|
||||
|
@ -491,97 +534,201 @@ MACRO(NL_SETUP_BUILD)
|
|||
SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}")
|
||||
ENDIF(WITH_SYMBOLS)
|
||||
|
||||
SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${MIN_OPTIMIZATIONS} ${NL_DEBUG_CFLAGS}")
|
||||
SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${SPEED_OPTIMIZATIONS} ${NL_RELEASE_CFLAGS}")
|
||||
SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}")
|
||||
SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}")
|
||||
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}")
|
||||
|
||||
IF(WITH_WARNINGS)
|
||||
SET(DEBUG_CFLAGS "/W4 ${DEBUG_CFLAGS}")
|
||||
ELSE(WITH_WARNINGS)
|
||||
SET(DEBUG_CFLAGS "/W3 ${DEBUG_CFLAGS}")
|
||||
ENDIF(WITH_WARNINGS)
|
||||
ELSE(MSVC)
|
||||
IF(WIN32)
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DWIN32 -D_WIN32")
|
||||
ADD_PLATFORM_FLAGS("-DWIN32 -D_WIN32")
|
||||
|
||||
IF(CLANG)
|
||||
ADD_PLATFORM_FLAGS("-nobuiltininc")
|
||||
ENDIF(CLANG)
|
||||
ENDIF(WIN32)
|
||||
|
||||
IF(APPLE)
|
||||
IF(TARGET_CPU STREQUAL "x86")
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -arch i386")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -arch i386")
|
||||
ENDIF(TARGET_CPU STREQUAL "x86")
|
||||
IF(TARGET_ARM)
|
||||
ADD_PLATFORM_FLAGS("-mthumb")
|
||||
ENDIF(TARGET_ARM)
|
||||
|
||||
IF(TARGET_CPU STREQUAL "x86_64")
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -arch x86_64")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -arch x86_64")
|
||||
ENDIF(TARGET_CPU STREQUAL "x86_64")
|
||||
IF(APPLE)
|
||||
IF(IOS)
|
||||
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE PATH "" FORCE)
|
||||
ELSE(IOS)
|
||||
IF(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE PATH "" FORCE)
|
||||
ENDIF(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
ENDIF(IOS)
|
||||
|
||||
IF(XCODE)
|
||||
IF(IOS)
|
||||
SET(CMAKE_OSX_SYSROOT "iphoneos" CACHE PATH "" FORCE)
|
||||
ELSE(IOS)
|
||||
# SET(CMAKE_OSX_SYSROOT "macosx" CACHE PATH "" FORCE)
|
||||
ENDIF(IOS)
|
||||
ELSE(XCODE)
|
||||
IF(CMAKE_OSX_ARCHITECTURES)
|
||||
SET(TARGETS_COUNT 0)
|
||||
SET(_ARCHS)
|
||||
FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES})
|
||||
IF(_ARCH STREQUAL "i386")
|
||||
SET(_ARCHS "${_ARCHS} i386")
|
||||
SET(TARGET_X86 1)
|
||||
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
|
||||
ELSEIF(_ARCH STREQUAL "x86_64")
|
||||
SET(_ARCHS "${_ARCHS} x86_64")
|
||||
SET(TARGET_X64 1)
|
||||
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
|
||||
ELSEIF(_ARCH STREQUAL "armv7")
|
||||
SET(_ARCHS "${_ARCHS} armv7")
|
||||
SET(TARGET_ARMV7 1)
|
||||
SET(TARGET_ARM 1)
|
||||
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
|
||||
ELSEIF(_ARCH STREQUAL "armv6")
|
||||
SET(_ARCHS "${_ARCHS} armv6")
|
||||
SET(TARGET_ARMV6 1)
|
||||
SET(TARGET_ARM 1)
|
||||
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
|
||||
ELSE(_ARCH STREQUAL "i386")
|
||||
SET(_ARCHS "${_ARCHS} unknwon(${_ARCH})")
|
||||
ENDIF(_ARCH STREQUAL "i386")
|
||||
ENDFOREACH(_ARCH)
|
||||
MESSAGE(STATUS "Compiling under Mac OS X for ${TARGETS_COUNT} architectures: ${_ARCHS}")
|
||||
ELSE(CMAKE_OSX_ARCHITECTURES)
|
||||
SET(TARGETS_COUNT 1)
|
||||
ENDIF(CMAKE_OSX_ARCHITECTURES)
|
||||
|
||||
IF(TARGETS_COUNT EQUAL 1)
|
||||
IF(TARGET_ARM)
|
||||
IF(TARGET_ARMV7S)
|
||||
ADD_PLATFORM_FLAGS("-arch armv7s")
|
||||
ENDIF(TARGET_ARMV7S)
|
||||
|
||||
IF(TARGET_ARMV7)
|
||||
ADD_PLATFORM_FLAGS("-arch armv7")
|
||||
ENDIF(TARGET_ARMV7)
|
||||
|
||||
IF(TARGET_ARMV6)
|
||||
ADD_PLATFORM_FLAGS("-arch armv6")
|
||||
ENDIF(TARGET_ARMV6)
|
||||
|
||||
IF(TARGET_ARMV5)
|
||||
ADD_PLATFORM_FLAGS("-arch armv5")
|
||||
ENDIF(TARGET_ARMV5)
|
||||
ENDIF(TARGET_ARM)
|
||||
|
||||
IF(TARGET_X86)
|
||||
ADD_PLATFORM_FLAGS("-arch i386")
|
||||
ENDIF(TARGET_X86)
|
||||
|
||||
IF(TARGET_X64)
|
||||
ADD_PLATFORM_FLAGS("-arch x86_64")
|
||||
ENDIF(TARGET_X64)
|
||||
ELSE(TARGETS_COUNT EQUAL 1)
|
||||
IF(TARGET_ARMV6)
|
||||
ADD_PLATFORM_FLAGS("-Xarch_armv6 -mthumb -Xarch_armv6 -DHAVE_ARM -Xarch_armv6 -DHAVE_ARMV6")
|
||||
ENDIF(TARGET_ARMV6)
|
||||
|
||||
IF(TARGET_ARMV7)
|
||||
ADD_PLATFORM_FLAGS("-Xarch_armv7 -mthumb -Xarch_armv7 -DHAVE_ARM -Xarch_armv7 -DHAVE_ARMV7")
|
||||
ENDIF(TARGET_ARMV7)
|
||||
|
||||
IF(TARGET_X86)
|
||||
ADD_PLATFORM_FLAGS("-arch i386 -Xarch_i386 -DHAVE_X86")
|
||||
ENDIF(TARGET_X86)
|
||||
|
||||
IF(TARGET_X64)
|
||||
ADD_PLATFORM_FLAGS("-arch x86_64 -Xarch_x86_64 -DHAVE_X64 -Xarch_x86_64 -DHAVE_X86_64")
|
||||
ENDIF(TARGET_X64)
|
||||
ENDIF(TARGETS_COUNT EQUAL 1)
|
||||
|
||||
IF(IOS)
|
||||
IF(IOS_VERSION)
|
||||
PARSE_VERSION_STRING(${IOS_VERSION} IOS_VERSION_MAJOR IOS_VERSION_MINOR IOS_VERSION_PATCH)
|
||||
CONVERT_VERSION_NUMBER(${IOS_VERSION_MAJOR} ${IOS_VERSION_MINOR} ${IOS_VERSION_PATCH} IOS_VERSION_NUMBER)
|
||||
|
||||
ADD_PLATFORM_FLAGS("-D__IPHONE_OS_VERSION_MIN_REQUIRED=${IOS_VERSION_NUMBER}")
|
||||
ENDIF(IOS_VERSION)
|
||||
|
||||
IF(CMAKE_IOS_SYSROOT)
|
||||
ADD_PLATFORM_FLAGS("-isysroot${CMAKE_IOS_SYSROOT}")
|
||||
ADD_PLATFORM_FLAGS("-miphoneos-version-min=${IOS_VERSION}")
|
||||
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-iphoneos_version_min,${IOS_VERSION}")
|
||||
ENDIF(CMAKE_IOS_SYSROOT)
|
||||
|
||||
IF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86)
|
||||
IF(TARGETS_COUNT EQUAL 1)
|
||||
ADD_PLATFORM_FLAGS("-arch i386")
|
||||
ELSE(TARGETS_COUNT EQUAL 1)
|
||||
SET(XARCH "-Xarch_i386 ")
|
||||
ENDIF(TARGETS_COUNT EQUAL 1)
|
||||
|
||||
# Always force -mmacosx-version-min to override environement variable
|
||||
ADD_PLATFORM_FLAGS("${XARCH}-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
ENDIF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86)
|
||||
ELSE(IOS)
|
||||
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)
|
||||
ADD_PLATFORM_FLAGS("-isysroot ${CMAKE_OSX_SYSROOT}")
|
||||
ELSE(CMAKE_OSX_SYSROOT)
|
||||
MESSAGE(FATAL_ERROR "CMAKE_OSX_SYSROOT can't be determinated")
|
||||
ENDIF(CMAKE_OSX_SYSROOT)
|
||||
|
||||
# Always force -mmacosx-version-min to override environement variable
|
||||
ADD_PLATFORM_FLAGS("-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
ENDIF(IOS)
|
||||
|
||||
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-headerpad_max_install_names")
|
||||
|
||||
IF(HAVE_FLAG_SEARCH_PATHS_FIRST)
|
||||
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-search_paths_first")
|
||||
ENDIF(HAVE_FLAG_SEARCH_PATHS_FIRST)
|
||||
ENDIF(XCODE)
|
||||
ELSE(APPLE)
|
||||
IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86")
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -m32 -march=i686")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -m32 -march=i686")
|
||||
ADD_PLATFORM_FLAGS("-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")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -m64")
|
||||
ADD_PLATFORM_FLAGS("-m64")
|
||||
ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
|
||||
ENDIF(APPLE)
|
||||
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -D_REENTRANT -pipe -Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused -fno-strict-aliasing")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -D_REENTRANT -pipe -Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused -fno-strict-aliasing")
|
||||
|
||||
IF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -ansi")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ansi")
|
||||
ENDIF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
ADD_PLATFORM_FLAGS("-D_REENTRANT -pipe -fno-strict-aliasing")
|
||||
|
||||
IF(WITH_COVERAGE)
|
||||
SET(PLATFORM_CFLAGS "-fprofile-arcs -ftest-coverage ${PLATFORM_CFLAGS}")
|
||||
SET(PLATFORM_CXXFLAGS "-fprofile-arcs -ftest-coverage ${PLATFORM_CXXFLAGS}")
|
||||
ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage")
|
||||
ENDIF(WITH_COVERAGE)
|
||||
|
||||
IF(WITH_WARNINGS)
|
||||
ADD_PLATFORM_FLAGS("-Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused")
|
||||
IF(CLANG)
|
||||
ADD_PLATFORM_FLAGS("-std=gnu99")
|
||||
ELSE(CLANG)
|
||||
ADD_PLATFORM_FLAGS("-ansi")
|
||||
ENDIF(CLANG)
|
||||
ENDIF(WITH_WARNINGS)
|
||||
|
||||
IF(APPLE)
|
||||
SET(PLATFORM_CFLAGS "-gdwarf-2 ${PLATFORM_CFLAGS}")
|
||||
SET(PLATFORM_CXXFLAGS "-gdwarf-2 ${PLATFORM_CXXFLAGS}")
|
||||
ADD_PLATFORM_FLAGS("-gdwarf-2")
|
||||
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}")
|
||||
SET(PLATFORM_CXXFLAGS "-isysroot ${CMAKE_OSX_SYSROOT} ${PLATFORM_CXXFLAGS}")
|
||||
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}")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -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}")
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -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}")
|
||||
SET(PLATFORM_CXXFLAGS "-fPIC ${PLATFORM_CXXFLAGS}")
|
||||
ADD_PLATFORM_FLAGS("-fPIC")
|
||||
ENDIF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS)
|
||||
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48")
|
||||
|
@ -788,7 +935,10 @@ MACRO(SETUP_EXTERNAL)
|
|||
IF(VC_ROOT_DIR MATCHES "registry")
|
||||
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VCExpress\\10.0_Config;InstallDir]" ABSOLUTE)
|
||||
IF(VC_ROOT_DIR MATCHES "registry")
|
||||
FILE(TO_CMAKE_PATH $ENV{VS100COMNTOOLS} VC_ROOT_DIR)
|
||||
SET(VS100COMNTOOLS $ENV{VS100COMNTOOLS})
|
||||
IF(VS100COMNTOOLS)
|
||||
FILE(TO_CMAKE_PATH ${VS100COMNTOOLS} VC_ROOT_DIR)
|
||||
ENDIF(VS100COMNTOOLS)
|
||||
IF(NOT VC_ROOT_DIR)
|
||||
MESSAGE(FATAL_ERROR "Unable to find VC++ 2010 directory!")
|
||||
ENDIF(NOT VC_ROOT_DIR)
|
||||
|
|
Loading…
Reference in a new issue