Linking static library against object libraries, then exporting it
Hi! I recently started to use object libraries which is a great feature for my needs.
In my project I have a "normal" library named sail-codecs-objects
. I tried to link object libraries into it using target_link_libraries(sail-codecs-objects PRIVATE sail-codec-avif)
which is supposed to work as per the docs. My understanding is that when I link my "normal" library against object libs, their objects and usage requirements should be transferred into my "normal" library.
After that, I install and export the "normal" lib:
install(TARGETS sail-codecs-objects sail-codecs
EXPORT SailCodecsTargets
...)
However, CMake gives me the following error:
CMake Error: install(EXPORT "SailCodecsTargets" ...) includes target "sail-codecs-objects" which requires target "sail-codec-avif" that is not in any export set.
It looks like it tries to export the object library as well. Is that expected?
Interesting is that in a smaller sample project I failed to reproduce the issue. So there is definitely some flaw in my project preventing CMake from configuring it, but I failed to find it. Maybe you can suggest a workaround and what's the issue behind the error?
To dig deeper, the project is located here: https://github.com/HappySeaFox/sail.git . Branch is feature/linking-object-libraries-error
. To reproduce, it's much easier to use Linux. Commands to configure:
cd /tmp
git clone https://github.com/HappySeaFox/sail.git
cd sail
git checkout feature/linking-object-libraries-error
mkdir build && cd build/
cmake -DCMAKE_BUILD_TYPE=Release -DSAIL_STATIC=ON ..