I use vcpkg to install few external dependencies (zlib, pthreads, etc) for my projects, then pick them up with find_package() calls; sometimes I want to link them statically and vcpkg makes this easy by allowing me to use something like -D VCPKG_TARGET_TRIPLET=x64-windows-static
on the cmake command line.
However, when it comes to packaging the whole project if I use something like this:
install (
FILES
${PThreads4W_LIBRARY_RELEASE_DLL}
DESTINATION .
COMPONENT my-component
)
it breaks when I use the static version of libraries.
Is there a way to test how the library I am importing is built? I’ve found that targets have a “STATIC_LIBRARY” property (https://cmake.org/cmake/help/latest/prop_tgt/TYPE.html) but it seems I am not able to query it, for instance this fails:
get_target_property(LINK_TYPE ZLIB::ZLIB TYPE)
message("LINK TYPE: " "${LINK_TYPE}")
like this:
CMake Error at dist/CMakeLists.txt:124 (get_target_property):
get_target_property() called with non-existent target "ZLIB::ZLIB".
Ideas?