I have a CMake
multiple definition linking problem with an executable that depends on a shared library that contains a static library.
I create a shared library foo
that depends on a static library bar
.
add_library(foo SHARED foo.cpp)
target_link_libraries(foo bar)
By definition, the content of bar
is in library foo
.
Then I create an executable exe
that depends on foo
.
add_executable(exe exe.cpp)
target_link_libraries(exe foo)
At linking time, I have a multiple definition
warning/error that tells me that functions in library bar
are present twice. When looking at the linking command, I see that exe
is linked against bar
and foo
, which is not consistent.
Do I miss something in the declaration of dependencies? Do I miss a magic CMake
keyword?