diff --git a/CMakeLists.txt b/CMakeLists.txt index 58a0e2da7..bddc61a8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,64 +50,66 @@ ENDIF() # value is needed to find the correct version of OpenGL (X11 or Cocoa). IF(APPLE AND NOT ANDROID) - # Here we check if the user specified IPhone SDK - # These options are formally defined later, but can also be specified - # by the user at the command line using the cmake -D switch - # Note that FORCE is used since the user will likely enable IPhone - # build via CMake GUI after already having configured once - 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.") + # custom option to flag an iOS build + OPTION(OSG_BUILD_PLATFORM_IPHONE "Enable IPhoneSDK Device support" OFF) - #set iphone arch and flags taken from http://sites.google.com/site/michaelsafyan/coding/resources/how-to-guides/cross-compile-for-the-iphone/how-to-cross-compile-for-the-iphone-using-cmake IF(OSG_BUILD_PLATFORM_IPHONE) - IF(${IPHONE_VERSION_MIN} LESS "7.0") - SET(CMAKE_OSX_ARCHITECTURES "armv6;armv7" CACHE STRING "Build architectures for iOS" FORCE) - ELSE() - SET(CMAKE_OSX_ARCHITECTURES "armv7;armv7s;arm64" CACHE STRING "Build architectures for iOS" FORCE) - ENDIF() + + # set sdk and min versions + SET (IPHONE_SDKVER "10.2" CACHE STRING "IOS SDK-Version") + SET (IPHONE_VERSION_MIN "7.0" CACHE STRING "IOS minimum os version, use 7.0 or greater to get 64bit support") + + # get full path to sdk from requested versions + SET (IPHONE_DEVROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer") + SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneOS${IPHONE_SDKVER}.sdk") + + # optionally enable bitcode for the build + SET (IPHONE_ENABLE_BITCODE "NO" CACHE STRING "IOS Enable Bitcode") + + # seamless toggle between device and simulator + SET(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") + + # set deployment target to min version + SET(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IPHONE_VERSION_MIN}" CACHE STRING "Deployment target for iOS" FORCE) + + # Set standard architectures + SET(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)") ELSE() - #simulator uses i386 and x86_64 architectures - SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for iOS Simulator" FORCE) - ENDIF() + # OSX >= 10.5 uses Cocoa windowing system, otherwise Carbon + IF(OSG_OSX_VERSION VERSION_LESS 10.5) + SET(OSG_WINDOWING_SYSTEM "Carbon" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.") + ELSE() + SET(OSG_WINDOWING_SYSTEM "Cocoa" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.") + ENDIF() - #here we set the specific iphone sdk version. We can only set either device or simulator sdk. So if you want both you currently have to have two separate projects - SET(CMAKE_OSX_SYSROOT "${IPHONE_SDKROOT}" CACHE STRING "System root for iOS" FORCE) - - ELSE() - # OSX >= 10.5 uses Cocoa windowing system, otherwise Carbon - IF(OSG_OSX_VERSION VERSION_LESS 10.5) - SET(OSG_WINDOWING_SYSTEM "Carbon" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.") - ELSE() - SET(OSG_WINDOWING_SYSTEM "Cocoa" CACHE STRING "Windowing system type for graphics window creation, options Carbon, Cocoa or X11.") + # Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4 + # and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support. + # These are set the first time CMake is run, and can be changed by + # the user at any time. + IF(OSG_OSX_VERSION VERSION_GREATER 10.7) + # 64 Bit Works, i386,ppc is not supported any more + SET(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX") + SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.8" CACHE STRING "Target OSX version") + ELSEIF(OSG_OSX_VERSION VERSION_EQUAL 10.7) + # 64 Bit Works, PPC is not supported any more + SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX") + ELSEIF(OSG_OSX_VERSION VERSION_GREATER 10.4) + # 64-bit compiles are not supported with Carbon. + SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX") + SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING "Target OSX version") + ELSEIF(OSG_OSX_VERSION VERSION_EQUAL 10.4) + # 64-bit compiles are not supported with Carbon. + SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX") + ELSE() + # No Universal Binary support and SDK detection is too unreliable. + # Warn user and continue at their own peril. + MESSAGE(WARNING "OSX 10.3 and earlier not supported.") + ENDIF() ENDIF() - - # Set defaults for Universal Binaries. We want 32-bit Intel/PPC on 10.4 - # and 32/64-bit Intel/PPC on >= 10.5. Anything <= 10.3 doesn't support. - # These are set the first time CMake is run, and can be changed by - # the user at any time. - IF(OSG_OSX_VERSION VERSION_GREATER 10.7) - # 64 Bit Works, i386,ppc is not supported any more - SET(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX") - SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.8" CACHE STRING "Target OSX version") - ELSEIF(OSG_OSX_VERSION VERSION_EQUAL 10.7) - # 64 Bit Works, PPC is not supported any more - SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX") - ELSEIF(OSG_OSX_VERSION VERSION_GREATER 10.4) - # 64-bit compiles are not supported with Carbon. - SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX") - SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING "Target OSX version") - ELSEIF(OSG_OSX_VERSION VERSION_EQUAL 10.4) - # 64-bit compiles are not supported with Carbon. - SET(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "Build architectures for OSX") - ELSE() - # No Universal Binary support and SDK detection is too unreliable. - # Warn user and continue at their own peril. - MESSAGE(WARNING "OSX 10.3 and earlier not supported.") - ENDIF() - ENDIF() ENDIF() + PROJECT(OpenSceneGraph) SET(OPENSCENEGRAPH_VERSION ${OPENSCENEGRAPH_MAJOR_VERSION}.${OPENSCENEGRAPH_MINOR_VERSION}.${OPENSCENEGRAPH_PATCH_VERSION}) @@ -218,40 +220,15 @@ ENDIF(OSG_MAINTAINER) IF(NOT ANDROID) IF(APPLE) - # 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 really have an OSG_BUILD_PLATFORM variable that we set to our desired platform - OPTION(OSG_BUILD_PLATFORM_IPHONE "Enable IPhoneSDK Device support" OFF) - OPTION(OSG_BUILD_PLATFORM_IPHONE_SIMULATOR "Enable IPhoneSDK Simulator support" OFF) - IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) + IF(OSG_BUILD_PLATFORM_IPHONE) - #you need to manually set the default sdk version here - SET (IPHONE_SDKVER "10.2" CACHE STRING "IOS SDK-Version") - SET (IPHONE_VERSION_MIN "7.0" CACHE STRING "IOS minimum os version, use 7.0 or greater to get 64bit support") + # set the sdk path as our sysroot, if we set this before the project is defined cmake fails to build its test program + SET(CMAKE_OSX_SYSROOT "${IPHONE_SDKROOT}" CACHE STRING "System root for iOS" FORCE) - #the below is taken from ogre, it states the gcc stuff needs to happen before PROJECT() is called. I've no clue if we even need it - # Force gcc <= 4.2 on iPhone - IF(IPHONE_VERSION_MIN LESS "6.0") - include(CMakeForceCompiler) - CMAKE_FORCE_C_COMPILER(llvm-gcc-4.2 GNU) - CMAKE_FORCE_CXX_COMPILER(llvm-gcc-4.2 GNU) - SET(GCC_THUMB_SUPPORT NO) - ENDIF() + # Set the path to OpenGL library + SET(OPENGL_gl_LIBRARY "${IPHONE_SDKROOT}/System/Library/Frameworks/OpenGLES.framework") - #set either the device sdk or the simulator sdk. Can't find away to separate these in the same project - IF(OSG_BUILD_PLATFORM_IPHONE) - SET (IPHONE_DEVROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer") - SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneOS${IPHONE_SDKVER}.sdk") - ELSE() - SET (IPHONE_DEVROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer") - SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneSimulator${IPHONE_SDKVER}.sdk") - ENDIF() - - SET (IPHONE_ENABLE_BITCODE "NO" CACHE STRING "IOS Enable Bitcode") - - # Apple iOS: Find OpenGLES - FIND_LIBRARY(OPENGLES_LIBRARY OpenGLES) ELSE () FIND_LIBRARY(CARBON_LIBRARY Carbon) FIND_LIBRARY(COCOA_LIBRARY Cocoa) @@ -1105,41 +1082,15 @@ ENDIF() IF(APPLE AND NOT ANDROID) - #Here we check if the user specified IPhone SDK - IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) + IF(OSG_BUILD_PLATFORM_IPHONE) - #set iphone arch and flags taken from http://sites.google.com/site/michaelsafyan/coding/resources/how-to-guides/cross-compile-for-the-iphone/how-to-cross-compile-for-the-iphone-using-cmake - IF(OSG_BUILD_PLATFORM_IPHONE) - IF(${IPHONE_VERSION_MIN} LESS "7.0") - SET(CMAKE_OSX_ARCHITECTURES "armv6;armv7" CACHE STRING "Build architectures for iOS" FORCE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-thumb -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE) - ELSE() - SET(CMAKE_OSX_ARCHITECTURES "armv7;armv7s;arm64" CACHE STRING "Build architectures for iOS" FORCE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE) - ENDIF() + # set osg window system to iOS + SET(OSG_WINDOWING_SYSTEM "IOS" CACHE STRING "Windowing system type for graphics window creation, options only IOS." FORCE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=${IPHONE_VERSION_MIN}" FORCE) - - ELSE() - #simulator uses i386 and x86_64 architectures - SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for iOS Simulator" FORCE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-thumb -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE) - - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mios-simulator-version-min=${IPHONE_VERSION_MIN}" FORCE) - - ENDIF() - - #here we set the specific iphone sdk version. We can only set either device or simulator sdk. So if you want both you currently have to have two separate projects - SET(CMAKE_OSX_SYSROOT "${IPHONE_SDKROOT}" CACHE STRING "System root for iOS" FORCE) - - #hack, force link to opengles - set(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework OpenGLES") - - #use the IPhone windowing system - SET(OSG_WINDOWING_SYSTEM "IOS" CACHE STRING "Forced IPhone windowing system on iOS" FORCE) + # set osg default image plugin SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio" CACHE STRING "Forced imageio default image plugin for iOS" FORCE) - #I think this or similar will be required for IPhone apps + # ensure app bundles for example app OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" ON) ELSE() diff --git a/CMakeModules/OsgMacroUtils.cmake b/CMakeModules/OsgMacroUtils.cmake index 8fcc627c2..ab5d74882 100644 --- a/CMakeModules/OsgMacroUtils.cmake +++ b/CMakeModules/OsgMacroUtils.cmake @@ -429,7 +429,7 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP) IF(APPLE) SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "") - IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) + IF(OSG_BUILD_PLATFORM_IPHONE) SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE ${IPHONE_ENABLE_BITCODE}) ENDIF() ENDIF() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4edb8dc39..788e5075f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -243,13 +243,11 @@ ELSE(DYNAMIC_OPENSCENEGRAPH) #needed on win32 or the linker get confused by _declspec declarations ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC) - ADD_SUBDIRECTORY(osgstaticviewer) - - # IPHONE_PORT@tom - IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) + IF(OSG_BUILD_PLATFORM_IPHONE) ADD_SUBDIRECTORY(osgviewerIPhone) + ELSE() + ADD_SUBDIRECTORY(osgstaticviewer) ENDIF() - # IPHONE_PORT@tom ENDIF(DYNAMIC_OPENSCENEGRAPH) diff --git a/examples/osgviewerIPhone/CMakeLists.txt b/examples/osgviewerIPhone/CMakeLists.txt index b0a48f00d..7312207a0 100644 --- a/examples/osgviewerIPhone/CMakeLists.txt +++ b/examples/osgviewerIPhone/CMakeLists.txt @@ -27,7 +27,7 @@ SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES} #backup setting SET(TMP_OSG_BUILD_APPLICATION_BUNDLES {$OSG_BUILD_APPLICATION_BUNDLES}) SET(OSG_BUILD_APPLICATION_BUNDLES TRUE) -SET(MACOSX_DEPLOYMENT_TARGET, ${IPHONE_VERSION_MIN}) +#SET(MACOSX_DEPLOYMENT_TARGET, ${IPHONE_VERSION_MIN}) SETUP_EXAMPLE(osgViewerIPhone) SET_TARGET_PROPERTIES(example_osgViewerIPhone PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer" XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${IPHONE_VERSION_MIN} @@ -35,4 +35,4 @@ SET_TARGET_PROPERTIES(example_osgViewerIPhone PROPERTIES XCODE_ATTRIBUTE_CODE_SI #restore setting SET(OSG_BUILD_APPLICATION_BUNDLES {$TMP_OSG_BUILD_APPLICATION_BUNDLES}) -SET(CMAKE_EXE_LINKER_FLAGS "-framework QuartzCore -framework Foundation -framework OpenGLES -framework UIKit -framework ImageIO -framework CoreImage -framework MobileCoreServices -framework CoreGraphics") +SET(CMAKE_EXE_LINKER_FLAGS "-framework QuartzCore -framework Foundation -framework UIKit -framework ImageIO -framework CoreImage -framework MobileCoreServices -framework CoreGraphics") diff --git a/src/OpenThreads/pthreads/CMakeLists.txt b/src/OpenThreads/pthreads/CMakeLists.txt index 770ca5f85..31b55af09 100644 --- a/src/OpenThreads/pthreads/CMakeLists.txt +++ b/src/OpenThreads/pthreads/CMakeLists.txt @@ -125,7 +125,7 @@ ELSE() ENDIF() IF(APPLE) - IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) + IF(OSG_BUILD_PLATFORM_IPHONE) SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE ${IPHONE_ENABLE_BITCODE}) ENDIF() ENDIF() diff --git a/src/osgDB/CMakeLists.txt b/src/osgDB/CMakeLists.txt index 070a9cec6..03bcd2c93 100644 --- a/src/osgDB/CMakeLists.txt +++ b/src/osgDB/CMakeLists.txt @@ -126,7 +126,7 @@ SET(TARGET_SRC ) IF(APPLE AND NOT ANDROID) - IF(NOT OSG_BUILD_PLATFORM_IPHONE AND NOT OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) + IF(NOT OSG_BUILD_PLATFORM_IPHONE) # Needs CoreFoundation calls and a Carbon function SET(OSGDB_PLATFORM_SPECIFIC_LIBRARIES ${CARBON_LIBRARY} ${COCOA_LIBRARY}) ENDIF() diff --git a/src/osgPlugins/freetype/CMakeLists.txt b/src/osgPlugins/freetype/CMakeLists.txt index f29b81cf8..cb7990509 100644 --- a/src/osgPlugins/freetype/CMakeLists.txt +++ b/src/osgPlugins/freetype/CMakeLists.txt @@ -5,7 +5,7 @@ ENDIF() INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS} ) IF(APPLE) - IF(NOT OSG_BUILD_PLATFORM_IPHONE AND NOT OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) + IF(NOT OSG_BUILD_PLATFORM_IPHONE) SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib") ENDIF() ENDIF() diff --git a/src/osgPlugins/imageio/CMakeLists.txt b/src/osgPlugins/imageio/CMakeLists.txt index 20b257cf8..f53a07b3b 100644 --- a/src/osgPlugins/imageio/CMakeLists.txt +++ b/src/osgPlugins/imageio/CMakeLists.txt @@ -1,11 +1,9 @@ SET(TARGET_SRC ReaderWriterImageIO.cpp ) IF (APPLE) - IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) - # compile FileUtils.cpp as objective-c++ - SET_SOURCE_FILES_PROPERTIES(ReaderWriterImageIO.cpp - PROPERTIES COMPILE_FLAGS "-x objective-c++" - ) + IF(OSG_BUILD_PLATFORM_IPHONE) + # compile as objective-c++ + SET_SOURCE_FILES_PROPERTIES(ReaderWriterImageIO.cpp PROPERTIES COMPILE_FLAGS "-x objective-c++") ENDIF() ENDIF() diff --git a/src/osgViewer/CMakeLists.txt b/src/osgViewer/CMakeLists.txt index 3a13934f4..fc6164faf 100644 --- a/src/osgViewer/CMakeLists.txt +++ b/src/osgViewer/CMakeLists.txt @@ -223,7 +223,7 @@ ELSE() # X11 on Apple requires X11 library plus OpenGL linking hack on Leopard IF(APPLE) # hack for finding the iphone opengl es lib - IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR) + IF(OSG_BUILD_PLATFORM_IPHONE) SET(OPENGL_INCLUDE_DIR ${IPHONE_SDKROOT}/System/Library/Frameworks) SET(OPENGL_LIBRARIES ${IPHONE_SDKROOT}/System/Library/Frameworks/OpenGLES) ELSE()