2012-05-10 109 views
4

我正在嘗試使用Cmake生成ASSIMP的Xcode項目。我知道它已經有一個工作區文件夾。而我只是想創造自己。我試着寫了cmakelist.txt:如何使用Cmake爲IOS生成靜態庫的xcode項目?

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) 

然後我跑這個命令:

#!/bin/bash 
cd "$(dirname "$0")"/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 

它生成的Xcode項目,但產品是libassimp.dylib,並得到了「target指定產品類型「 com.apple.product-type.library.dynamic',但是'iphoneos'平臺「沒有這樣的產品類型錯誤。

如何將'com.apple.product-type.library.dynamic'更改爲靜態?我已經設置了-DBUILD_SHARED_LIBS = OFF但它不起作用。

我搜索了網絡,無法找到造成問題的原因。

非常感謝您的幫助!

+0

哦,請原諒我疏忽,在/ code /目錄下的cmakelist.txt中有一行: ADD_LIBRARY(assimp SHARED 只是將SHARED更改爲STATIC,現在可以在IOS平臺上構建 – user1349923

回答

9

在/代碼/目錄cmakelist.txt有一行:ADD_LIBRARY(assimp SHARED只是改變共享STATIC

我使用的cmakelist:

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)