2012-07-21 72 views
12

当我尝试通过运行build_ios.sh建立Assimp,它告诉我:你如何设置CMAKE_C_COMPILER和CMAKE_CXX_COMPILER来为iOS构建Assimp?

CMake Error: your C compiler: "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name. 
CMake Error: your CXX compiler: "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name. 

我需要的路径什么是是:

/Applications/XCode.app/Contents/Developer/Platforms/... 

我试过在build_ios.shIPHONE_xxxx_TOOLCHAIN.cmake改变DEVROOT,因为这就是CMAKE_C_COMPILER等似乎产生,但它仍然给我同样的错误。

+1

你找到一个解决办法? – MatterGoal 2013-04-21 16:26:05

回答

31

选项1:

您可以在命令行设置的CMake变量是这样的:

cmake -D CMAKE_C_COMPILER="/path/to/your/c/compiler/executable" -D CMAKE_CXX_COMPILER "/path/to/your/cpp/compiler/executable" /path/to/directory/containing/CMakeLists.txt 

this学习如何创建CMake的缓存条目。


选项2:

在你的shell脚本build_ios.sh你可以设置环境变量CCCXX分别指向C和C++编译器可执行文件,例如:

export CC=/path/to/your/c/compiler/executable 
export CXX=/path/to/your/cpp/compiler/executable 
cmake /path/to/directory/containing/CMakeLists.txt 

选项3:

编辑的“Assimp”的文件的CMakeLists.txt:顶部添加这些行(您使用project()enable_language()命令之前必须加)

set(CMAKE_C_COMPILER "/path/to/your/c/compiler/executable") 
set(CMAKE_CXX_COMPILER "/path/to/your/cpp/compiler/executable") 

this学习如何在使用set命令CMake的。另外this是了解一些常用CMake变量的使用的有用资源。


下面是来自官方的FAQ中的相关条目:http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F

6

CC和CXX位于内/Applications/Xcode.app。这应该找到合适的路径

export CXX=`xcrun -find c++` 
export CC=`xcrun -find cc`