-
Notifications
You must be signed in to change notification settings - Fork 31
Prepare CXX_MODULE usage #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ClausKlein
wants to merge
17
commits into
bemanproject:main
Choose a base branch
from
ClausKlein:feature/add_cxx_module
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add module usage example too Create a self contained CXX_MODULE Fix modules install path
Author
|
@ednolan Please help, I can't fix some of the CI problems caused by I disabled on |
Author
to "Check if import std; is possible"
ClausKlein
commented
Jan 21, 2026
Author
|
How it works internally: /Users/clausklein/Workspace/cpp/beman-project/exemplar/build/gcc-release
bash-5.3$ tree stagedir/
stagedir/
├── bin
│ ├── beman.exemplar.examples.identity_as_default_projection
│ ├── beman.exemplar.examples.identity_direct_usage
│ ├── beman.exemplar.examples.identity_module_usage
│ └── beman.exemplar.tests.identity
├── include
│ └── beman
│ └── exemplar
│ └── identity.hpp
└── lib
├── cmake
│ └── beman.exemplar
│ ├── beman.exemplar-config-version.cmake
│ ├── beman.exemplar-config.cmake
│ ├── beman.exemplar-targets-relwithdebinfo.cmake
│ ├── beman.exemplar-targets.cmake
│ ├── cxx-modules
│ │ ├── cxx-modules-beman.exemplar-RelWithDebInfo.cmake
│ │ ├── cxx-modules-beman.exemplar.cmake
│ │ └── target-exemplar-RelWithDebInfo.cmake
│ └── modules
│ └── identity.cppm
└── libbeman.exemplar.a
10 directories, 14 files
bash-5.3$ ninja
[4/4] Linking CXX executable stagedir/bin/beman.exemplar.tests.identity
ld: warning: ignoring duplicate libraries: 'lib/libgtest.a'
bash-5.3$ ctest
Test project /Users/clausklein/Workspace/cpp/beman-project/exemplar/build/gcc-release
Start 1: IdentityTest.call_identity_with_int
1/9 Test #1: IdentityTest.call_identity_with_int ...................... Passed 0.01 sec
Start 2: IdentityTest.call_identity_with_custom_type
2/9 Test #2: IdentityTest.call_identity_with_custom_type .............. Passed 0.01 sec
Start 3: IdentityTest.compare_std_vs_beman
3/9 Test #3: IdentityTest.compare_std_vs_beman ........................ Passed 0.01 sec
Start 4: IdentityTest.check_is_transparent
4/9 Test #4: IdentityTest.check_is_transparent ........................ Passed 0.01 sec
Start 5: install-to-stagedir
5/9 Test #5: install-to-stagedir ...................................... Passed 0.05 sec
Start 6: find-package-test
6/9 Test #6: find-package-test ........................................ Passed 2.74 sec
Start 7: beman.exemplar.examples.identity_direct_usage
7/9 Test #7: beman.exemplar.examples.identity_direct_usage ............ Passed 0.30 sec
Start 8: beman.exemplar.examples.identity_module_usage
8/9 Test #8: beman.exemplar.examples.identity_module_usage ............ Passed 0.24 sec
Start 9: beman.exemplar.examples.identity_as_default_projection
9/9 Test #9: beman.exemplar.examples.identity_as_default_projection ... Passed 0.24 sec
100% tests passed, 0 tests failed out of 9
Total Test time (real) = 3.62 sec
bash-5.3$ !tree
tree stagedir/
stagedir/
├── bin
│ ├── beman.exemplar.examples.identity_as_default_projection
│ ├── beman.exemplar.examples.identity_direct_usage
│ ├── beman.exemplar.examples.identity_module_usage
│ └── beman.exemplar.tests.identity
├── include
│ └── beman
│ └── exemplar
│ └── identity.hpp
└── lib
├── cmake
│ └── beman.exemplar
│ ├── beman.exemplar-config-version.cmake
│ ├── beman.exemplar-config.cmake
│ ├── beman.exemplar-targets-relwithdebinfo.cmake
│ ├── beman.exemplar-targets.cmake
│ ├── cxx-modules
│ │ ├── cxx-modules-beman.exemplar-RelWithDebInfo.cmake
│ │ ├── cxx-modules-beman.exemplar.cmake
│ │ └── target-exemplar-RelWithDebInfo.cmake
│ └── modules
│ └── identity.cppm
└── libbeman.exemplar.a
10 directories, 14 files
bash-5.3$ cd -
/Users/clausklein/Workspace/cpp/beman-project/exemplar/build/gcc-release/tests/beman/exemplar/find-package-test
bash-5.3$ ninja
ninja: no work to do.
bash-5.3$ ctest
Test project /Users/clausklein/Workspace/cpp/beman-project/exemplar/build/gcc-release/tests/beman/exemplar/find-package-test
Start 1: beman.exemplar.examples.identity_direct_usage
1/3 Test #1: beman.exemplar.examples.identity_direct_usage ............ Passed 0.23 sec
Start 2: beman.exemplar.examples.identity_module_usage
2/3 Test #2: beman.exemplar.examples.identity_module_usage ............ Passed 0.23 sec
Start 3: beman.exemplar.examples.identity_as_default_projection
3/3 Test #3: beman.exemplar.examples.identity_as_default_projection ... Passed 0.28 sec
100% tests passed, 0 tests failed out of 3
Total Test time (real) = 0.75 sec
bash-5.3$ cmake -L .
-- use ccache
CMake Warning at /Users/clausklein/Workspace/cpp/beman-project/exemplar/cmake/prelude.cmake:46 (message):
$CXX is not set
Call Stack (most recent call first):
CMakeLists.txt:5 (include)
-- CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=/usr/local/Cellar/gcc/15.2.0/include/c++/15;/usr/local/Cellar/gcc/15.2.0/include/c++/15/x86_64-apple-darwin23;/usr/local/Cellar/gcc/15.2.0/include/c++/15/backward;/usr/local/Cellar/gcc/15.2.0/lib/gcc/current/gcc/x86_64-apple-darwin23/15/include;/usr/local/Cellar/gcc/15.2.0/lib/gcc/current/gcc/x86_64-apple-darwin23/15/include-fixed;/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include;/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks
-- CMAKE_CXX_SCAN_FOR_MODULES=ON
Examples to be built: identity_direct_usage;identity_module_usage;identity_as_default_projection
-- Configuring done (0.1s)
CMake Warning (dev) in CMakeLists.txt:
CMake's support for `import std;` in C++23 and newer is experimental. It
is meant only for experimentation and feedback to CMake developers.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done (0.0s)
-- Build files have been written to: /Users/clausklein/Workspace/cpp/beman-project/exemplar/build/gcc-release/tests/beman/exemplar/find-package-test
-- Cache values
BEMAN_HAS_MODULES:BOOL=ON
BEMAN_USE_STD_MODULE:BOOL=OFF
CCACHE_EXECUTABLE:FILEPATH=/usr/local/bin/ccache
CMAKE_BUILD_TYPE:STRING=RelWithDebInfo
CMAKE_CXX_COMPILER_LAUNCHER:PATH=/usr/local/bin/ccache
CMAKE_C_COMPILER_LAUNCHER:PATH=/usr/local/bin/ccache
CMAKE_INSTALL_PREFIX:PATH=/Users/clausklein/.local
CMAKE_MAKE_PROGRAM:FILEPATH=/Users/clausklein/.local/bin/ninja
CMAKE_OSX_ARCHITECTURES:STRING=
CMAKE_OSX_DEPLOYMENT_TARGET:STRING=
CMAKE_OSX_SYSROOT:STRING=
beman.exemplar_DIR:PATH=/Users/clausklein/Workspace/cpp/beman-project/exemplar/build/gcc-release/stagedir/lib/cmake/beman.exemplar
bash-5.3$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a prototype only to evaluate some concepts how we can work with CXX_MODULES
I added 3
cmake moduleswhich can be included before and afterproject()call.Require C++20 or newer with extensions for modules!
target_compile_definitions(beman.exemplar PUBLIC BEMAN_HAS_MODULES)target_compile_features(beman.exemplar PUBLIC cxx_std_${CMAKE_CXX_STANDARD})
All 3 are prepared to be integrated / merged into
infra/cmakerepoThey add 3 new global options:
Create a self contained
CXX_MODULEAdd module usage example too that will be tested after staged install to build directory
8fbd480 Set BEMAN_USE_STD_MODULE=1 on gcc presets
76afe1e Disable BEMAN_USE_STD_MODULE for now
bb7b274 Add option BEMAN_USE_STD_MODULE
a77018c Disable CI tests with clang and libstdc++ for now
eb59178 Disable CI tests with gcc-13 for now
f1e4627 Add generic cmake modules to work with import std;
5afc6ca On UNIX Ninja is required to build CXX_MODULES
f0cb4e7 Require C++20 or newer with extensions for modules
83ddc05 Try to handle CI matrix complexity
fcd47ab Update googletest to v1.17.0 (reverted again)
0abf4a9 Modules opt in only on compilers that support it
0768b67 Use ctest --build-and-test to check the installed version
a4f2313 rm CMakeUserPresets.json (accidentally added)
18d3e51 Prepare CXX_MODULE usage
CMAKE_CXX_STANDARDvalue (17 or 20)!Cookiecutteris a nightmare, next week I will start to tryIt depends on following PR:
fix #287 too