编译于iOS与CMake的 [英] Compiling for iOS with CMake
问题描述
我用CMake的为我的建筑工具编译的C ++静态库,我想将其链接到我的iOS应用。结果
我创建了X code进行简单的'空'的应用程序和链接叫libengine.a它我的图书馆。结果
我试图编译我的iOS项目和链接给了我这样的警告:结果
忽略文件/Users/.../build/engine/libengine.a,
文件是专为存档而不是被连接的架构(I386):
/Users/.../build/engine/libengine.a
据我了解,我需要编译我的图书馆ARM处理器。现在的问题是,我不知道怎么办。结果
我觉得真正的CMake缺乏良好的教程。结果
不管怎么说,我的CMake的脚本附后。搜索结果
任何帮助将大大AP preciated。结果
谢谢,塔尔。搜索结果
这里是我的主要CMake的脚本:
cmake_minimum_required(版本2.8)项目(电影夜)如果(定义PLATFORM)
包括:(工具链/ ios.cmake)
万一()add_definitions(-Wall)集(调试)如果(定义DEBUG)
add_definitions(-g)
万一()如果(定义RELEASE)
add_definitions(-O3)
万一()add_subdirectory(发动机)
add_subdirectory(UI)add_subdirectory(测试)
下面是我的工具链/ ios.cmake文件:
集(CMAKE_SYSTEM_NAME达尔文)
集(CMAKE_SYSTEM_PROCESSOR ARM)
只要使用这个工具链文件: HTTP ://$c$c.google.com/p/ios-cmake/ ,并把它作为
cmake的-DCMAKE_TOOLCHAIN_FILE = path_to_your_toolchain_file
然后,在的CMakeLists.txt
:
SET(CMAKE_C_FLAGS$ {} CMAKE_C_FLAGS的ARMv7 -arch)
SET(CMAKE_CXX_FLAGS$ {} CMAKE_CXX_FLAGS的ARMv7 -arch)
I've compiled a C++ static library by using CMake as my building tool and I want to link it to my iOS app.
I created a simple 'Empty' application in Xcode and linked my library called libengine.a to it.
I tried to compile my iOS project and the linker gave me this warning:
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
As I understand it, I need to compile my library for ARM processors. The problem is I don't know how.
I think CMake really lacks good tutorials.
Anyways, my CMake scripts are attached below.
Any help would be greatly appreciated.
Thanks, Tal.
Here is my main CMake script:
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)
Here is my toolchains/ios.cmake file:
set(CMAKE_SYSTEM_NAME Darwin)
set(CMAKE_SYSTEM_PROCESSOR arm)
Just use this toolchain file: http://code.google.com/p/ios-cmake/ and use it as
cmake -DCMAKE_TOOLCHAIN_FILE=path_to_your_toolchain_file
Then, in CMakeLists.txt
:
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch armv7")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch armv7")
这篇关于编译于iOS与CMake的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!