testing for library build type for packaging purposes

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 (
    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".


I have this MR which I need to get back to at some point.