[CMake] What is the proper way to force compiler?

J Decker d3ck0r at gmail.com
Mon Mar 1 21:47:09 EST 2010


I'd like to know why I have to do this at the end of each CMakeLists.txt...

if( C++ )
  set( CMAKE_C_COMPILER "${CMAKE_CXX_COMPILER}" )
  set( CMAKE_C_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}" )
endif()

if I do those lines any time sooner than the very end of the file,
then the compiler override does not hold.

I'd like to do this at the very beginning of my root CMakeLIsts.txt so
all sub-projects inherit the settings.

and I might not have to do both of these, probably just the first? ...
well, the C and C++ options might very, so really maybe I should just
do the second, except the line set in COMPILE_OBJECT references
COMPILER...


so at this state, I have to add this after all add_subdirectories() in
each and every CMakeLists.txt file.


More information about the CMake mailing list