xcode 如何使用Cmake为IOS生成静态库的xcode项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10530849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to generate the xcode project of static libs for IOS using Cmake?
提问by user1349923
I'm trying generate the Xcode project of ASSIMP using Cmake. I know there is already one in it's workspace folder. And I just trying to generate myself. I tried to write the cmakelist.txt:
我正在尝试使用 Cmake 生成 ASSIMP 的 Xcode 项目。我知道它的工作区文件夹中已经有一个。而我只是试图生成自己。我试着写cmakelist.txt:
cmake_minimum_required(VERSION 2.8)
project(assimp)
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")
set(CMAKE_OSX_SYSROOT iphoneos5.1)
set(CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD_32_BIT))
add_subdirectory(assimp)
then i ran this command:
然后我运行了这个命令:
#!/bin/bash
cd "$(dirname "cmake_minimum_required(VERSION 2.8.6)
project(assimp)
# Set the Base SDK (only change the SDKVER value, if for instance, you are building for iOS 5.0):
set(SDKVER "5.1")
set(DEVROOT "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer")
set(SDKROOT "${DEVROOT}/SDKs/iPhoneOS${SDKVER}.sdk")
if(EXISTS ${SDKROOT})
set(CMAKE_OSX_SYSROOT "${SDKROOT}")
else()
message("Warning, iOS Base SDK path not found: " ${SDKROOT})
endif()
# Will resolve to "Standard (armv6 armv7)" on Xcode 4.0.2 and to "Standard (armv7)" on Xcode 4.2:
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_BIT)")
# seamless toggle between device and simulator
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
add_subdirectory(assimp)
")"/assimp
if [ ! -d xcode ]
then
mkdir xcode
fi
cd xcode
cmake -G Xcode ../.. -DINSTALL_LIBS=ON -DCMAKE_INSTALL_PREFIX=../.. -DBUILD_SHARED_LIBS=OFF -DBUILD_ASSIMP_TOOLS:BOOL=OFF -DENABLE_BOOST_WORKAROUND=ON
# Device or simulator
xcodebuild -target install -configuration Release
it generates the Xcode project but in products is libassimp.dylib and got the "target specifies product type 'com.apple.product-type.library.dynamic', but there's no such product type for the 'iphoneos' platform" error.
它生成 Xcode 项目,但在产品中是 libassimp.dylib 并得到“目标指定产品类型 'com.apple.product-type.library.dynamic',但没有这样的产品类型用于 'iphoneos' 平台”错误。
How to change the 'com.apple.product-type.library.dynamic' to static? I had set -DBUILD_SHARED_LIBS=OFF but it didn't work.
如何将“com.apple.product-type.library.dynamic”更改为静态?我已经设置了 -DBUILD_SHARED_LIBS=OFF 但它没有用。
I searched the web and can't find what is causing the problem.
我在网上搜索并找不到导致问题的原因。
Thank you very much for any help!
非常感谢您的帮助!
回答by user1349923
in cmakelist.txt at /code/ directory there is a line: ADD_LIBRARY( assimp SHARED just change the SHARED to STATIC
在 /code/ 目录下的 cmakelist.txt 中有一行:ADD_LIBRARY(assimp SHARED just change the SHARED to STATIC
the cmakelist i'm using:
我正在使用的 cmakelist:
##代码##