From f1d1d6f0ce05922552d860d849b716324aeb11ed Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Mon, 24 Aug 2026 19:37:56 +0200 Subject: [PATCH] Use BASE_DIRS to install modules right Merge the cmake logic and c++ version handling with other boost modules, i.e. any, lexical_cast, pfr, and, conversion --- CMakeLists.txt | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2275d3b..8cac31e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,24 +4,26 @@ # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt -cmake_minimum_required(VERSION 3.5...4.20) +cmake_minimum_required(VERSION 3.5...4.4) project(boost_type_index VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) -if (BOOST_USE_MODULES) - add_library(boost_type_index) - target_sources(boost_type_index - PUBLIC +if(BOOST_USE_MODULES) + add_library(boost_type_index STATIC) + target_sources(boost_type_index PUBLIC FILE_SET CXX_MODULES - BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" - FILES "${CMAKE_CURRENT_SOURCE_DIR}/modules/boost_type_index.cppm" + BASE_DIRS modules + FILES "modules/boost_type_index.cppm" ) target_compile_features(boost_type_index PUBLIC cxx_std_20) target_compile_definitions(boost_type_index PUBLIC BOOST_USE_MODULES) - if ((CMAKE_CXX_STANDARD IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) AND CMAKE_CXX_MODULE_STD) - target_compile_features(boost_type_index PRIVATE cxx_std_23) - target_compile_definitions(boost_type_index PRIVATE BOOST_TYPE_INDEX_USE_STD_MODULE) + if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 20) + endif() + if(CMAKE_CXX_MODULE_STD AND CMAKE_CXX_STANDARD IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) + target_compile_features(boost_type_index PUBLIC cxx_std_23) + target_compile_definitions(boost_type_index PUBLIC BOOST_TYPE_INDEX_USE_STD_MODULE) message(STATUS "Using `import std;`") else() message(STATUS "`import std;` is not available")