`install(TARGETS)` does not install the `HEADERS` `FILE_SET` by default
The documentation page for the install(TARGETS ...)
command lists FILE_SET
(specifically HEADERS
) has a default install location, but currently the HEADERS
FILE_SET
is not installed.
This causes problems when exporting the target/project since cmake will error out with: install TARGETS target repro is exported but not all of its interface file sets are installed
(minimal repro at the end)
This makes it kinda manditory to specify all ARCHIVE
/RUNTIME
/... parts and locations (possibly even COMPONENT
) that should be installed instead of simply specifying which targets to install and cmake picking sane defaults.
cmake_minimum_required(VERSION 3.23)
project(repro)
add_library(${PROJECT_NAME} STATIC)
target_sources(${PROJECT_NAME} PRIVATE lib.cpp)
target_sources(${PROJECT_NAME} PUBLIC FILE_SET HEADERS FILES lib.hpp)
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Export)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
install(
EXPORT ${PROJECT_NAME}Export
DESTINATION lib/cmake/${PROJECT_NAME}
NAMESPACE ${PROJECT_NAME}::
)