如何获取CMake使用默认编译器在系统PATH? [英] How to Get CMake to Use Default Compiler on System PATH?
问题描述
目前,我从我的构建目录调用CMake如下:
CXX =/ opt / gcc-4.8 / bin / g ++cmake ..
来获取CMake使用这个特定的编译器。
我的PATH有 /opt/gcc-4.8/bin
在一切的前面。所以,而不是前面的环境变量是有办法指定在`CMakeLists.txt文件中使用默认的g ++路径?
CMake尊重 PATH
环境变量的设置,优先于通用编译器名称 cc
和 c ++
。要确定CMake在UNIX下默认使用哪个C编译器,请运行:
$ which cc
要确定默认的C ++编译器,请运行:
$ which c ++
如果生成符号链接在 /opt/gcc-4.8/bin
中指向 /opt/gcc-4.8/bin/g ++ / code>,CMake应该默认使用GCC 4.8。
Currently, I invoke CMake from my build directory as follows:
CXX="/opt/gcc-4.8/bin/g++" cmake ..
to get CMake to use this particular compiler. Otherwise it uses the operating system default compiler.
My PATH has "/opt/gcc-4.8/bin
" in front of everything else. So, instead of prepending the environmental variable is there way to specify in the "`CMakeLists.txt" file to use the default g++ on the path?
解决方案 CMake honors the setting of the PATH
environment variable, but gives preference to the generic compiler names cc
and c++
. To determine which C compiler will be used by default under UNIX by CMake, run:
$ which cc
To determine the default C++ compiler, run:
$ which c++
If you generate a symbolic link c++
in /opt/gcc-4.8/bin
which points to /opt/gcc-4.8/bin/g++
, CMake should use GCC 4.8 by default.
这篇关于如何获取CMake使用默认编译器在系统PATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!