为什么Cmake总是选择GCC?
问题描述:
由于我无法完全理解的原因,Cmake在编译软件时选择了GNU编译器工具集。为什么Cmake总是选择GCC?
我的环境是这样的:
which cc
/opt/cray/xt-asyncpe/4.9/bin/cc
which CC
/opt/cray/xt-asyncpe/4.9/bin/CC
echo $CC
/opt/cray/xt-asyncpe/4.9/bin/cc
echo $CXX
/opt/cray/xt-asyncpe/4.9/bin/CC
但是当我使用的cmake我得到这个
Using existing /opt/cmake/2.8.4/bin/cmake
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
而构建的所有使用g ++命令的软件。为什么会这样呢?如何设置编译器?
答
我不确定为什么CMake支持GCC。
然而,设置编译器,使用方法:
cmake .
答
您可以:
cmake <path to CMakeLists.txt> -DCMAKE_C_COMPILER=/opt/cray/xt-asyncpe/4.9/bin/cc -DCMAKE_CXX_COMPILER=/opt/cray/xt-asyncpe/4.9/bin/CC
这些值将被缓存,因此后续的CMake(如果需要)的运行可以简单地通过调用也像autotools一样设置env vars CC和CXX。
CC = CC CXX = CC的cmake ...
确保您先建立一个空构建树。
+0
+1更容易...也要注意** make cc = cc CXX = cc **不适用于cmake这种方式,它必须加上前缀。 – FUD
真正搞砸的是,这个程序上的./configuration调用cmake ...它是我们生活的一个疯狂的世界。 – Mikhail