From Erik den Dekker, "
IF(${CMAKE_OSX_SYSROOT} STREQUAL "/Developer/SDKs/MacOSX10.7.sdk") ... ELSEIF(${CMAKE_OSX_SYSROOT} STREQUAL "/Developer/SDKs/MacOSX10.5.sdk" OR ${CMAKE_OSX_SYSROOT} STREQUAL "/Developer/SDKs/MacOSX10.6.sdk") ... ELSEIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk) ... ELSE() ... ENDIF() Which is fragile because XCode could be installed into another directory than /Developer. (In case XCode is not installed into the /Developer directory CMake can automatically resolve the path via command line utility ${CMAKE_XCODE_SELECT} --print-path) This issue bites me currently because the latest XCode (Version 4.3.1 - 4E1019) installed through the Mac App Store is per default installed in "/Applications/Xcode.app/Contents/Developer" and hence the 10.7 SDK in "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk" Searching the web to find the proper way to determine the version of the Platform SDK programmatically, I found no standard way. I came up with 2 options myself: 1) Parse the path string to extract the version number 2) Read a value from the SDKSettings.plist found in the root of each SDK (e.g., "defaults read ${CMAKE_OSX_ROOT}/SDKSettings.plist CanonicalName" gives "macosx10.7") I implemented the last option and verified that at least the following Mac OS SDKs (10.3.9, 10.4, 10.5, 10.6, 10.7) support this method. It also looks reasonably future proof. An additional benefit of this method is that it also seems to be compatible with iOS and iOS Simulator SDKs (at least for version 5.1, but I assume this also applies to older versions). This is interesting because the CMake infrastructure to build OSG for iOS currently still contains similar hard-coded paths and even requires you to manually change the cmake file to build for another iOS SDK version. In the near future I hope to address these issues, but I haven't been able to try this yet."
This commit is contained in:
parent
14a563dc9f
commit
c2ae14f94d
@ -188,6 +188,11 @@ ENDIF(OSG_MAINTAINER)
|
||||
|
||||
IF(NOT ANDROID)
|
||||
IF(APPLE)
|
||||
# Determine the canonical name of the selected Platform SDK
|
||||
EXECUTE_PROCESS(COMMAND "defaults" "read" "${CMAKE_OSX_SYSROOT}/SDKSettings.plist" "CanonicalName"
|
||||
OUTPUT_VARIABLE APPLE_PLATFORM_SDK_CANONICAL_NAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Trying to get CMake to generate an XCode IPhone project, current efforts are to get iphoneos sdk 3.1 working
|
||||
# Added option which needs manually setting to select the IPhone SDK for building. We can only have one of the below
|
||||
# set to true. Should realy have an OSG_BUILD_PLATFORM variable that we set to our desired platform
|
||||
@ -819,20 +824,18 @@ IF(APPLE)
|
||||
# FORCE is used because the options are not reflected in the UI otherwise.
|
||||
# Seems like a good place to add version specific compiler flags too.
|
||||
IF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
|
||||
# This is really fragile, but CMake doesn't provide the OS system
|
||||
# version information we need. (Darwin versions can be changed
|
||||
# independently of OS X versions.)
|
||||
IF (${CMAKE_OSX_SYSROOT} STREQUAL "/Developer/SDKs/MacOSX10.7.sdk")
|
||||
IF(${APPLE_PLATFORM_SDK_CANONICAL_NAME} STREQUAL "macosx10.7")
|
||||
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
|
||||
# 64 Bit Works, PPC is not supported any more
|
||||
SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
ELSEIF(${CMAKE_OSX_SYSROOT} STREQUAL "/Developer/SDKs/MacOSX10.5.sdk" OR ${CMAKE_OSX_SYSROOT} STREQUAL "/Developer/SDKs/MacOSX10.6.sdk")
|
||||
ELSEIF(${APPLE_PLATFORM_SDK_CANONICAL_NAME} STREQUAL "macosx10.6" /
|
||||
${APPLE_PLATFORM_SDK_CANONICAL_NAME} STREQUAL "macosx10.5")
|
||||
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
|
||||
# 64-bit compiles are not supported with Carbon.
|
||||
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.5 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
ELSEIF(EXISTS /Developer/SDKs/MacOSX10.4u.sdk)
|
||||
ELSEIF(${APPLE_PLATFORM_SDK_CANONICAL_NAME} STREQUAL "macosx10.4")
|
||||
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "quicktime" CACHE STRING "Forced imageio default image plugin for OSX" FORCE)
|
||||
SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.4 -ftree-vectorize -fvisibility-inlines-hidden" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
@ -841,7 +844,7 @@ IF(APPLE)
|
||||
# Should break down further to set the -mmacosx-version-min,
|
||||
# but the SDK detection is too unreliable here.
|
||||
ENDIF()
|
||||
ENDIF(NOT OSG_CONFIG_HAS_BEEN_RUN_BEFORE)
|
||||
ENDIF()
|
||||
|
||||
OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" OFF)
|
||||
|
||||
@ -881,12 +884,12 @@ IF(BUILD_DOCUMENTATION)
|
||||
# If html help generation was requested. DOCUMENTATION_HTML_HELP is defined by Documentation.cmake
|
||||
SET(GENERATE_HTMLHELP "NO")
|
||||
IF(DOCUMENTATION_HTML_HELP)
|
||||
# on windows Documentation.cmake finds the html help workshop fi it exists. On u*ix we might have it with wine but no way to point it out
|
||||
# on windows Documentation.cmake finds the html help workshop if it exists. On u*ix we might have it with wine but no way to point it out
|
||||
IF(NOT WIN32)
|
||||
SET(HTML_HELP_COMPILER "" CACHE FILEPATH "Enter location of the HTML help compiler to let doxygen compile html")
|
||||
MARK_AS_ADVANCED(HTML_HELP_COMPILER)
|
||||
ENDIF()
|
||||
# this var sets a proper value in .doxygen files when coniguring them below
|
||||
# this var sets a proper value in .doxygen files when configuring them below
|
||||
SET(GENERATE_HTMLHELP "YES")
|
||||
endif()
|
||||
|
||||
|
@ -68,8 +68,9 @@ ELSE()
|
||||
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
|
||||
SET(OSG_WINDOWING_SYSTEM "IOS" CACHE STRING "Windowing system type for graphics window creation, options only IOS.")
|
||||
ELSE()
|
||||
IF (${CMAKE_OSX_SYSROOT} STREQUAL "/Developer/SDKs/MacOSX10.7.sdk" OR ${CMAKE_OSX_SYSROOT} STREQUAL "/Developer/SDKs/MacOSX10.6.sdk" OR ${CMAKE_OSX_SYSROOT} STREQUAL "/Developer/SDKs/MacOSX10.5.sdk")
|
||||
|
||||
IF(${APPLE_PLATFORM_SDK_CANONICAL_NAME} STREQUAL "macosx10.7" OR
|
||||
${APPLE_PLATFORM_SDK_CANONICAL_NAME} STREQUAL "macosx10.6" OR
|
||||
${APPLE_PLATFORM_SDK_CANONICAL_NAME} STREQUAL "macosx10.5")
|
||||
SET(OSG_WINDOWING_SYSTEM "Cocoa" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.")
|
||||
ELSE()
|
||||
SET(OSG_WINDOWING_SYSTEM "Carbon" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.")
|
||||
|
Loading…
Reference in New Issue
Block a user