iOS CMake project generation improvements (bitcode option)

when building for iOS, Xcode allows developers to specify to enable or disable the 'bitcode' compilation option. There's not a preferred way to go and the choice is really up to the developer but considering that:

1. Currently the generated project defaults the option to YES
2. There are almost 90 projects targets that should be modified if one wants to disable the bitcode option (which considerably reduces the footprint of the app)
3. Even though one can select all the 90+ targets and set the option to NO for all of them, the updates could take a few seconds and could be error prone because one could miss to select some targets

I propose to add a CMake setting that is displayed only when building for iOS. By setting this option "before" the project generation would speed up things for developers and would avoid errors at compiling time.
This commit is contained in:
Alessandro Terenzi 2018-03-09 10:17:59 +00:00 committed by Robert Osfield
parent e17f1c4e31
commit 9010fd8035
3 changed files with 18 additions and 2 deletions

View File

@ -76,9 +76,9 @@ IF(APPLE AND NOT ANDROID)
#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 #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(OSG_BUILD_PLATFORM_IPHONE)
IF(${IPHONE_VERSION_MIN} LESS "7.0") IF(${IPHONE_VERSION_MIN} LESS "7.0")
SET(CMAKE_OSX_ARCHITECTURES "armv6;armv7" CACHE STRING "Build architectures for iOS" FORCE) SET(CMAKE_OSX_ARCHITECTURES "armv6;armv7" CACHE STRING "Build architectures for iOS" FORCE)
ELSE() ELSE()
SET(CMAKE_OSX_ARCHITECTURES "armv7;armv7s;arm64" CACHE STRING "Build architectures for iOS" FORCE) SET(CMAKE_OSX_ARCHITECTURES "armv7;armv7s;arm64" CACHE STRING "Build architectures for iOS" FORCE)
ENDIF() ENDIF()
ELSE() ELSE()
@ -263,6 +263,8 @@ IF(APPLE)
SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneSimulator${IPHONE_SDKVER}.sdk") SET (IPHONE_SDKROOT "${IPHONE_DEVROOT}/SDKs/iPhoneSimulator${IPHONE_SDKVER}.sdk")
ENDIF() ENDIF()
SET (IPHONE_ENABLE_BITCODE "NO" CACHE STRING "IOS Enable Bitcode")
# Apple iOS: Find OpenGLES # Apple iOS: Find OpenGLES
FIND_LIBRARY(OPENGLES_LIBRARY OpenGLES) FIND_LIBRARY(OPENGLES_LIBRARY OpenGLES)
ELSE () ELSE ()

View File

@ -225,6 +225,9 @@ MACRO(SETUP_LIBRARY LIB_NAME)
) )
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES FOLDER "OSG Core") SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES FOLDER "OSG Core")
IF(APPLE) IF(APPLE)
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE ${IPHONE_ENABLE_BITCODE})
ENDIF()
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "") SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "")
ENDIF() ENDIF()
IF(TARGET_LABEL) IF(TARGET_LABEL)
@ -333,6 +336,9 @@ MACRO(SETUP_PLUGIN PLUGIN_NAME)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES FOLDER "Plugins") SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES FOLDER "Plugins")
IF(APPLE) IF(APPLE)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "") SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "")
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE ${IPHONE_ENABLE_BITCODE})
ENDIF()
ENDIF() ENDIF()
SETUP_LINK_LIBRARIES() SETUP_LINK_LIBRARIES()
@ -423,6 +429,9 @@ MACRO(SETUP_EXE IS_COMMANDLINE_APP)
IF(APPLE) IF(APPLE)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "") SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_WARNING_CFLAGS "")
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
SET_TARGET_PROPERTIES(${TARGET_TARGETNAME} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE ${IPHONE_ENABLE_BITCODE})
ENDIF()
ENDIF() ENDIF()
SETUP_LINK_LIBRARIES() SETUP_LINK_LIBRARIES()

View File

@ -123,6 +123,11 @@ ELSE()
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${OPENTHREADS_VERSION} SOVERSION ${OPENTHREADS_SOVERSION}) SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${OPENTHREADS_VERSION} SOVERSION ${OPENTHREADS_SOVERSION})
ENDIF() ENDIF()
IF(APPLE)
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES XCODE_ATTRIBUTE_ENABLE_BITCODE ${IPHONE_ENABLE_BITCODE})
ENDIF()
ENDIF()
SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_SAFE}") SET(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_SAFE}")