[CMake] Passing linker argument in a compiler independent way in CMake?

mchalls mchallss at gmail.com
Thu Nov 1 07:18:23 EDT 2012


I have a project with both GCC and Clang used. I need to pass an option to
the linker. I tried to used CMake this way:

SET_TARGET_PROPERTIES(mytarget PROPERTIES LINK_FLAGS
"--allow-shlib-undefined")

However this simply adds the option *--allow-shlib-undefined* to the
compiler options. But GCC and Clang expects different prefixes for passing
an option to the linker. For example, GCC expects it to be
-Wl--allow-shlib-undefined, while Clang expects another prefix.

Is it possible to solve this in a compiler independent way? Or do I have to
add the prefix myself with and if-else block?



--
View this message in context: http://cmake.3232098.n2.nabble.com/Passing-linker-argument-in-a-compiler-independent-way-in-CMake-tp7582239.html
Sent from the CMake mailing list archive at Nabble.com.


More information about the CMake mailing list