[CMake] CMAKE_EXE_LINKER_FLAGS are not used for linking the compiler test; CMAKE_C_FLAGS are used instead
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Thu Jan 17 05:10:55 EST 2013
Hi,
I need to build a project with a weird set of compile/link flags:
CFLAGS = -fsanitize=memory
LINKFLAGS for executables = -fsanitize=memory -pie
LINKFLAGS for shared libraries = -fsanitize=memory
The trick is, linker flags have to be exactly this way: -pie can not be
omitted for executables (the other flag requires -pie, link will fail
without it), and, of course, it can not be specified for shared libraries.
I configure the project with
-DCMAKE_C_FLAGS=-fsanitize=memory -DCMAKE_EXE_LINKER_FLAGS=-pie
and get a failure in the compiler test:
[2/2] Linking C executable cmTryCompileExec3346801198
...
clang-3: error: invalid argument '-fsanitize=memory' only allowed with
'-pie'
Apparently, linking of the compiler test binary is done with
CMAKE_C_FLAGS, but without CMAKE_EXE_LINKER_FLAGS. Is it true? Why? Am
I missing something? Any workarounds?
Sorry if this is a duplicate message, it did not make it to the list
on the first try.
More information about the CMake
mailing list