[cmake-developers] Duplicated linking flags are removed when linking final executable

Brad King brad.king at kitware.com
Mon Mar 14 10:58:20 EDT 2016


On 03/14/2016 09:33 AM, Sergio Checa wrote:
>     target_link_libraries(L
>         -Wl,-whole-archive A -Wl,-no-whole-archive
>         -Wl,-whole-archive B -Wl,-no-whole-archive
>     )
> 
>     add_executable(main main.cpp)
>     target_link_libraries(main L)

Specifying flags anywhere except the final executable's target_link_libraries
is not very well defined.  I'd rather not try to define behavior different
than has been there for a long time.

It looks like you're trying to achieve what OBJECT libraries are for:

  https://cmake.org/cmake/help/v3.5/command/add_library.html#object-libraries

Please try that approach instead.

-Brad



More information about the cmake-developers mailing list