OS X: CMake ignores CMAKE_C_COMPILER

1.2k Views Asked by At

I am trying to build Trilinos on my OS X 10.11.6 laptop and keep encountering the following problem: CMake uses Apple's Clang instead of GCC

... 

Probing the environment ...

-- USE_XSDK_DEFAULTS='FALSE'
-- CMAKE_BUILD_TYPE='RELEASE'
-- BUILD_SHARED_LIBS='FALSE'
-- CMAKE_C_COMPILER_ID='AppleClang'
-- CMAKE_C_COMPILER_VERSION='7.3.0.7030031'
-- CMAKE_CXX_COMPILER_ID='AppleClang'
-- CMAKE_CXX_COMPILER_VERSION='7.3.0.7030031'

...

Despite the fact that I passed gcc/g++ address as an argument in call:

cmake -D CMAKE_C_COMPILER=/usr/bin/gcc -D CMAKE_CXX_COMPILER=/usr/bin/g++  ..

I installed GCC and G++ separately:

$ gcc --version

gcc (GCC) 4.9.2 20141029 (prerelease)

Copyright (C) 2014 Free Software Foundation, Inc.

UPD If anybody's interested, I've given up and moved development to ubuntu. If you find a way to do this, please comment below

1

There are 1 best solutions below

3
Tsyvarev On

When compiler is set explicitely, CMake doesn't try to guess its identification (variables *_COMPILER_ID and *_COMPILER_VERSION.

If you want (and usually you do want) this identification to correctly reflect your compiler, you need to set these variables explicitely too.

For setup several variables describing building environment you may use toolchain files.