用CMake编译iOS
我通过使用CMake作为我的构build工具编译了一个C ++静态库,我想将它链接到我的iOS应用程序。
我在Xcode中创build了一个简单的'Empty'应用程序,并将名为libengine.a的库链接到它。
我试图编译我的iOS项目,链接器给了我这个警告:
ignoring file /Users/.../build/engine/libengine.a, file was built for archive which is not the architecture being linked (i386): /Users/.../build/engine/libengine.a
据我了解,我需要编译我的库ARM处理器。 问题是我不知道如何。
我认为CMake真的缺乏好的教程。
无论如何,我的CMake脚本附在下面。
任何帮助将不胜感激。
谢谢,Tal。
这是我的主要CMake脚本:
cmake_minimum_required(VERSION 2.8) project(movie-night) if (DEFINED PLATFORM) include(toolchains/ios.cmake) endif() add_definitions(-Wall) set(DEBUG) if (DEFINED DEBUG) add_definitions(-g) endif() if (DEFINED RELEASE) add_definitions(-O3) endif() add_subdirectory(engine) add_subdirectory(ui) add_subdirectory(test)
这是我的工具链/ ios.cmake文件:
set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR arm)
只需使用此工具链文件: http : //code.google.com/p/ios-cmake/并将其用作
cmake -DCMAKE_TOOLCHAIN_FILE=path_to_your_toolchain_file
然后,在CMakeLists.txt
:
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch armv7") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch armv7")
iOS.cmake的第二个版本位于:
https://ceres-solver.googlesource.com
注意:您可能会发现这两个版本的iOS.cmake将只生成您的项目的x86版本。 CMake现在将CMAKE_OSX_SYSROOT设置为系统上可用的(最新)Mac OS X SDK。 您可以通过修改您的iOS.cmake副本来始终设置CMAKE_OSX_SYSROOT来解决此问题。 你可以通过注释掉你的副本iOS.cmake来做到这一点:
# -- Under CMake 3.4.2, CMAKE_OSX_SYSROOT is automatically defined to point to the latest Mac OS X SDK. -- # -- So, the iOS SDK is never found. Grab the correct CMAKE_OS_SYSROOT and ignore any prior setting. -- # If user did not specify the SDK root to use, then query xcodebuild for it. # if (NOT CMAKE_OSX_SYSROOT) execute_process(COMMAND xcodebuild -version -sdk ${XCODE_IOS_PLATFORM} Path OUTPUT_VARIABLE CMAKE_OSX_SYSROOT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) message (STATUS "Using SDK: ${CMAKE_OSX_SYSROOT} for platform: ${IOS_PLATFORM}") message (STATUS "be sure the previous line points to the correct SDK") # endif ( )
- 为什么最终的二进制文件的大小比静态库的大小要小得多呢?
- 文件自预编译头build立以来已被修改
- 获取相机胶卷照片到自定义集合视图
- 将textLabel垂直放置在tableView的UITableViewHeaderFooterView中:willDisplayHeaderView:forSection:
- 在NSObject类中使用AVAudioPlayer播放audio
- iOS上的可恢复断言/断点,如带MS编译器的__debugbreak()
- MonoTouch.Dialog:如何设置EntryElement的字符数限制
- 用于iOS开发的Objective-C ++
- 如何使用UIMenuController iOS5.1防止在UITextView上复制/粘贴/selectpopup窗口