[CMake] SET_CXX_COMPILER

William A. Hoffman billlist at nycap.rr.com
Thu Feb 16 08:02:36 EST 2006


At 03:12 AM 2/16/2006, Sören Freudiger wrote:
>Hi folks
>
>two questions:
>
>1. my macro:
>  MACRO(SET_CXX_COMPILER compiler)
>    SET(CMAKE_CXX_COMPILER ${compiler} CACHE STRING "C++ compiler" FORCE)
>  ENDMACRO(SET_CXX_COMPILER)
>
>and my implementation:
>  SET_CXX_COMPILER("distcc mpicxx")
>  
>results in a build.cmake file with
>
>  distcc\ mpicxx ...
>
>the problem is the backslash "\" before the blank. How can the be avoided?
>Like this I cannot execute make.
>
>2. why does the compiler not change at the build.cmake file by changing the
>C++ compiler within the advanced options in ccmake? I can set the compiler
>within ccmake e.g. to gcc, but I always get the "c++"-compiler at the build
>file?
>(of course only if I am not using my SET_CXX_COMPILER macro...). 
>
>Hoping for answers,
>QuestAnn

Because of the way the compiler is tested and used for setting things up,
it is not a good idea to change it after the language has been enabled.
The way to do what you want is this:

export CXX = "distcc mpicxx"
cmake ../project

You can tell cmake what compiler to use before running cmake with the
environment variables CC and CXX.  However, I seem to remember a bug
with this, and you may have to use CVS cmake for this to work correctly.

-Bill



More information about the CMake mailing list