Skip to content

Instantly share code, notes, and snippets.

@sixman9
Created December 14, 2010 10:42
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sixman9/740257 to your computer and use it in GitHub Desktop.
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)
# 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")
@sixman9
Copy link
Author

sixman9 commented Dec 14, 2010

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}")

@Amicoolll
Copy link

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

@newNcy
Copy link

newNcy commented Aug 16, 2021

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