install(IMPORTED_RUNTIME_ARTIFACTS rejects libraries of type UNKNOWN
Imported targets will often be created as type
UNKNOWN because they could be shared or static. The
FindZLIB module is a prime example where the target type is
UNKNOWN, but the
install(IMPORTED_RUNTIME_ARTIFACTS command should be able to delay its checks on whether the underlying binary is a shared or static library until later. At the moment, the following simple project results in an error:
cmake_minimum_required(VERSION 3.21) project(rundep) find_package(ZLIB REQUIRED) install(IMPORTED_RUNTIME_ARTIFACTS ZLIB::ZLIB)
CMake Error at CMakeLists.txt:5 (install): install IMPORTED_RUNTIME_ARTIFACTS given target "ZLIB::ZLIB" which is not an executable, library, or module.
As it happens, the above sample project is likely to be a very common use case for the command. Given that this is new functionality being added for CMake 3.21, it would seem desirable to make this work for
UNKNOWN libraries in that release as well.