From 3eac0a78a2e7eae2d12799069e2d1e4eba595c0a Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Mon, 24 Aug 2026 19:49:52 +0200 Subject: [PATCH 1/2] Use BASE_DIRS to install modules right Merge the cmake logic and c++ version handling with other boost modules, i.e. type_index, lexical_cast, pfr, and, conversion --- CMakeLists.txt | 20 ++++++++++---------- modules/boost_any.cppm | 6 +++++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fd8717..15d4aaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,25 +2,25 @@ # Distributed under the Boost Software License, Version 1.0. # See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt -cmake_minimum_required( VERSION 3.8...3.31 ) +cmake_minimum_required(VERSION 3.8...4.4) project( boost_any VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX ) -if (BOOST_USE_MODULES) - add_library(boost_any) +if(BOOST_USE_MODULES) + add_library(boost_any STATIC) target_sources(boost_any PUBLIC - FILE_SET modules_public - TYPE CXX_MODULES + FILE_SET CXX_MODULES + BASE_DIRS modules FILES modules/boost_any.cppm ) target_compile_features(boost_any PUBLIC cxx_std_20) target_compile_definitions(boost_any PUBLIC BOOST_USE_MODULES) - set(__boost_cxx_standard ${CMAKE_CXX_STANDARD}) - if (NOT __boost_cxx_standard) - set(__boost_cxx_standard 20) + if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 20) endif() - if (CMAKE_CXX_COMPILER_IMPORT_STD AND ${__boost_cxx_standard} IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) - target_compile_definitions(boost_any PRIVATE BOOST_ANY_USE_STD_MODULE) + if(CMAKE_CXX_MODULE_STD AND CMAKE_CXX_STANDARD IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) + target_compile_definitions(boost_any PUBLIC BOOST_ANY_USE_STD_MODULE) + target_compile_features(boost_any PUBLIC cxx_std_23) message(STATUS "Using `import std;`") else() message(STATUS "`import std;` is not available") diff --git a/modules/boost_any.cppm b/modules/boost_any.cppm index de7430c..a86c4b5 100644 --- a/modules/boost_any.cppm +++ b/modules/boost_any.cppm @@ -11,7 +11,9 @@ module; #include #include #include -#include + +// Any-specific global module fragment includes. +// Do not include here! #ifdef BOOST_ANY_USE_STD_MODULE import std; @@ -27,6 +29,8 @@ import std; export module boost.any; +import boost.type_index; + #ifdef __clang__ # pragma clang diagnostic ignored "-Winclude-angled-in-module-purview" #endif From c3d2c0722bb86b8e4a397c8e6cae47f2a0dee90f Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Tue, 25 Aug 2026 20:50:38 +0200 Subject: [PATCH 2/2] Fix cmake_subdir_test --- test/cmake_subdir_test/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/cmake_subdir_test/CMakeLists.txt b/test/cmake_subdir_test/CMakeLists.txt index cae23df..952d92b 100644 --- a/test/cmake_subdir_test/CMakeLists.txt +++ b/test/cmake_subdir_test/CMakeLists.txt @@ -2,28 +2,31 @@ # Distributed under the Boost Software License, Version 1.0. # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt -cmake_minimum_required(VERSION 3.5...4.0) +cmake_minimum_required(VERSION 3.5...4.4) project(any_subdir_test LANGUAGES CXX) add_subdirectory(../../../assert boostorg/assert) -add_subdirectory(../../../core boostorg/core) add_subdirectory(../../../config boostorg/config) add_subdirectory(../../../container_hash boostorg/container_hash) +add_subdirectory(../../../core boostorg/core) add_subdirectory(../../../describe boostorg/describe) add_subdirectory(../../../detail boostorg/detail) add_subdirectory(../../../integer boostorg/integer) add_subdirectory(../../../mp11 boostorg/mp11) +add_subdirectory(../../../predef boostorg/predef) add_subdirectory(../../../preprocessor boostorg/preprocessor) +add_subdirectory(../../../smart_ptr boostorg/smart_ptr) add_subdirectory(../../../throw_exception boostorg/throw_exception) add_subdirectory(../../../type_index boostorg/type_index) add_subdirectory(../../../type_traits boostorg/type_traits) +add_subdirectory(../../../unordered boostorg/unordered) add_subdirectory(../../ boostorg/any) enable_testing() -if (BOOST_USE_MODULES) +if(BOOST_USE_MODULES) add_executable(boost_any_module_usage ../../modules/usage_sample.cpp) target_link_libraries(boost_any_module_usage PRIVATE Boost::any) add_test(NAME boost_any_module_usage COMMAND boost_any_module_usage) @@ -46,7 +49,7 @@ list(APPEND RUN_TESTS_SOURCES # any_test.cpp # Ambiguous with modules, because all the anys now available ) -foreach (testsourcefile ${RUN_TESTS_SOURCES}) +foreach(testsourcefile ${RUN_TESTS_SOURCES}) get_filename_component(testname ${testsourcefile} NAME_WLE) add_executable(${PROJECT_NAME}_${testname} ../${testsourcefile}) target_link_libraries(${PROJECT_NAME}_${testname} Boost::any Boost::core)