diff --git a/CMakeLists.txt b/CMakeLists.txt index 94c7973cd..de8af363c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/examples/osgviewerIPhone/CMakeLists.txt b/examples/osgviewerIPhone/CMakeLists.txt index 0aaf24cb6..adaabe92d 100644 --- a/examples/osgviewerIPhone/CMakeLists.txt +++ b/examples/osgviewerIPhone/CMakeLists.txt @@ -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") diff --git a/src/osgDB/CMakeLists.txt b/src/osgDB/CMakeLists.txt index 54cd41460..d457f2eac 100644 --- a/src/osgDB/CMakeLists.txt +++ b/src/osgDB/CMakeLists.txt @@ -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") diff --git a/src/osgPlugins/freetype/CMakeLists.txt b/src/osgPlugins/freetype/CMakeLists.txt index 0151bf1ee..79d3f7f7e 100644 --- a/src/osgPlugins/freetype/CMakeLists.txt +++ b/src/osgPlugins/freetype/CMakeLists.txt @@ -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 diff --git a/src/osgPlugins/imageio/CMakeLists.txt b/src/osgPlugins/imageio/CMakeLists.txt index c22050669..3e806e800 100644 --- a/src/osgPlugins/imageio/CMakeLists.txt +++ b/src/osgPlugins/imageio/CMakeLists.txt @@ -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" ) diff --git a/src/osgViewer/CMakeLists.txt b/src/osgViewer/CMakeLists.txt index 8358ed29e..45394e594 100644 --- a/src/osgViewer/CMakeLists.txt +++ b/src/osgViewer/CMakeLists.txt @@ -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()