你如何设置 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER 来构建 Assimp for iOS? [英] How do you set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER for building Assimp for iOS?

查看:123
本文介绍了你如何设置 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER 来构建 Assimp for iOS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

CMake 错误:您的 C 编译器:未找到/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc".请将 CMAKE_C_COMPILER 设置为有效的编译器路径或名称.CMake 错误:您的 CXX 编译器:找不到/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-g++".请将 CMAKE_CXX_COMPILER 设置为有效的编译器路径或名称.

我需要的路径是:

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

我已经尝试在 build_ios.shIPHONE_xxxx_TOOLCHAIN.cmake 中更改 DEVROOT,因为这就是 CMAKE_C_COMPILER等似乎是从生成的,但它仍然给我同样的错误.

解决方案

选项 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/包含/CMakeLists.txt

参见这个了解如何创建 CMake 缓存条目.

<小时>

选项 2:

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

export CC=/path/to/your/c/compiler/executableexport CXX=/path/to/your/cpp/compiler/executablecmake/path/to/directory/包含/CMakeLists.txt

<小时>

选项 3:

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

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

请参阅以了解如何在 CMake 中使用 set 命令.另外这个是了解一些常见 CMake 变量的有用资源.

<小时>

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

When I try to build Assimp by running build_ios.sh, it tells me:

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.

What I need the path to be is:

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

I've tried changing DEVROOT in build_ios.sh and IPHONE_xxxx_TOOLCHAIN.cmake, because that's what CMAKE_C_COMPILER etc seem to get generated from, but it still gives me the same errors.

解决方案

Option 1:

You can set CMake variables at command line like this:

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

See this to learn how to create a CMake cache entry.


Option 2:

In your shell script build_ios.sh you can set environment variables CC and CXX to point to your C and C++ compiler executable respectively, example:

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


Option 3:

Edit the CMakeLists.txt file of "Assimp": Add these lines at the top (must be added before you use project() or enable_language() command)

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

See this to learn how to use set command in CMake. Also this is a useful resource for understanding use of some of the common CMake variables.


Here is the relevant entry from the official FAQ: https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-do-i-use-a-different-compiler

这篇关于你如何设置 CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER 来构建 Assimp for iOS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆