Skip to content

Commit 5865161

Browse files
authored
Fix import std detection in CMake and CMake fixes for tests (#37)
Fixes: #34 Closes: #35
1 parent b6024cf commit 5865161

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
cd ..
8686
rm -rf __build
8787
88-
- name: Run modules tests wihtout 'import std;'
88+
- name: Run modules tests without 'import std;'
8989
if: ${{matrix.toolset == 'clang-19'}}
9090
run: |
9191
cd ../boost-root/libs/any
@@ -218,7 +218,7 @@ jobs:
218218
cd ..
219219
rm -rf build_module
220220
221-
- name: Run modules tests wihtout 'import std;'
221+
- name: Run modules tests without 'import std;'
222222
if: ${{matrix.toolset == 'msvc-14.3'}}
223223
shell: cmd
224224
run: |

CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22
# Distributed under the Boost Software License, Version 1.0.
33
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
44

5-
cmake_minimum_required( VERSION 3.5...3.31 )
5+
cmake_minimum_required( VERSION 3.8...3.31 )
66
project( boost_any VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX )
77

88
if (BOOST_USE_MODULES)
99
add_library(boost_any)
1010
target_sources(boost_any PUBLIC
11-
FILE_SET modules_public TYPE CXX_MODULES FILES
12-
${CMAKE_CURRENT_LIST_DIR}/modules/boost_any.cppm
11+
FILE_SET modules_public
12+
TYPE CXX_MODULES
13+
FILES modules/boost_any.cppm
1314
)
1415

1516
target_compile_features(boost_any PUBLIC cxx_std_20)
1617
target_compile_definitions(boost_any PUBLIC BOOST_USE_MODULES)
17-
if (CMAKE_CXX_COMPILER_IMPORT_STD)
18+
set(__boost_cxx_standard ${CMAKE_CXX_STANDARD})
19+
if (NOT __boost_cxx_standard)
20+
set(__boost_cxx_standard 20)
21+
endif()
22+
if (CMAKE_CXX_COMPILER_IMPORT_STD AND ${__boost_cxx_standard} IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD)
1823
target_compile_definitions(boost_any PRIVATE BOOST_ANY_USE_STD_MODULE)
1924
message(STATUS "Using `import std;`")
2025
else()

test/cmake_subdir_test/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ add_subdirectory(../../../detail boostorg/detail)
1515
add_subdirectory(../../../integer boostorg/integer)
1616
add_subdirectory(../../../mp11 boostorg/mp11)
1717
add_subdirectory(../../../preprocessor boostorg/preprocessor)
18-
add_subdirectory(../../../static_assert boostorg/static_assert)
1918
add_subdirectory(../../../throw_exception boostorg/throw_exception)
2019
add_subdirectory(../../../type_index boostorg/type_index)
2120
add_subdirectory(../../../type_traits boostorg/type_traits)
@@ -25,7 +24,7 @@ add_subdirectory(../../ boostorg/any)
2524
enable_testing()
2625

2726
if (BOOST_USE_MODULES)
28-
add_executable(boost_any_module_usage ../modules/usage_sample.cpp)
27+
add_executable(boost_any_module_usage ../../modules/usage_sample.cpp)
2928
target_link_libraries(boost_any_module_usage PRIVATE Boost::any)
3029
add_test(NAME boost_any_module_usage COMMAND boost_any_module_usage)
3130
endif()
@@ -50,7 +49,7 @@ list(APPEND RUN_TESTS_SOURCES
5049
foreach (testsourcefile ${RUN_TESTS_SOURCES})
5150
get_filename_component(testname ${testsourcefile} NAME_WLE)
5251
add_executable(${PROJECT_NAME}_${testname} ../${testsourcefile})
53-
target_link_libraries(${PROJECT_NAME}_${testname} Boost::any)
52+
target_link_libraries(${PROJECT_NAME}_${testname} Boost::any Boost::core)
5453
add_test(NAME ${PROJECT_NAME}_${testname} COMMAND ${PROJECT_NAME}_${testname})
5554
endforeach()
5655

0 commit comments

Comments
 (0)