Skip to content

Prepare CXX_MODULE usage - #286

Closed
ClausKlein wants to merge 4 commits into
bemanproject:mainfrom
ClausKlein:feature/add_cxx_module
Closed

ClausKlein wants to merge 4 commits into
bemanproject:mainfrom
ClausKlein:feature/add_cxx_module

Conversation

@ClausKlein

@ClausKlein ClausKlein commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

This is a prototype only to evaluate some concepts how we can work with CXX_MODULES

see too cmake/README.md

Create a self contained CXX_MODULE

Add module usage example.

All examples will be tested in Release build within a find-package-test using staged install to build directory

BEMAN_USE_STD_MODULE=OFF only for llvm

  • Local fix only to install modules right!
  • some historic compiler should not longer used / supported (i.e.: gcc-14, clang-18, clang-19)!
  • for all current clang compiler on Linux, cmake -D BEMAN_USE_STD_MODULE=OFF should be used on CI!
  • install test on CI should not longer needed or must be changed to Ninja instead default generator?
  • Cookiecutter is a nightmare, Not yet started! The concept has to be approved and the infra PR merged!

It depends on following PR:

fix #287 too
and some aspects of #59

@coveralls

coveralls commented Jan 16, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same
when pulling deac326 on ClausKlein:feature/add_cxx_module
into ddfe5ba on bemanproject:main.

@ClausKlein
ClausKlein marked this pull request as draft January 16, 2026 21:18
@ClausKlein

ClausKlein commented Jan 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@ednolan Please help, I can't fix some of the CI problems caused by infra structure

I disabled on CI C++26 tests with historic appleclang, gcc-13, clang-17, clang-18

@ClausKlein

ClausKlein commented Jan 21, 2026 •

Copy link
Copy Markdown
Contributor Author

@ednolan I disable the gcc-13 tests on CI for now

see ticket #290

and C++26 is not usable with apple clang, see #289

eb59178

Comment thread cmake/cxx-modules-rules.cmake
Comment thread cmake/beman-install-library.cmake Outdated
Comment thread cmake/beman-install-library.cmake Outdated
Comment thread CMakePresets.json
Comment thread CMakeLists.txt
@ClausKlein

ClausKlein commented Feb 3, 2026 •

Copy link
Copy Markdown
Contributor Author

the full log of:

bash-5.3$ make -n demo
rm -rf build stagedir compile_commands.json
find . -name '*~' -delete
rm -rf /opt/local/*/*
cmake --preset appleclang-release --fresh --log-level=VERBOSE
cmake --workflow appleclang-release
cmake --preset gcc-release --fresh --log-level=VERBOSE
cmake --workflow gcc-release
cmake --preset llvm-release --fresh --log-level=VERBOSE
cmake --workflow llvm-release
cmake --preset llvm-debug --fresh --log-level=VERBOSE
cmake --workflow llvm-debug
cmake --install build/llvm-debug --prefix=/opt/local
cmake --install build/llvm-release --prefix=/opt/local
tree /opt/local

bash-5.3$ tree /opt/local
/opt/local
├── bin
├── etc
├── include
│   └── beman
│       └── exemplar
│           └── identity.hpp
├── lib
│   ├── cmake
│   │   └── beman.exemplar
│   │       ├── beman.exemplar-config-version.cmake
│   │       ├── beman.exemplar-config.cmake
│   │       ├── beman.exemplar-targets-debug.cmake
│   │       ├── beman.exemplar-targets-relwithdebinfo.cmake
│   │       ├── beman.exemplar-targets.cmake
│   │       ├── cxx-modules
│   │       │   ├── cxx-modules-beman.exemplar-targets-Debug.cmake
│   │       │   ├── cxx-modules-beman.exemplar-targets-RelWithDebInfo.cmake
│   │       │   ├── cxx-modules-beman.exemplar-targets.cmake
│   │       │   ├── target-exemplar-Debug.cmake
│   │       │   └── target-exemplar-RelWithDebInfo.cmake
│   │       └── modules
│   │           └── identity.cppm
│   ├── libbeman.exemplar.a
│   └── libbeman.exemplar_d.a
└── share

12 directories, 14 files

build-cz7u1udb.log

@ClausKlein
ClausKlein force-pushed the feature/add_cxx_module branch from a02a839 to 99a50f2 Compare February 4, 2026 13:51
Comment thread CMakeLists.txt Outdated
@ClausKlein
ClausKlein force-pushed the feature/add_cxx_module branch 3 times, most recently from 2d9e275 to aadf857 Compare February 8, 2026 20:02
Comment thread cmake/beman.exemplar-config.cmake.in
Add module usage example too

Create a self contained CXX_MODULE

Use ctest --build-and-test to check the installed version

Modules opt in only on compilers that support it

Require C++20 or newer with extensions for modules

On UNIX Ninja is required to build CXX_MODULES

Add generic cmake modules to work with import std;

Disable CI tests with gcc-13 for now

Disable CI tests with clang and libstdc++ for now

Add option BEMAN_USE_STD_MODULE

Prepare BMI install too, but not yet used!

Use bracket form for quoting if not only a package name is used

Prevent use of sanitizer flags in Release builds

Set BEMAN_USE_STD_MODULE in CMake presets
@ClausKlein
ClausKlein force-pushed the feature/add_cxx_module branch from c2a2fc6 to 8da0597 Compare February 15, 2026 19:50
Set SOVERSION too for shared libs

Use target PROPERTIES CXX_MODULE_STD
@ClausKlein
ClausKlein force-pushed the feature/add_cxx_module branch from 8da0597 to aba447e Compare February 18, 2026 13:56
@ClausKlein

Copy link
Copy Markdown
Contributor Author

This was only created to demonstrate one possible concept and to end in a discussion how to use CXX_MODULES in a Beman project.

The discussion should continue https://discourse.bemanproject.org/t/c-20-modules-in-beman-project-libraries/279/39?u=clausklein here

@ClausKlein ClausKlein closed this Mar 9, 2026
@ClausKlein
ClausKlein deleted the feature/add_cxx_module branch July 25, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The exported cmake config packages must be checked to be usable

2 participants