-
Notifications
You must be signed in to change notification settings - Fork 17
Feat: Prepare CXX_MODULES tests #195
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
base: main
Are you sure you want to change the base?
Feat: Prepare CXX_MODULES tests #195
Conversation
ClausKlein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems the including inside module code is tricky and not clear to me?
dietmarkuehl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have experience with modules, yet. My original hope/plan was to effectively include all the headers implementing beman::execution into a module unit and export the various visible names. The various exposition-only names would, hopefully, not get exported (although I'm currently using some for beman::task - I may need to move that to beman::execution).
Since there are constraints on how the standard library is made available, I may need to conditionally import std; instead of including the various headers. The approach is probably migrating things individually in dependency order or so: get some feedback on what works/doesn't work before finding out it doesn't work once everything is migrated.
| add_library(${TARGET_NAME} STATIC) | ||
|
|
||
| # CMake requires the language standard to be specified as compile feature | ||
| # when a target provides C++23 modules and the target will be installed | ||
| target_compile_features(${TARGET_NAME} PUBLIC cxx_std_23) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should/could this section be conditional on whether modules are available/enabled? It looks as if this is unconditionally set up. I believe beman::execution is currently build with multiple C++ standards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need a target to set target_compile_features()
| # export LDFLAGS=-L$(LLVM_DIR)/lib/c++ -lc++abi -lc++ # -lc++experimental | ||
| # export GCOV="llvm-cov gcov" | ||
| export CMAKE_CXX_STDLIB_MODULES_JSON=${LLVM_DIR}/lib/c++/libc++.modules.json | ||
| export CXX=clang++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer if the compiler were not defaulted like this in the Makefile (although I actually don't even know what export does in Makefiles; it seems something similar to bash's export).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer if the compiler were not defaulted like this in the Makefile
as long the cmake feature is experimental and the compiler have problems to find there own json files for stdc++ lib it is needed in that way at leas on OSX!
you my try it in cmake code like here: https://github.com/ClausKlein/cmake-init-modules/blob/develop/cmake/prelude.cmake
| export CXXFLAGS:=-stdlib=libstdc++ | ||
| export GCOV="gcov" | ||
| # export CMAKE_CXX_STDLIB_MODULES_JSON=${GCC_DIR}/lib/gcc/current/libstdc++.modules.json | ||
| # export CXX:=g++-15 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least, I prefer clang++ over g++-15: I'm mostly using Mac's with Apple silicon and there is no released gcc for these (as far as I know; there is patch from Ian Sandoe I managed to build but even so the result would be named g++-15 for me).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an option you may change like you want, also the version may be changed a you need.
| ```cpp | ||
| // Copyright (c) 2016-2025 Antony Polukhin | ||
| // | ||
| // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this implies that I'd prefer a link to the location of where this "cheat sheet" lives rather than including it over here! I'm not opposed to the Boost license but I'd prefer avoiding mixing licenses in a respository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this must be at the beman standard an is only an example for you and me.
You will find a simple and cleaned asio module but this is only usable as CXX_MODULES and with or without import std;
me too, but im interesting to know ! see https://github.com/ClausKlein/fmt-module/tree/develop?tab=readme-ov-file#readme |
I miss the BMI file
CMake install CXX_MODULES_BMII have tried to import std; in module test.
The include system headers in module code must be prevented!
A clear concept is missing, you will found one i.e. boost/any
https://github.com/ClausKlein/scope/blob/develop/include/beman/scope/beman.scope.cppm (simple without import std;)
https://github.com/ClausKlein/modules-playground/blob/develop/asio-module/module/asio.cxx (clear, but useable only as CXX_MODULES)
https://github.com/ClausKlein/any/blob/develop/modules/boost_any.cppm (best, flexible and consistent build concept)
https://github.com/ClausKlein/fmt-module/blob/develop/module/fmt.cppm (caos, want to be usable with C++17 too)