From 02b75dda78c86606021db330ca8e6e878e2f7a3d Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sat, 5 Oct 2024 16:52:16 +0200 Subject: [PATCH] Add headers to generated CMake targets For header-only libraries this adds a target to IDEs containing the headers (CMake 3.19+) For compiled libraries it includes the headers in the existing target --- src/boostdep.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/boostdep.cpp b/src/boostdep.cpp index 1136384..4a84e04 100644 --- a/src/boostdep.cpp +++ b/src/boostdep.cpp @@ -2734,6 +2734,10 @@ static void output_module_cmake_report( std::string module ) "add_library(Boost::" << lm << " ALIAS boost_" << lm << ")\n" "\n" "target_include_directories(boost_" << lm << " INTERFACE include)\n" + "if(NOT CMAKE_VERSION VERSION_LESS \"3.19\")\n" + " file(GLOB_RECURSE headers include/*.hpp)\n" + " target_sources(boost_optional PRIVATE ${headers})\n" + "endif()\n" "\n" ; @@ -2770,6 +2774,9 @@ static void output_module_cmake_report( std::string module ) { // compiled library + std::cout << + + "file(GLOB_RECURSE headers include/*.hpp)\n"; std::cout << "add_library(boost_" << lm << "\n"; @@ -2781,6 +2788,7 @@ static void output_module_cmake_report( std::string module ) std::cout << + " ${headers}\n" ")\n" "\n" "add_library(Boost::" << lm << " ALIAS boost_" << lm << ")\n"