Skip to content
Open
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
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 5 additions & 1 deletion modules/boost_any.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ module;
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>
#include <boost/type_index.hpp>

// Any-specific global module fragment includes.
// Do not include <boost/type_index.hpp> here!

#ifdef BOOST_ANY_USE_STD_MODULE
import std;
Expand All @@ -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
Expand Down
11 changes: 7 additions & 4 deletions test/cmake_subdir_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down