Created
December 14, 2010 10:42
-
-
Save sixman9/740257 to your computer and use it in GitHub Desktop.
cmake files for Apple IOS development (has C++ lean, can be adapted however)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See original post at http://stackoverflow.com/questions/822404/how-to-set-up-cmake-to-build-an-app-for-the-iphone | |
cmake_minimum_required(VERSION 2.8) | |
cmake_policy(SET CMP0015 NEW) | |
cmake_policy(SET CMP0016 NEW) | |
project(test) | |
set(NAME test) | |
file(GLOB headers *.h) | |
file(GLOB sources *.cpp) | |
SET (SDKVER "4.1") | |
SET (DEVROOT "/Developer/Platforms/iPhoneOS.platform/Developer") | |
SET (SDKROOT "${DEVROOT}/SDKs/iPhoneOS${SDKVER}.sdk") | |
SET (CMAKE_OSX_SYSROOT "${SDKROOT}") | |
SET (CMAKE_OSX_ARCHITECTURES "$(ARCHS_UNIVERSAL_IPHONE_OS)") | |
#Other 'CMAKE_OSX_ARCHITECTURES' iPhone/IOS option examples | |
#SET (CMAKE_OSX_ARCHITECTURES "armv6" "armv7") | |
#SET (CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_32_BIT)) | |
set(CMAKE_CXX_FLAGS "-x objective-c++") | |
set(CMAKE_EXE_LINKER_FLAGS | |
"-framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework UIKit" | |
) | |
link_directories(\${HOME}/\${SDKROOT}/lib) | |
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.mycompany.\${PRODUCT_NAME:identifier}") | |
set(APP_TYPE MACOSX_BUNDLE) | |
add_executable(${NAME} | |
${APP_TYPE} | |
${headers} | |
${sources} | |
) | |
target_link_libraries(${NAME} | |
# other libraries to link | |
) | |
# code signing | |
set_target_properties(${NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer: My Name") | |
Load a file's content into a CMake variable (parsing properties is the grail...)
SET(cat_prog cat)
IF(WIN32)
IF(NOT UNIX)
SET(cat_prog type)
ELSE(NOT UNIX)
ENDIF(WIN32)
EXEC_PROGRAM(${cat_prog} ARGS /input/file.txt OUTPUT_VARIABLE variable)
MESSAGE("Content of file is: ${variable}")
Hi Guys,
Really Appreciate for this solution.
Will this work with making multiple projects for 1 code as well?
Thanks in Advance.
Thanks & Regards
Amit Singh
do you know how to link an existing framework?
你知道怎么链接一个已经存在的framework吗
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CMake-based IOS resource copying (see StackOverflow post )
Xcode doesn't seem to properly add resources when you build the project using CMake, so I this can be added to the CMakeLists.txt file:
This will copy the entire folder /data into the resources folder (as if we had added a "blue" folder link in Xcode).
Finding IOS Frameworks programmatically within CMake
The following macro snippet [supposedly] can be used in place of the 'CMAKE_EXE_LINKER_FLAGS' property and arguments
Once the macro is in place, the framework can be added thus:
Making CMake produce universal Iphone binaries
Just set the architecture variable to:
This will generate armv6/armv7 etc binaries. There are some posts out there (stackoverflow etc.) which say that this has caused problems with iPad deployment, however, I am unable to verify that at present.