Skip to content

Feature/use modules#10

Open
ClausKlein wants to merge 23 commits intomainfrom
feature/use-modules
Open

Feature/use modules#10
ClausKlein wants to merge 23 commits intomainfrom
feature/use-modules

Conversation

@ClausKlein
Copy link
Copy Markdown

@ClausKlein ClausKlein commented Mar 13, 2026

This is only a prove of concept to build an interface library (header only) and a c++20 module library together

  • IMHO you should not realy need 2 module libs
  • the beman library naming convention is no clear to me. The install function does only yet accepts beman.xxx_yyy names
  • some historic toolchains should not used with c++26 on CI
  • g++-15 with CXX_MODULES does not compile friends #15
  • CI build with and w/o module with MSVC and clang++-22
  • All test on CI with and w/o modules
  • Supports usable installation too

@ClausKlein ClausKlein marked this pull request as draft March 13, 2026 13:52
@ClausKlein ClausKlein self-assigned this Mar 13, 2026
@ClausKlein ClausKlein marked this pull request as ready for review March 13, 2026 13:57
@ClausKlein ClausKlein marked this pull request as draft March 13, 2026 15:57
@ClausKlein ClausKlein force-pushed the feature/use-modules branch from 97f42f3 to a8de9f8 Compare March 13, 2026 20:47
@ClausKlein ClausKlein marked this pull request as ready for review March 13, 2026 20:48
Comment thread examples/CMakeLists.txt
set_target_properties(
beman.monadics.examples.${example}
PROPERTIES
# TODO(CK): why? CXX_EXTENSIONS OFF
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we actually need to do that per target. I was just following recommendations.
I think it should be controlled by a consumer.

I have not verified if it is okay to mix for example consumer build with -std=gnu++20 and library has been builded with std=c++20

Copy link
Copy Markdown
Author

@ClausKlein ClausKlein Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't mix any compile flag or option, still a cmake constrain!

Comment thread CMakePresets.json
Comment on lines +11 to +13
"BEMAN_USE_MODULES": true,
"BEMAN_USE_STD_MODULE": true,
"CMAKE_CXX_STANDARD": "23",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mostly testing by default with C++20 and modules should be a separate preset.
Maybe we could use somehow environment variables to conditionally extend preset?

Copy link
Copy Markdown
Author

@ClausKlein ClausKlein Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be controlled like here:

https://github.com/ClausKlein/asio/blob/feature/module/.github/workflows/clang.yml

@ednolan but not with beman CI workflows?

Comment thread CMakePresets.json
Comment on lines +80 to +82
"environment": {
"CXX": "clang++",
"CMAKE_CXX_FLAGS": "-stdlib=libc++"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That comes from toolchain.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On OSX it is still needed!

Comment thread CMakePresets.json
Comment on lines +96 to +97
"CXX": "clang++",
"CMAKE_CXX_FLAGS": "-stdlib=libc++"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tito


if(BEMAN_USE_MODULES)
add_library(beman.monadics.detail)
add_library(beman.monadics_detail)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we are using . every as a separator or does it make any difference?

Copy link
Copy Markdown
Author

@ClausKlein ClausKlein Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ednolan The beman install script has some checks to force this!

Comment thread CMakeLists.txt
endif()

beman_install_library(beman.monadics)
beman_install_library(beman.monadics TARGETS beman.monadics beman.monadics_detail beman.monadics_module)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... I am not sure I have understood why do we need all 3 targets.
If the library configured with BEMAN_USE_MODULES then we should not leak any details to a consumer, so we should not install beman.monadics_detail.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmake needs all headers and modules to build the BMI again for a consumer!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, that is the case when library installed as system library.

@ClausKlein
Copy link
Copy Markdown
Author

ClausKlein commented Mar 14, 2026

FYI:

bash-5.3$ clang-tidy examples/monadics_std_usage.cpp 
949 warnings generated.
/Users/clausklein/Workspace/cpp/beman-project/monadics/examples/monadics_std_usage.cpp:10:19: warning: function 'error' has inline specifier but is implicitly inlined [readability-redundant-inline-specifier]
   10 |     [[nodiscard]] inline static constexpr auto error() noexcept { return std::nullopt; }
      |                   ^~~~~~
Suppressed 948 warnings (948 in non-user code).
Use -header-filter=.* or leave it as default to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
bash-5.3$ 

Please check witch clang and w/o module:

run-clang-tidy -checks='-*,misc-include-*' tests/beman/monadics

@ClausKlein
Copy link
Copy Markdown
Author

ClausKlein commented Mar 14, 2026

FIXME: the usage of this header is strange and fragile!

bash-5.3$ git ls-files ::*trait.hpp
tests/beman/monadics/enum/trait.hpp
tests/beman/monadics/expected/trait.hpp
tests/beman/monadics/optional/trait.hpp
tests/beman/monadics/raw_ptr/trait.hpp
tests/beman/monadics/shared_ptr/trait.hpp
bash-5.3$ 

bash-5.3$ head `git ls-files ::*trait.hpp`
==> tests/beman/monadics/enum/trait.hpp <==
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef BEMAN_MONADICS_RAW_PTR_TRAIT_HPP
#define BEMAN_MONADICS_RAW_PTR_TRAIT_HPP

#include <beman/monadics/monadics.hpp>

#include <concepts>
#include <utility>


==> tests/beman/monadics/expected/trait.hpp <==
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef BEMAN_MONADICS_EXPECTED_TRAIT_HPP
#define BEMAN_MONADICS_EXPECTED_TRAIT_HPP

#include <beman/monadics/monadics.hpp>

#include <type_traits>
#include <utility>
#include <concepts>

==> tests/beman/monadics/optional/trait.hpp <==
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef BEMAN_MONADICS_OPTIONAL_TRAIT_HPP
#define BEMAN_MONADICS_OPTIONAL_TRAIT_HPP

#include <beman/monadics/monadics.hpp>

#include <optional>

template <typename T>

==> tests/beman/monadics/raw_ptr/trait.hpp <==
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef BEMAN_MONADICS_RAW_PTR_TRAIT_HPP
#define BEMAN_MONADICS_RAW_PTR_TRAIT_HPP

#include <beman/monadics/monadics.hpp>

#include <type_traits>

template <typename Box>

==> tests/beman/monadics/shared_ptr/trait.hpp <==
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef BEMAN_MONADICS_OPTIONAL_TRAIT_HPP
#define BEMAN_MONADICS_OPTIONAL_TRAIT_HPP

#include <beman/monadics/monadics.hpp>

#include <memory>
#include <utility>

bash-5.3$ 

@ClausKlein ClausKlein force-pushed the feature/use-modules branch from 2b53237 to 81be02e Compare March 14, 2026 15:36
Comment thread CMakePresets.json
"_debug-base"
],
"cacheVariables": {
"BEMAN_USE_MODULES": false,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled for now, it does not compile with g++-15

Comment thread CMakePresets.json
"_release-base"
],
"cacheVariables": {
"BEMAN_USE_MODULES": false,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled for now, it does not compile with g++-15

@coveralls
Copy link
Copy Markdown

coveralls commented Mar 15, 2026

Coverage Status

coverage: 100.0%. remained the same
when pulling 90d9241 on feature/use-modules
into 96a3721 on main.

msvetkin and others added 12 commits March 18, 2026 17:11
Replace global CMAKE_CXX_STANDARD with target_compile_features.

Using target_compile_features expresses the language requirement as a
target usage requirement, ensuring correct propagation to dependents.

Disable compiler extensions to enforce strict ISO C++20 and avoid
compiler-specific behavior.
Ensure they are built with strict ISO C++ and behave consistently
with the main library.
Enforce stricter builds to catch issues early.
@ClausKlein ClausKlein force-pushed the feature/use-modules branch from 5c15262 to 2880561 Compare March 18, 2026 16:15
@ClausKlein ClausKlein requested a review from msvetkin March 18, 2026 16:44
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.

3 participants