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

2016-03-15 Thread Brad King
On 03/15/2016 05:58 AM, Sergio Checa wrote: > In this example, I only want libA and libB linked into the main > executable iff their symbols are used somewhere in the linking > chain (-as-needed). This may work: add_library(A SHARED a.cpp) add_library(B SHARED b.cpp) add_library(L SHARED

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

2016-03-15 Thread Sergio Checa
Hi, Thanks for the suggestion about OBJECT libraries, I've learnt one more way to design my build process. Nevertheless, the effect also appears when linking dynamic libraries. For example, a slightly modified CMakeLists.txt: cmake_minimum_required(VERSION 3.5) file(WRITE a.cpp "") file(WRITE

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

2016-03-14 Thread Brad King
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

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

2016-03-14 Thread Sergio Checa
Hello, This is my first email to this list, so please tell me if I'm not following the contribution process properly. Here is the scenario that I am working on: .---> -flags A | main > L -| | '---> -flags B