[cmake-developers] GCC link options

J Decker d3ck0r at gmail.com
Tue Jul 24 17:24:51 EDT 2012


On Tue, Jul 24, 2012 at 11:47 AM, Brad King <brad.king at kitware.com> wrote:
> On 07/24/2012 12:58 PM, J Decker wrote:
>> but after all the libraries that have been applied to this exectuable
>> target are a bunch more libraries, presumably the ones that are
>> recursively referenced by other libs....
>
> Yes, they are.
>
>> So how can I add a library to the very end of the list to link?
>
> If you specify it as a dependency of all the other libraries then
> the dependencies will ensure it ends up at the end.
>
>  target_link_libraries(mylib1 lastlib)
>  ...
>  target_link_libraries(mylibN lastlib)

Okay... that makes sense.  But... since I have the link line with
VERBOSE=1, I know advapi32 is the last library...

CMake Error at eltanin/sdlgui/src/eltanin_sdl/CMakeLists.txt:68
(target_link_libraries):
  Cannot specify link libraries for target "advapi32" which is not built by
  this project.

... or I know the last library that I did build...

CMake Error at eltanin/sdlgui/src/eltanin_sdl/CMakeLists.txt:68
(target_link_libraries):
  Attempt to add link library "eltanin_sdl_deadstart_end" to target
  "playcard" which is not built in this directory.

... so I can put it in the playcard target, and reference the library,
and it gets put in a good place.

Is there something I can do to make sure this specific library is
last?  That maybe someone needs to update the cmake scripts?

It's possible with time that this will no longer be the last library....


>
> Alternatively, don't specify any target_link_libraries calls
> so that there are no indirect dependencies.
Where would I put the libraries then? as part of the sources?

>
> -Brad



More information about the cmake-developers mailing list