如何让 CMake 在 Mac OS X 上使用 GCC 而不是 Clang?
问题描述
我找不到有关它的任何信息,只能找到相反的信息(例如,如何将 CMake 设置为使用 clang).
I can't find any info on it, but only the other way around (e.g., how to set CMake to use clang).
我已经使用 brew 安装了 gcc-4.8,设置了所有依赖项、头文件等,现在 CMake 拒绝使用 gcc.
I've installed gcc-4.8 using brew, setup all dependencies, headers, etc, and now CMake refuses to use gcc.
我已经使用别名和实际条目设置了我的 bash 配置文件:
I've set my bash profile with both aliases and actual entries:
然而,CMake 顽固地拒绝使用 gcc,而是恢复为 clang:
Yet CMake stubbornly refuses to use gcc and instead reverts back to clang:
推荐答案
CMake 不(总是)听 CC
和 CXX
.而是使用 CMAKE_C_COMPILER
和 CMAKE_CXX_COMPILER
:
CMake doesn't (always) listen to CC
and CXX
. Instead use CMAKE_C_COMPILER
and CMAKE_CXX_COMPILER
:
另见文档.
或者,您可以提供一个工具链文件,但在这种情况下这可能有点矫枉过正.
Alternatively, you can provide a toolchain file, but that might be overkill in this case.
这篇关于如何让 CMake 在 Mac OS X 上使用 GCC 而不是 Clang?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!