From 005e32d9318fa7bbeca501ae09c116ef5246d91a Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 28 Sep 2025 12:49:37 +0200 Subject: [PATCH] Avoid installing libraries multiple times or issueing wrong message Some libraries call `boost_install` themselves which adds `INSTALL_INTERFACE` to their `INTERFACE_INCLUDE_DIRETORIES` property. That then makes the install check in `__boost_auto_install` fail and print a message that the library won't be installed while it will be. Use a label to detect targets for which `boost_install` was already called and skip the logic in `__boost_auto_install` for those. --- include/BoostInstall.cmake | 4 ++++ include/BoostRoot.cmake | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/include/BoostInstall.cmake b/include/BoostInstall.cmake index 1127c6f..f918c04 100644 --- a/include/BoostInstall.cmake +++ b/include/BoostInstall.cmake @@ -320,6 +320,10 @@ function(boost_install_target) install(EXPORT ${LIB}-targets DESTINATION "${CONFIG_INSTALL_DIR}" NAMESPACE Boost:: FILE ${LIB}-targets.cmake) + get_target_property(labels ${LIB} LABELS) + list(APPEND labels boost_install_specified) + set_target_properties(${LIB} PROPERTIES LABELS "${labels}") + set(CONFIG_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/tmpinst/${LIB}-config.cmake") set(CONFIG_FILE_CONTENTS "# Generated by BoostInstall.cmake for ${LIB}-${__VERSION}\n\n") diff --git a/include/BoostRoot.cmake b/include/BoostRoot.cmake index bd7f8be..d0d48ba 100644 --- a/include/BoostRoot.cmake +++ b/include/BoostRoot.cmake @@ -182,6 +182,11 @@ function(__boost_auto_install __boost_lib) if(TARGET "Boost::${__boost_lib_target}" AND TARGET "boost_${__boost_lib_target}") + get_target_property(labels "boost_${__boost_lib_target}" LABELS) + if("boost_install_specified" IN_LIST labels) + return() # Ignore libraries for which boost_install was already called + endif() + get_target_property(__boost_lib_incdir "boost_${__boost_lib_target}" INTERFACE_INCLUDE_DIRECTORIES) set(incdir "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/${__boost_lib}/include")