From 20d3cb1da748cea8826c0e1323bf5fa3895ebba5 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Mon, 24 Aug 2026 20:15:11 +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, type_index, pfr, and conversion --- CMakeLists.txt | 20 +++++++++++-------- .../lexical_cast/detail/lcast_precision.hpp | 5 +++-- .../detail/lcast_unsigned_converters.hpp | 3 ++- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33377c2..0455d94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,22 +3,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.0) +cmake_minimum_required(VERSION 3.5...4.4) project(boost_lexical_cast VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) - -if (BOOST_USE_MODULES) - add_library(boost_lexical_cast) +if(BOOST_USE_MODULES) + add_library(boost_lexical_cast STATIC) target_sources(boost_lexical_cast PUBLIC - FILE_SET modules_public TYPE CXX_MODULES FILES - ${CMAKE_CURRENT_LIST_DIR}/modules/boost_lexical_cast.cppm + FILE_SET CXX_MODULES + BASE_DIRS modules + FILES modules/boost_lexical_cast.cppm ) target_compile_features(boost_lexical_cast PUBLIC cxx_std_20) target_compile_definitions(boost_lexical_cast PUBLIC BOOST_USE_MODULES) - if (CMAKE_CXX_COMPILER_IMPORT_STD) - target_compile_definitions(boost_lexical_cast PRIVATE BOOST_LEXICAL_CAST_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_definitions(boost_lexical_cast PUBLIC BOOST_LEXICAL_CAST_USE_STD_MODULE) + target_compile_features(boost_lexical_cast PUBLIC cxx_std_23) message(STATUS "Using `import std;`") else() message(STATUS "`import std;` is not available") diff --git a/include/boost/lexical_cast/detail/lcast_precision.hpp b/include/boost/lexical_cast/detail/lcast_precision.hpp index 372deab..abbd5ba 100644 --- a/include/boost/lexical_cast/detail/lcast_precision.hpp +++ b/include/boost/lexical_cast/detail/lcast_precision.hpp @@ -10,6 +10,8 @@ #include +#include // ULONG_MAX + #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT) #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT @@ -18,9 +20,8 @@ # pragma once #endif -#include #include -#include +#include #endif // #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT diff --git a/include/boost/lexical_cast/detail/lcast_unsigned_converters.hpp b/include/boost/lexical_cast/detail/lcast_unsigned_converters.hpp index 4979002..5a3d381 100644 --- a/include/boost/lexical_cast/detail/lcast_unsigned_converters.hpp +++ b/include/boost/lexical_cast/detail/lcast_unsigned_converters.hpp @@ -20,6 +20,8 @@ #include +#include // CHAR_MAX + #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT) #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT @@ -28,7 +30,6 @@ # pragma once #endif -#include #include #include #include