如何设置CMAKE_C_COMPILER和CMAKE_CXX_COMPILER来构建适用于iOS的Assimp?

Cur*_*ous 20 cmake ios

当我尝试通过运行来构建Assimp时build_ios.sh,它告诉我:

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.
Run Code Online (Sandbox Code Playgroud)

我需要的道路是:

/Applications/XCode.app/Contents/Developer/Platforms/...
Run Code Online (Sandbox Code Playgroud)

我试着改变DEVROOTbuild_ios.shIPHONE_xxxx_TOOLCHAIN.cmake,因为那是什么CMAKE_C_COMPILER等似乎得到从产生,但它仍然给了我同样的错误.

abi*_*abi 42

选项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
Run Code Online (Sandbox Code Playgroud)

请参阅此内容以了解如何创建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
Run Code Online (Sandbox Code Playgroud)

选项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")
Run Code Online (Sandbox Code Playgroud)

请参阅此内容以了解如何set在CMake中使用命令.此外,是了解某些常见CMake变量使用的有用资源.


以下是官方常见问题解答中的相关条目:http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F

  • cmake 命令在分配 cmake 变量时缺少等号:它应该类似于 `cmake -DCMAKE_C_COMPILER="/path/to/your/c/compiler/executable" -DCMAKE_CXX_COMPILER="/path/to/your/cpp/compiler/可执行文件“/path/to/directory/containing/CMakeLists.txt` (2认同)

neo*_*eye 6

cc和cxx位于内部/Applications/Xcode.app.这应该找到正确的路径

export CXX=`xcrun -find c++`
export CC=`xcrun -find cc`
Run Code Online (Sandbox Code Playgroud)