[CMake] CMAKE set linker variables (including custom linker script)

Vittorio Giovara vittorio.giovara at gmail.com
Mon Jun 24 03:14:34 EDT 2013


On Thu, Jun 20, 2013 at 9:57 PM, Martin Osterloh <
Martin.Osterloh at dartmouth.edu> wrote:

>  I am currently migrating my project to CMAKE and so far it has been
> going quite well. I am using the standard “ld” as a linker with options –N
> –S –q –T <path-to-linkerscript.ld>****
>
> ** **
>
> In my CMakeLists.txt I do:****
>
> Set(CMAKE_C_LINK_EXECUTABLE “ld –N –S –q –T <path-to-linkerscript.ld>”)***
> *
>
> ** **
>
> This seems to invoke the correct linker script. However, it also fails to
> produce any binaries! No compilation or linker errors (even with --verbose).
> ****
>
> The code compiles fine and produces executables without setting this
> variable.****
>
> **
>

Shouldn't you be using CMAKE_EXE_LINKER_FLAGS for adding linker flags? The
variable you are using overrides the whole linker invocation and you have
to take care of all paths and outputs on your own.
If you are linking libraries, use CMAKE_SHARED_LIBRARY_C[XX]_FLAGS, after
setting up CMP0018 policy.
Also, don't forget -Wl

Cheers,
Vittorio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130624/0938e4a6/attachment.htm>


More information about the CMake mailing list