mirror of
https://github.com/boostorg/any.git
synced 2026-07-21 13:03:30 +00:00
Fix import std detection in CMake and CMake fixes for tests (#37)
Fixes: https://github.com/boostorg/any/issues/34 Closes: https://github.com/boostorg/any/pull/35
This commit is contained in:
@@ -85,7 +85,7 @@ jobs:
|
||||
cd ..
|
||||
rm -rf __build
|
||||
|
||||
- name: Run modules tests wihtout 'import std;'
|
||||
- name: Run modules tests without 'import std;'
|
||||
if: ${{matrix.toolset == 'clang-19'}}
|
||||
run: |
|
||||
cd ../boost-root/libs/any
|
||||
@@ -218,7 +218,7 @@ jobs:
|
||||
cd ..
|
||||
rm -rf build_module
|
||||
|
||||
- name: Run modules tests wihtout 'import std;'
|
||||
- name: Run modules tests without 'import std;'
|
||||
if: ${{matrix.toolset == 'msvc-14.3'}}
|
||||
shell: cmd
|
||||
run: |
|
||||
|
||||
+9
-4
@@ -2,19 +2,24 @@
|
||||
# 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.5...3.31 )
|
||||
cmake_minimum_required( VERSION 3.8...3.31 )
|
||||
project( boost_any VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX )
|
||||
|
||||
if (BOOST_USE_MODULES)
|
||||
add_library(boost_any)
|
||||
target_sources(boost_any PUBLIC
|
||||
FILE_SET modules_public TYPE CXX_MODULES FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/modules/boost_any.cppm
|
||||
FILE_SET modules_public
|
||||
TYPE CXX_MODULES
|
||||
FILES modules/boost_any.cppm
|
||||
)
|
||||
|
||||
target_compile_features(boost_any PUBLIC cxx_std_20)
|
||||
target_compile_definitions(boost_any PUBLIC BOOST_USE_MODULES)
|
||||
if (CMAKE_CXX_COMPILER_IMPORT_STD)
|
||||
set(__boost_cxx_standard ${CMAKE_CXX_STANDARD})
|
||||
if (NOT __boost_cxx_standard)
|
||||
set(__boost_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)
|
||||
message(STATUS "Using `import std;`")
|
||||
else()
|
||||
|
||||
@@ -15,7 +15,6 @@ add_subdirectory(../../../detail boostorg/detail)
|
||||
add_subdirectory(../../../integer boostorg/integer)
|
||||
add_subdirectory(../../../mp11 boostorg/mp11)
|
||||
add_subdirectory(../../../preprocessor boostorg/preprocessor)
|
||||
add_subdirectory(../../../static_assert boostorg/static_assert)
|
||||
add_subdirectory(../../../throw_exception boostorg/throw_exception)
|
||||
add_subdirectory(../../../type_index boostorg/type_index)
|
||||
add_subdirectory(../../../type_traits boostorg/type_traits)
|
||||
@@ -25,7 +24,7 @@ add_subdirectory(../../ boostorg/any)
|
||||
enable_testing()
|
||||
|
||||
if (BOOST_USE_MODULES)
|
||||
add_executable(boost_any_module_usage ../modules/usage_sample.cpp)
|
||||
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)
|
||||
endif()
|
||||
@@ -50,7 +49,7 @@ list(APPEND 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)
|
||||
target_link_libraries(${PROJECT_NAME}_${testname} Boost::any Boost::core)
|
||||
add_test(NAME ${PROJECT_NAME}_${testname} COMMAND ${PROJECT_NAME}_${testname})
|
||||
endforeach()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user