From Ulrich Hertlein, "Attached; here's a summary of the changes:

- CMakeLists.txt
-- don't look for GL when compiling for iOS (device or simulator), look for OGLES instead
-- use architecture i386 for simulator
-- removed iphoneos-version-min for simulator

- examples/osgviewerIPhone/CMakeLists.txt
-- added build dependencies for osgdb_osg, osgdb_freetype, osgdb_imageio
-- added framework QuartzCore link dependency

- src/osgDB/CMakeLists.txt
-- don't link against Carbon on iOS (device or simulator)

- src/osgPlugins/freetype/CMakeLists.txt
-- don't link against OpenGL on iOS device or simulator

- src/osgViewer/CMakeLists.txt
-- link against OpenGLES on iOS (device or simulator)

- src/osgPlugins/imageio/CMakeLists.txt
-- compile ReaderWriterImageIO_IOS.cpp as Objective-C++

"
This commit is contained in:
Robert Osfield 2010-12-02 14:20:52 +00:00
parent 65aee287e7
commit 0754a78ddb
6 changed files with 34 additions and 20 deletions

View File

@ -138,10 +138,6 @@ IF (OSG_MAINTAINER)
ENDIF(OSG_MAINTAINER)
# Find OpenGL
FIND_PACKAGE(OpenGL)
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
@ -169,17 +165,22 @@ IF(APPLE)
SET (IPHONE_DEVROOT "/Developer/Platforms/iPhoneSimulator.platform/Developer")
SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneSimulator${IPHONE_SDKVER}.sdk")
ENDIF()
ENDIF ()
FIND_LIBRARY(CARBON_LIBRARY Carbon)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
IF(OSG_BUILD_PLATFORM_IPHONE)
# Apple iOS: Find OpenGLES
FIND_LIBRARY(OPENGLES_LIBRARY OpenGLES)
ENDIF()
ELSE ()
FIND_LIBRARY(CARBON_LIBRARY Carbon)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
# Apple OS X: Find OpenGL
FIND_PACKAGE(OpenGL)
ENDIF ()
OPTION(OSG_COMPILE_FRAMEWORKS "compile frameworks instead of dylibs (experimental)" OFF)
SET(OSG_COMPILE_FRAMEWORKS_INSTALL_NAME_DIR "@executable_path/../Frameworks" CACHE STRING "install name dir for compiled frameworks")
ELSE()
# Non-Apple: Find OpenGL
FIND_PACKAGE(OpenGL)
ENDIF()
IF(UNIX)
@ -708,8 +709,8 @@ IF(APPLE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=3.1 -mno-thumb -arch armv6 -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
ELSE()
#simulator uses i386 architectures
SET(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for iOS Simulator" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=3.1 -mno-thumb -arch i386 -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." FORCE)
SET(CMAKE_OSX_ARCHITECTURES "i386" CACHE STRING "Build architectures for iOS Simulator" FORCE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-thumb -arch i386 -pipe -no-cpp-precomp" CACHE STRING "Flags used by the compiler during all build types." 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 seperate projects
@ -720,7 +721,7 @@ IF(APPLE)
#use the IPhone windowing system
SET(OSG_WINDOWING_SYSTEM "IOS" CACHE STRING "Forced IPhone windowing system on iOS" FORCE)
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "imageio " CACHE STRING "Forced imageio default image plugin for iOS" FORCE)
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
OPTION(OSG_BUILD_APPLICATION_BUNDLES "Enable the building of applications and examples as OSX Bundles" ON)

View File

@ -6,12 +6,12 @@ SET(TARGET_SRC
osgIPhoneViewer-Info.plist
)
SET(TARGET_ADDED_LIBRARIES osgdb_osg osgdb_freetype osgdb_imageio)
#backup setting
SET(TMP_OSG_BUILD_APPLICATION_BUNDLES {$OSG_BUILD_APPLICATION_BUNDLES})
SET(OSG_BUILD_APPLICATION_BUNDLES TRUE)
SETUP_EXAMPLE(osgViewerIPhone)
#restore setting
SET(OSG_BUILD_APPLICATION_BUNDLES {$TMP_OSG_BUILD_APPLICATION_BUNDLES})
SET(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework OpenGLES -framework UIKit")
SET(CMAKE_EXE_LINKER_FLAGS "-framework QuartzCore -framework Foundation -framework OpenGLES -framework UIKit")

View File

@ -121,8 +121,10 @@ ADD_LIBRARY(${LIB_NAME}
)
IF(APPLE)
# Needs CoreFoundation calls and a Carbon function
SET(OSGDB_PLATFORM_SPECIFIC_LIBRARIES ${CARBON_LIBRARY})
IF(NOT OSG_BUILD_PLATFORM_IPHONE AND NOT OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
# Needs CoreFoundation calls and a Carbon function
SET(OSGDB_PLATFORM_SPECIFIC_LIBRARIES ${CARBON_LIBRARY})
ENDIF()
SET(OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX "quicktime" CACHE STRING "standard image plugin for os x, options are quicktime, imageio")

View File

@ -5,7 +5,9 @@ ENDIF()
INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS} )
IF(APPLE)
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")
IF(NOT OSG_BUILD_PLATFORM_IPHONE AND NOT OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
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()
SET(TARGET_SRC

View File

@ -4,6 +4,15 @@ ELSE()
SET(TARGET_SRC ReaderWriterImageIO.cpp )
ENDIF()
IF (APPLE)
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
# compile FileUtils.cpp as objective-c++
SET_SOURCE_FILES_PROPERTIES(ReaderWriterImageIO_IOS.cpp
PROPERTIES COMPILE_FLAGS "-x objective-c++"
)
ENDIF()
ENDIF()
SET(TARGET_ADDED_LIBRARIES)
SET(TARGET_LIBRARIES_VARS IMAGEIO_LIBRARY )
SET(TARGET_EXTERNAL_LIBRARIES "/System/Library/Frameworks/Accelerate.framework" )

View File

@ -195,7 +195,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_IOS)
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
SET(OPENGL_INCLUDE_DIR ${IPHONE_SDKROOT}System/Library/Frameworks)
SET(OPENGL_LIBRARIES ${IPHONE_SDKROOT}System/Library/Frameworks/OpenGLES)
ELSE()