CMake Support for different compilers

William A. Hoffman billlist at nycap.rr.com
Tue Mar 21 17:45:48 CET 2006


At 10:56 AM 3/21/2006, Allen Winter wrote:
>In FindKDE4Internal.cmake I'd like to at least setup the framework for
>supporting different C/C++ compilers, including icecream, icc, etc.
>
>I assume we want to support the $CC and $CXX environment variables,
>and also the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER values.
>
>Does code like the following work?
>if ($ENV{CC} MATCHES "[:print:]")
>   set(CMAKE_C_COMPILER $ENV{CC})
>endif ($ENV{CC} MATCHES "[:print:]")
># now set C compiler options based on which compiler being used
>
>But, if the user has $CC=gcc set but then runs "cmake -DCMAKE_C_COMPILER=icecream"
>cmake will use gcc instead of icecream, and we probably agree that the command line
>value (icecream) should override the environment variable.  So how do you tell cmake
>to use the command line value in this case.
>
>Or am I totally off-track here?

The compiler should not be changed from within a cmakelist file.
CMake already looks for CC and CXX environment variables for the compiler
to try.

-Bill



More information about the Kde-buildsystem mailing list