2012-06-01 33 views
1

由於我無法完全理解的原因,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 ++命令的軟件。爲什麼會這樣呢?如何設置編譯器?

回答

1

我不確定爲什麼CMake支持GCC。

然而,設置編譯器,使用方法:

cmake . 
+1

真正搞砸的是,這個程序上的./configuration調用cmake ...它是我們生活的一個瘋狂的世界。 – Mikhail

5

您可以:

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