Bug #14589
openExported CMake targets contain full paths to dependent libraries
0%
Description
Environment: Windows, MSVC, CMake 3.31, static build, Wt 4.13 release branch
After building static libraries from Wt the generated file 'wt-target-http.cmake' contains absolute path to Zlib library and OpenSSL library.
E.g.
set_target_properties(Wt::HTTP PROPERTIES
INTERFACE_LINK_LIBRARIES "Wt::Wt;c:/_Dev/out/zlib/msvc17-amd64-static/lib/zlibstaticd.lib;..."
)
Hence a consumer cannot use a prebuilt package of static Wt with CMake exported targets on another machine.
This bug can be fixed by using imported targets in CMake rather than using CMake variables:
E.g. in src\http\CMakeLists.txt we have:
TARGET_LINK_LIBRARIES(wthttp
PUBLIC
wt
PRIVATE
${MY_ZLIB_LIBS}
${MY_SSL_LIBS}
...
And should be like this:
TARGET_LINK_LIBRARIES(wthttp
PUBLIC
wt
PRIVATE
ZLIB::ZLIB
OpenSSL::SSL OpenSSL::Crypto
...
Then we will have correct INTERFACE_LINK_LIBRARIES in exported CMake targets:
set_target_properties(Wt::HTTP PROPERTIES
INTERFACE_LINK_LIBRARIES "Wt::Wt;\$<LINK_ONLY:ZLIB::ZLIB>;\$<LINK_ONLY:OpenSSL::SSL>;\$<LINK_ONLY:OpenSSL::Crypto>;...
)
This would allow the consumer of Wt to do find_package(ZLIB REQUIRED) and linking will succeed.
The following dependent libraries are affected:
- ZLIB
- OpenSSL
- Sqlite3
- PostgreSQL
For SQlite3 the internal finder module does not support imported targets. I suggest to remove internal package finders and use CMake default find modules for all dependent libraries or even use exported targets from dependent libraries where applicable.
No data to display