Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/BoostInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,20 @@ function(boost_install_target)
string(APPEND CONFIG_INSTALL_DIR "-static")
endif()

# C++20 modules supported since CMake 3.28
set(__BOOST_INSTALL_FILE_SET_ARGS)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
set(__BOOST_INSTALL_FILE_SET_ARGS FILE_SET CXX_MODULES DESTINATION "${CMAKE_INSTALL_DATADIR}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @anarthal ! I believe that it is also required to set CXX_MODULES_BMI DESTINATION "" to not install the BMI (because it is compiler/version specific and should be build from module interface unit and public headers)

as CMake documentation says

Any module files from C++ modules from PUBLIC sources in a file set of type CXX_MODULES will be installed to the given DESTINATION. All modules are placed directly in the destination as no directory structure is derived from the names of the modules. An empty DESTINATION may be used to suppress installing these files (for use in generic code).

I am not pretty sure whether BMI is installed with unset CXX_MODULES_BMI but explicit option specification seems more straightforward way

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CXX_MODULES_BMI can be omitted, it is as wrong designed install option! The installed BMI files are never used from CMake!

endif()

install(TARGETS ${LIB} EXPORT ${LIB}-targets
# explicit destination specification required for 3.13, 3.14 no longer needs it
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PRIVATE_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
Copy link
Copy Markdown

@fdr400 fdr400 May 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does install actually work without specifying PUBLIC FILE_SET HEADERS with all library headers explicitly listed their and adding FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} in install command?
I am not very experienced in modules installation but I guess that it is required for approach when module may be imported after library headers preprocessed. Probably, FILE_SET HEADERS with specified only BASE_DIRS
@ClausKlein I saw your PRs with attempts of Boost libraries CMake installation with modules support and FILE_SET HEADERS was specified their. Can you please clarify how it actually should be done

Also such installation approach won't work for both headers and modules users simultaneously if Boost library is not header-only. Because installed .a or .so library will contain symbols attached to the target module (with @<module_name> suffix), so headers users (who did not specified BOOST_USE_MODULES) can't link with modules-aware compiled library, and vice versa modules users can't link with non-modules-aware compiled library.
And I can not actually imagine how such libraries should be provided for, for instance, Ubuntu debian packages to be available for header-based and modules-based users. Possibly, only if two packages are provided for each, but such a way all headers are duplicated in them.
Maybe, for CMake install both module and non-module library should be compiled and installed somehow?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FILE_SET HEADERS are the modern way to build and install headers and should be used.

${__BOOST_INSTALL_FILE_SET_ARGS}
)

export(TARGETS ${LIB} NAMESPACE Boost:: FILE export/${LIB}-targets.cmake)
Expand Down
3 changes: 3 additions & 0 deletions include/BoostRoot.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ macro(__boost_add_header_only lib)

endmacro()

# C++20 modules
option(BOOST_USE_MODULES "Build Boost as a collection of C++20 modules (unstable)" OFF)

#

file(GLOB __boost_libraries RELATIVE "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs" "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/*/CMakeLists.txt" "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/numeric/*/CMakeLists.txt")
Expand Down
Loading