install(TARGETS) installs non-RUNTIME lib when only RUNTIME is given on Windows
The docs for the install(TARGETS)
command state the following:
For each of these arguments given, the arguments following them only apply to the target or file type specified in the argument. If none is given, the installation properties apply to all target types. If only one is given then only targets of that type will be installed (which can be used to install just a DLL or just an import library.)
So code like the following is expected to only install the .dll
on Windows, but not the associated .lib
import library:
install(TARGETS someLib RUNTIME)
However, testing with CMake 3.21.1 and 3.22.0-rc2 shows that the import library IS still installed. If you explicitly add a DESTINATION
to the RUNTIME
section though, then only the .dll
is installed, as expected according to the docs:
install(TARGETS someLib RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
The documented behavior is very desirable, since it makes it easier to create packages that strictly only need runtime artefacts and nothing for supporting building against the installed contents. The workaround of having to explicitly give the DESTINATION
to get this behavior shouldn't be necessary, we should still be able to rely on the default install destination.