[CMake] CMake passes compiler flags to linker

Arindam Mukherjee arindam.mukerjee at gmail.com
Tue Oct 2 13:05:31 EDT 2012


Hi,

I have used CMAKE_CXX_FLAGS and CMAKE_EXE_LINKER_FLAGS variables to
pass custom options to the C++ compiler and linker. However, cmake
seems to be passing the flags meant only for the compiler to the
linker too. On Solaris with SunStudio 6.2, it passes the -g flag to
the linker causing it to dump core. Is there a way to override this
behaviour.

I tried passing compiler flags via add_definitions(...). This works
but it ends up passing the same option the the C and the C++ compiler
causing errors.

Thanks,
Arindam


More information about the CMake mailing list