Feature/offers a portable implementation version with import std support#53
Feature/offers a portable implementation version with import std support#53ClausKlein wants to merge 23 commits intobemanproject:mainfrom
Conversation
and portable C++ feature checks
This compiles with clang++-21 on OSX and should build on Windows too.
Add more test for unique_resource
scope_exit does not need to be move-assignable!
add get_version() to CXX_MODULE to export some code;
350bcd8 to
1a86a99
Compare
This is needed if only an interface library is build
79cd72c to
f51bfa4
Compare
Prevent warning: placeholder variables are a C++2c extension
26120f1 to
7af734d
Compare
|
|
||
| include(GenerateExportHeader) | ||
|
|
||
| generate_export_header( | ||
| beman.scope | ||
| BASE_NAME beman.scope | ||
| EXPORT_FILE_NAME beman/scope/modules_export.hpp | ||
| ) | ||
| else() | ||
| add_library(beman.scope INTERFACE) | ||
| endif() | ||
|
|
||
| if(CMAKE_CXX_SCAN_FOR_MODULES) |
There was a problem hiding this comment.
@JeffGarland For windows DLL do we need an export header too?
There was a problem hiding this comment.
The implementation isn't currently supported on msvc. However when it is there would only be a dll for modules I guess
86c2cfa to
c0e2002
Compare
Quickfix: do not use the old implementation Autoupdate pre-commit hooks
6475182 to
3d810f1
Compare
| #ifdef BEMAN_SCOPE_USE_DANIELA_ADVICE | ||
| #define BEMAN_SCOPE_MODULE_EXPORT export | ||
| #define BEMAN_SCOPE_MODULE_BEGIN_EXPORT export { | ||
| #define BEMAN_SCOPE_MODULE_END_EXPORT } | ||
|
|
||
| // If you define BEMAN_SCOPE_ATTACH_TO_GLOBAL_MODULE | ||
| // - all declarations are detached from module 'beman.scope' | ||
| // - the module behaves like a traditional static library, too | ||
| // - all library symbols are mangled traditionally | ||
| // - you can mix TUs with either importing or #including the {beman.scope} API | ||
| #ifdef BEMAN_SCOPE_ATTACH_TO_GLOBAL_MODULE | ||
| extern "C++" { | ||
| #endif | ||
|
|
||
| // NOTE: this export all implementation details too! CK | ||
| export { | ||
|
|
||
| // FIXME: warning: '#include <filename>' attaches the declarations to the named | ||
| // module 'beman.scope', which is not usually intended; consider moving that | ||
| // directive before the module declaration [-Winclude-angled-in-module-purview] | ||
|
|
||
| #include <beman/scope/scope_impl.hpp> | ||
|
|
||
| } // end of export | ||
|
|
||
| #ifdef BEMAN_SCOPE_ATTACH_TO_GLOBAL_MODULE | ||
| } | ||
| #endif | ||
|
|
||
| #else | ||
| // ========================================================== | ||
| // Note: not needed because of using `module attachment`! | ||
| // ========================================================== | ||
|
|
There was a problem hiding this comment.
This works at least without import std;
| #ifdef BEMAN_SCOPE_USE_FALLBACK | ||
| #if __has_include("beman/scope/modules_export.hpp") | ||
| #include "beman/scope/modules_export.hpp" | ||
| #else | ||
| #define BEMAN_SCOPE_EXPORT | ||
| #endif | ||
|
|
||
| #include <exception> | ||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
||
| namespace beman::scope { |
There was a problem hiding this comment.
NOTE: this works with verify_interface_headers too;
BUT only if we have two explicit targets: one lib with cxx_module and one interface (header only lib)
CMAKE_EXPERIMENTAL_CXX_IMPORT_STD is still needed Build and install always a header only lib Fix some clang-tidy warnings pre-commit autoupdate
743105f to
4a35cc4
Compare
| list(APPEND ALL_EXAMPLES scope-module) | ||
| include(../cmake/prelude.cmake) | ||
|
|
||
| project(beman.scope.example LANGUAGES CXX) |
There was a problem hiding this comment.
are we doing this in exemplar now, because I don't think we are
| // scope exit: true success: true fail: false | ||
|
|
||
| // #ifdef HAS_MODULE_STD | ||
| // NOTE: not included in gcc-15 libstdc++ std module? CK |
There was a problem hiding this comment.
I think to get cassert you need std.compat
| #if __cplusplus < 202002L | ||
| #include <version> | ||
|
|
||
| #if defined(__cpp_concepts) && __cpp_concepts >= 201907L |
There was a problem hiding this comment.
does this work on msvc? maybe it's only the c++ version that doesnt?
This offers a portable implementation version that compiles on all OS with all C++23 compilers
import std;tooTODO:
DLLno lib foundgccon OSXclangDebug on CINOTE: This version compiles on OSX with apple-clang, llvm-clang, and g++-15 too!
Following Issues will be fixed:
unique_resource#28I have been prepared export headers to test with DLL's on Windows too.
see https://discourse.cmake.org/t/linker-error-with-cxx-modules/15449