ios - 如何设置 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER 来构建 Assimp for iOS?

标签 ios cmake

当我尝试通过运行 build_ios.sh 构建 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 etc 似乎是从中生成的,但它仍然给我同样的错误。

最佳答案

选项 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学习如何在 CMake 中使用 set 命令。还有 this是了解一些常见 CMake 变量的使用的有用资源。


这是来自官方常见问题解答的相关条目:https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler

关于ios - 如何设置 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER 来构建 Assimp for iOS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11588855/

相关文章:

ios - 如何使用 Storyboard向 UITableView 添加页脚?

ios - 使用 SpriteKit 缩放 SkSpriteNodes

c++ - 如何在大约 v2.8.8 的 cmake 中轻松包含来自库依赖项的 header

c++ - 使用 CMAKE 检查编译器中是否启用了 c++11 功能

C++ 库链接问题

ios - Swift-NIO 安全的 websocket 服务器

ios - 在 objective-c 中按顺序执行 block 代码

ios - 有附加内容时 ScrollView 顶部/底部的渐变

c++ - cmake目标链接openssl错误

c++ - 如何在 CMake 中使用 OpenGL/Angle 编译 QtGui 示例?