target_sources with object libraries that have dependencies
So we have a project setup like this
- top level
- CMakeLists.txt
- source 1
- spurce 2
- source ...
- source n
- linux
- CMakeLists.txt
- source a
- source b
- win32
- CMakeLists.txt
- source a
- source b
The top level directory has a bunch of source files + headers and depending on the system the lib is built for it ether adds the linux
or the win32
folder with add_subdirectory
. These folders provide the implementation for some specific headers defined in the main lib. Inside the CMakeLists.txt in linux
or win32
a object library is created from the sources that is then added to the top level library with target_sources
.
Now the problem is that our linux
object lib requires DL
. We did add it with target_link_libraries
to the object library but it seems that this dependency is not there anymore when the main lib is linked.
Is this the intended behavior or is our setup messed up?
Edited by GP