1

For reasons that I cannot completely understand, Cmake awlays chooses the GNU compiler toolset when compiling software.

My enviroment looks like this:

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

but when I use cmake I get this

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

And it builds all the software with g++ commands. Why is this going on? How does one set the compiler?

Mikhail
  • 7,749
  • 11
  • 62
  • 136

2 Answers2

5

You can also set the env vars CC and CXX much like autotools.

CC=cc CXX=CC cmake ...

Make sure you start with an empty build tree.

Bill Hoffman
  • 1,742
  • 11
  • 12
  • +1 much easier...also to note **make CC=cc CXX=cc** doesnt works for cmake that way, it has to be prefixed. – FUD Feb 07 '13 at 05:20
2

I'm not sure why CMake favours GCC.

However, to set the compilers, use:

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

These values will be cached, so subsequent runs of CMake (if required) can simply be invoked by:

cmake .
Fraser
  • 74,704
  • 20
  • 238
  • 215
  • 1
    What is really messed up is that the ./configuration on this program calls cmake... Its a crazy world we live in. – Mikhail Jun 01 '12 at 22:32