[CMake] overruling compiler fails to work

J.S. van Bethlehem j.s.van.bethlehem at astro.rug.nl
Fri May 6 06:00:10 EDT 2011


Hello everybody,

Let me say from the get-going: this is the worst question I could ask on 
this list because I'm pretty sure I don't provide enough information for 
a solution and the problem is likely not with CMake, but I can't think 
of anything else currently, so I'll give it a go anyway, hoping that 
someone recognizes the symptoms.

In my lists-files I write currently at the very top:
if (NOT CMAKE_CXX_COMPILER)
  set(CMAKE_CXX_COMPILER g++-4.6)
endif(NOT CMAKE_CXX_COMPILER)

It seems a bit contrived, but I use a lot of c++0x-stuff, the compiler 
on the system is still at version 4.4 and so I have to rely on a local 
installation of the more recent compiler. The if()-construct is there to 
allow setting the variable through the environment or on the cmdline. 
This worked fine for me, until this morning. I seemed to have changed 
something that causes CMake to miss this. But AFAICS I didn't change 
anything to the CMake-installation or to the lists-file(s) or to any 
part of my system for that matter. Well.... obviously I'm overlooking 
something. I put a message() before this construct and the output of 
that command appears right after all the standard messages regarding 
compilers (but used to appear before it - I know that for sure, because 
when I started to learn CMake I put a similar message there to test the 
construct I created):
-- 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
-- Detecting CXX compiler ABI info - done
-- Compiler = /usr/bin/c++   #   <- result of message(STATUS "Compiler = 
${CMAKE_CXX_COMPILER}") in front of the if()-construct
...

Again: I'm well aware that I don't nearly provide enough info about 
this. And odds are almost certain that no one can 'guess' what I'm 
overlooking here. My hope is just that by chance someone came across a 
similar situation and did manage to figure out what is going on. 
Hopefully that was the same mistake I'm making....

Yours sincerely,
Jakob van Bethlehem



More information about the CMake mailing list