diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e512106..c3159610 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -105,6 +105,25 @@ jobs: ./b2 -d0 headers ./b2 -j4 variant=debug tools/inspect + - name: Run modules tests + if: ${{matrix.toolset == 'clang-19'}} + run: | + cd ../boost-root/libs/$LIBRARY + cmake -S test/cmake_subdir_test -B __build \ + -GNinja \ + -DBUILD_TESTING=1 \ + -DBOOST_DLL_USE_STD_FS=1 \ + -DBOOST_USE_MODULES=1 \ + -DCMAKE_CXX_COMPILER=${{matrix.compiler}} \ + -DCMAKE_CXX_FLAGS="-stdlib=libc++" \ + -DCMAKE_CXX_STANDARD=23 \ + -DCMAKE_CXX_MODULE_STD=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 + + cmake --build __build + ctest --test-dir __build --output-on-failure --no-tests=error -VV + rm -rf __build + - name: Run modules tests without 'import std;' if: ${{matrix.toolset == 'clang-19'}} run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 0540476f..e886f23d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,18 @@ target_link_libraries(boost_dll_boost_fs if (BOOST_USE_MODULES) add_library(boost_dll) target_compile_definitions(boost_dll PUBLIC BOOST_USE_MODULES) - target_compile_features(boost_dll PUBLIC cxx_std_20) + + get_property(__standard TARGET boost_dll PROPERTY CXX_STANDARD) + if (__standard IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD AND CMAKE_CXX_MODULE_STD) + target_compile_features(boost_dll PUBLIC cxx_std_23) + target_compile_definitions(boost_dll PRIVATE BOOST_DLL_USE_STD_MODULE) + message(STATUS "Using `import std;`") + else() + target_compile_features(boost_dll PUBLIC cxx_std_20) + message(STATUS "`import std;` is not available") + endif() + unset(__standard) + target_sources(boost_dll PUBLIC FILE_SET CXX_MODULES diff --git a/include/boost/dll/config.hpp b/include/boost/dll/config.hpp index a55a464f..67c97d9a 100644 --- a/include/boost/dll/config.hpp +++ b/include/boost/dll/config.hpp @@ -47,8 +47,10 @@ using system_error = std::conditional_t #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) namespace boost { namespace dll { namespace fs { @@ -94,7 +96,9 @@ namespace boost { namespace dll { namespace detail { #else // BOOST_DLL_USE_STD_FS #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) namespace boost { namespace dll { namespace detail { diff --git a/include/boost/dll/detail/aggressive_ptr_cast.hpp b/include/boost/dll/detail/aggressive_ptr_cast.hpp index e50cc8da..a53e5669 100644 --- a/include/boost/dll/detail/aggressive_ptr_cast.hpp +++ b/include/boost/dll/detail/aggressive_ptr_cast.hpp @@ -14,9 +14,11 @@ #endif #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include // std::memcpy #include #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #if defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 301) diff --git a/include/boost/dll/detail/demangling/demangle_symbol.hpp b/include/boost/dll/detail/demangling/demangle_symbol.hpp index 5a1599af..c29cbb63 100644 --- a/include/boost/dll/detail/demangling/demangle_symbol.hpp +++ b/include/boost/dll/detail/demangling/demangle_symbol.hpp @@ -11,9 +11,11 @@ #include #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #if defined(_MSC_VER) // MSVC, Clang-cl, and ICC on Windows diff --git a/include/boost/dll/detail/demangling/itanium.hpp b/include/boost/dll/detail/demangling/itanium.hpp index b08ed38d..de20fc07 100644 --- a/include/boost/dll/detail/demangling/itanium.hpp +++ b/include/boost/dll/detail/demangling/itanium.hpp @@ -8,9 +8,11 @@ #define BOOST_DLL_DETAIL_DEMANGLING_ITANIUM_HPP_ #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #include diff --git a/include/boost/dll/detail/demangling/mangled_storage_base.hpp b/include/boost/dll/detail/demangling/mangled_storage_base.hpp index b072a9b2..38a59319 100644 --- a/include/boost/dll/detail/demangling/mangled_storage_base.hpp +++ b/include/boost/dll/detail/demangling/mangled_storage_base.hpp @@ -10,10 +10,12 @@ #if !defined(BOOST_DLL_INTERFACE_UNIT) #include +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include #include #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #include diff --git a/include/boost/dll/detail/demangling/msvc.hpp b/include/boost/dll/detail/demangling/msvc.hpp index 47740a12..1530f210 100644 --- a/include/boost/dll/detail/demangling/msvc.hpp +++ b/include/boost/dll/detail/demangling/msvc.hpp @@ -10,9 +10,11 @@ #if !defined(BOOST_DLL_INTERFACE_UNIT) #include +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #include diff --git a/include/boost/dll/detail/elf_info.hpp b/include/boost/dll/detail/elf_info.hpp index 363ce55b..beedf0fe 100644 --- a/include/boost/dll/detail/elf_info.hpp +++ b/include/boost/dll/detail/elf_info.hpp @@ -17,10 +17,12 @@ #if !defined(BOOST_DLL_INTERFACE_UNIT) #include +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include #include #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) namespace boost { namespace dll { namespace detail { diff --git a/include/boost/dll/detail/import_mangled_helpers.hpp b/include/boost/dll/detail/import_mangled_helpers.hpp index b7f7353e..33fc6489 100644 --- a/include/boost/dll/detail/import_mangled_helpers.hpp +++ b/include/boost/dll/detail/import_mangled_helpers.hpp @@ -13,7 +13,9 @@ #endif #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) namespace boost { namespace dll { namespace experimental { namespace detail { diff --git a/include/boost/dll/detail/macho_info.hpp b/include/boost/dll/detail/macho_info.hpp index bb9bd715..da6015cf 100644 --- a/include/boost/dll/detail/macho_info.hpp +++ b/include/boost/dll/detail/macho_info.hpp @@ -15,11 +15,13 @@ #endif #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include #include #include // for std::getline #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) namespace boost { namespace dll { namespace detail { diff --git a/include/boost/dll/detail/pe_info.hpp b/include/boost/dll/detail/pe_info.hpp index acbb9c08..8bfcaec2 100644 --- a/include/boost/dll/detail/pe_info.hpp +++ b/include/boost/dll/detail/pe_info.hpp @@ -15,11 +15,13 @@ #endif #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include #include #include // for std::getline #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) namespace boost { namespace dll { namespace detail { diff --git a/include/boost/dll/detail/posix/path_from_handle.hpp b/include/boost/dll/detail/posix/path_from_handle.hpp index cce67c69..372afce1 100644 --- a/include/boost/dll/detail/posix/path_from_handle.hpp +++ b/include/boost/dll/detail/posix/path_from_handle.hpp @@ -26,7 +26,9 @@ #if !defined(BOOST_DLL_INTERFACE_UNIT) # include # include +#if !defined(BOOST_DLL_USE_STD_MODULE) # include // for std::ptrdiff_t +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) namespace boost { namespace dll { namespace detail { diff --git a/include/boost/dll/detail/posix/program_location_impl.hpp b/include/boost/dll/detail/posix/program_location_impl.hpp index b0034524..0075632a 100644 --- a/include/boost/dll/detail/posix/program_location_impl.hpp +++ b/include/boost/dll/detail/posix/program_location_impl.hpp @@ -23,7 +23,9 @@ #if BOOST_OS_MACOS || BOOST_OS_IOS #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #include #endif // !defined(BOOST_DLL_INTERFACE_UNIT) @@ -51,7 +53,9 @@ namespace boost { namespace dll { namespace detail { #elif BOOST_OS_SOLARIS #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) namespace boost { namespace dll { namespace detail { @@ -65,10 +69,12 @@ namespace boost { namespace dll { namespace detail { #elif BOOST_OS_BSD_FREE #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include +#include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #include #include -#include #endif // !defined(BOOST_DLL_INTERFACE_UNIT) namespace boost { namespace dll { namespace detail { @@ -133,8 +139,10 @@ namespace boost { namespace dll { namespace detail { #elif BOOST_OS_QNX #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include // for std::getline +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) namespace boost { namespace dll { namespace detail { diff --git a/include/boost/dll/detail/posix/shared_library_impl.hpp b/include/boost/dll/detail/posix/shared_library_impl.hpp index e7e5568e..07311396 100644 --- a/include/boost/dll/detail/posix/shared_library_impl.hpp +++ b/include/boost/dll/detail/posix/shared_library_impl.hpp @@ -18,10 +18,12 @@ #include #include +#if !defined(BOOST_DLL_USE_STD_MODULE) #include // std::move +#include // strncmp +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #include -#include // strncmp #if !BOOST_OS_MACOS && !BOOST_OS_IOS && !BOOST_OS_QNX && !BOOST_OS_CYGWIN # include #elif BOOST_OS_QNX diff --git a/include/boost/dll/detail/system_error.hpp b/include/boost/dll/detail/system_error.hpp index ba7418d5..db81d79d 100644 --- a/include/boost/dll/detail/system_error.hpp +++ b/include/boost/dll/detail/system_error.hpp @@ -26,7 +26,9 @@ # include #endif +#if !defined(BOOST_DLL_USE_STD_MODULE) #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) diff --git a/include/boost/dll/detail/type_info.hpp b/include/boost/dll/detail/type_info.hpp index 4754294e..c7d77764 100644 --- a/include/boost/dll/detail/type_info.hpp +++ b/include/boost/dll/detail/type_info.hpp @@ -16,8 +16,10 @@ # include # endif +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) namespace boost { namespace dll { namespace detail { diff --git a/include/boost/dll/detail/windows/shared_library_impl.hpp b/include/boost/dll/detail/windows/shared_library_impl.hpp index a9ee2ab3..34247fc2 100644 --- a/include/boost/dll/detail/windows/shared_library_impl.hpp +++ b/include/boost/dll/detail/windows/shared_library_impl.hpp @@ -10,16 +10,19 @@ #include -#ifdef BOOST_HAS_PRAGMA_ONCE -# pragma once -#endif +#include +#include +#include +#include #if !defined(BOOST_DLL_INTERFACE_UNIT) #include #include +#if !defined(BOOST_DLL_USE_STD_MODULE) #include // std::move +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #include diff --git a/include/boost/dll/import.hpp b/include/boost/dll/import.hpp index b98dfcce..110e6b40 100644 --- a/include/boost/dll/import.hpp +++ b/include/boost/dll/import.hpp @@ -22,8 +22,10 @@ #endif #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include // std::addressof #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #include diff --git a/include/boost/dll/import_class.hpp b/include/boost/dll/import_class.hpp index 09fbf835..4aee7e0d 100644 --- a/include/boost/dll/import_class.hpp +++ b/include/boost/dll/import_class.hpp @@ -23,8 +23,10 @@ #endif #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include // std::move +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #include diff --git a/include/boost/dll/import_mangled.hpp b/include/boost/dll/import_mangled.hpp index 1607a99e..e9939ab6 100644 --- a/include/boost/dll/import_mangled.hpp +++ b/include/boost/dll/import_mangled.hpp @@ -28,11 +28,12 @@ #endif #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include // std::addressof #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) -#include #include #include diff --git a/include/boost/dll/library_info.hpp b/include/boost/dll/library_info.hpp index 352fe8ed..423e0888 100644 --- a/include/boost/dll/library_info.hpp +++ b/include/boost/dll/library_info.hpp @@ -29,8 +29,10 @@ #include #include +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #include diff --git a/include/boost/dll/runtime_symbol_info.hpp b/include/boost/dll/runtime_symbol_info.hpp index 74e17947..c19db0f9 100644 --- a/include/boost/dll/runtime_symbol_info.hpp +++ b/include/boost/dll/runtime_symbol_info.hpp @@ -25,7 +25,9 @@ #include #include +#if !defined(BOOST_DLL_USE_STD_MODULE) #include // std::addressof +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #if BOOST_OS_WINDOWS diff --git a/include/boost/dll/shared_library.hpp b/include/boost/dll/shared_library.hpp index 3e037f7a..7f78f4a8 100644 --- a/include/boost/dll/shared_library.hpp +++ b/include/boost/dll/shared_library.hpp @@ -27,8 +27,10 @@ #include #include +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include // std::move +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #include diff --git a/include/boost/dll/smart_library.hpp b/include/boost/dll/smart_library.hpp index 0e047bee..2ad121f1 100644 --- a/include/boost/dll/smart_library.hpp +++ b/include/boost/dll/smart_library.hpp @@ -25,8 +25,10 @@ #include #if !defined(BOOST_DLL_INTERFACE_UNIT) +#if !defined(BOOST_DLL_USE_STD_MODULE) #include #include // std::move +#endif // !defined(BOOST_DLL_USE_STD_MODULE) #endif // !defined(BOOST_DLL_INTERFACE_UNIT) #if (__cplusplus < 201103L) && (!defined(_MSVC_LANG) || _MSVC_LANG < 201103L) diff --git a/modules/boost_dll.cppm b/modules/boost_dll.cppm index d77d022b..4456fe77 100644 --- a/modules/boost_dll.cppm +++ b/modules/boost_dll.cppm @@ -16,8 +16,10 @@ module; #include #ifdef BOOST_DLL_USE_STD_FS +# ifndef BOOST_DLL_USE_STD_MODULE # include # include +# endif #else # include # include @@ -30,12 +32,14 @@ module; # include #endif +#ifndef BOOST_DLL_USE_STD_MODULE #include #include #include #include #include #include +#endif #ifndef _MSC_VER #include @@ -45,6 +49,10 @@ module; export module boost.dll; +#ifdef BOOST_DLL_USE_STD_MODULE +import std; +#endif + #ifdef __clang__ # pragma clang diagnostic ignored "-Winclude-angled-in-module-purview" #endif diff --git a/modules/sample_plugin.cppm b/modules/sample_plugin.cppm index 78073a33..95507bf6 100644 --- a/modules/sample_plugin.cppm +++ b/modules/sample_plugin.cppm @@ -7,6 +7,8 @@ module; +#include + #include export module sample_plugin;