diff --git a/docs/src/content/docs/reference/cmake.mdx b/docs/src/content/docs/reference/cmake.mdx index cab9e5d6..1d71de15 100644 --- a/docs/src/content/docs/reference/cmake.mdx +++ b/docs/src/content/docs/reference/cmake.mdx @@ -217,8 +217,9 @@ The package does not export the example programs. `FairMQ::FairMQ` gives these usage requirements to the targets that link to it: - C++17 (`cxx_std_17`). -- The include directories `include/fairmq` and `include` of the prefix. Thus `#include ` and the deprecated `#include ` both work. See [Move from the FairMQ* names](/guides/migrate-names/). +- The include directories `include` and `include/fairmq` of the prefix. Thus `#include ` and the deprecated `#include ` both work. See [Move from the FairMQ* names](/guides/migrate-names/). - The [compile definitions](#compile-definitions). +- The public headers in the header file set `HEADERS` of the target. IDEs and tools that read file sets can list them. - The libraries `Threads::Threads`, `dl`, `rt` (Linux only), `Boost::headers`, `Boost::container`, `Boost::program_options`, `Boost::filesystem`, `Boost::regex` and `FairLogger::FairLogger`. :::caution[Find the dependencies before you link] diff --git a/fairmq/CMakeLists.txt b/fairmq/CMakeLists.txt index 40cb91bc..1817fea2 100644 --- a/fairmq/CMakeLists.txt +++ b/fairmq/CMakeLists.txt @@ -19,9 +19,6 @@ if(BUILD_FAIRMQ) ${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}/Version.h @ONLY ) - install(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}/Version.h - DESTINATION ${PROJECT_INSTALL_INCDIR} - ) ########################## # libFairMQ header files # @@ -155,9 +152,19 @@ if(BUILD_FAIRMQ) set(target FairMQ) add_library(${target} ${FAIRMQ_SOURCE_FILES} - ${FAIRMQ_PUBLIC_HEADER_FILES} # for IDE integration ${FAIRMQ_PRIVATE_HEADER_FILES} # for IDE integration ) + # The file set installs the public headers with their relative paths and + # adds the base directories to the include directories. + target_sources(${target} + PUBLIC FILE_SET HEADERS + BASE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR} + ${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER} + FILES + ${FAIRMQ_PUBLIC_HEADER_FILES} + ${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWER}/Version.h + ) add_library(${PROJECT_NAME}::${target} ALIAS ${target}) target_compile_features(${target} PUBLIC cxx_std_17) set_target_properties(${target} PROPERTIES LABELS coverage) @@ -195,10 +202,8 @@ if(BUILD_FAIRMQ) ####################### target_include_directories(${target} PUBLIC # consumers inherit public include directories - $ $ $ - $ $ ) @@ -324,14 +329,6 @@ if(BUILD_FAIRMQ) RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR} LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR} ARCHIVE DESTINATION ${PROJECT_INSTALL_LIBDIR} + FILE_SET HEADERS DESTINATION ${PROJECT_INSTALL_INCDIR} ) - - # preserve relative path and prepend fairmq - foreach(HEADER ${FAIRMQ_PUBLIC_HEADER_FILES}) - get_filename_component(_path ${HEADER} DIRECTORY) - file(TO_CMAKE_PATH ${PROJECT_INSTALL_INCDIR}/${_path} _destination) - install(FILES ${HEADER} - DESTINATION ${_destination} - ) - endforeach() endif()