Skip to content
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

added a module and corresponding tests #91

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

added a module and corresponding tests #91

wants to merge 2 commits into from

Conversation

dietmarkuehl
Copy link
Collaborator

The CMakeLists.txt aren't quite right, yet:

  • some tests are disabled
  • more importantly, the install doesn't work, yet - something is missing

Also, there is probably some suitable guard needed to avoid trying to compile modules when there isn't any support. It seems clang++ has some level of implementation of modules but doesn't define the feature test macro. I haven't tried with gcc or MSVC++, yet.

@ClausKlein
Copy link
Collaborator

May I help you?

I see some cmake issues with installing the code with module.

FYI: https://github.com/ClausKlein/cmake-init-modules/blob/dcd6ebc78b3ea4e6f40eef25254b35670ecaf480/CMakeLists.txt#L53

and anarthal/boost-modules-bench#1

@dietmarkuehl
Copy link
Collaborator Author

May I help you?

I see some cmake issues with installing the code with module.

FYI: https://github.com/ClausKlein/cmake-init-modules/blob/dcd6ebc78b3ea4e6f40eef25254b35670ecaf480/CMakeLists.txt#L53

and anarthal/boost-modules-bench#1

I'd certainly appreciate help with that one! There are two things I think I need help with (note: I don't understand cmake particular well):

  1. I believe I copied what is needed to install things but when I uncomment any of the install(...) commands in src/beman/execution26/CMakeLists.txt I get an incomprehensible error message:

     -- TARGET_ALIAS="beman_execution26::beman_execution26" ; TARGET_LIBRARY="beman_execution26" ; 
     TARGET_PREFIX="beman.execution26" ; PROJECT_SOURCE_DIR="/Users/kuehl/src/execution26"
     CMake Error at src/beman/execution26/CMakeLists.txt:214 (install):
       install TARGETS target beman_execution26 is exported but not all of its
       interface file sets are installed
    
     -- Configuring incomplete, errors occurred!
    

    I suspect that beman.execution26.pcm or so needs to be installed (or, maybe, the cmake needs to be updated; I'm currently using cmake version 3.30.5).

  2. Even if I get over that, it seems the modules stuff isn't understood by all the compilers, yet, and it may be necessary to only use modules with some compiler versions. I don't know how to determine that in the CMakeLists.txt.

@ClausKlein
Copy link
Collaborator

ClausKlein commented Nov 26, 2024

  1. I believe I copied what is needed to install things

I will try to fix it

I suspect that beman.execution26.pcm or so needs to be installed (or, maybe, the cmake needs to be updated; I'm currently using cmake version 3.30.5).

Yes, and this cmake v3.30.x is now the absolute minimum version!

  1. Even if I get over that, it seems the modules stuff isn't understood by all the compilers, yet, and it may be necessary to only use modules with some compiler versions. I don't know how to determine that in the CMakeLists.txt.

There are some limitations right now:

  1. only ninja generators works to install c++ modules
  2. clang++ v18 or newer and Visual Studio 17 2022 are supported without patches, see compiler-support
  3. and some more limitations

see too cxx_modules

@ClausKlein
Copy link
Collaborator

done:

bash-5.2$ cmake --workflow release
# ...

Executing workflow step 3 of 4: test preset "release"

Test project /Users/clausklein/Workspace/cpp/beman-project/execution26/build/release
    Start 1: beman.execution26.execution-module.test
1/3 Test #1: beman.execution26.execution-module.test ....   Passed    0.32 sec
    Start 2: beman.execution26.stop-token-module.test
2/3 Test #2: beman.execution26.stop-token-module.test ...   Passed    0.26 sec
    Start 3: find-package-test
3/3 Test #3: find-package-test ..........................   Passed    1.95 sec

100% tests passed, 0 tests failed out of 3

Total Test time (real) =   2.53 sec

Executing workflow step 4 of 4: package preset "release"

CPack: Create package using TGZ
CPack: Install projects
CPack: - Install project: beman_execution26 [Release]
CPack: Create package
CPack: - package: /Users/clausklein/Workspace/cpp/beman-project/execution26/build/release/beman_execution26-0.1.0-Darwin.tar.gz generated.
bash-5.2$ tree stagedir/lib/cmake/
stagedir/lib/cmake/
`-- beman_execution26
    |-- beman_execution26-config-version.cmake
    |-- beman_execution26-config.cmake
    |-- beman_execution26-targets-relwithdebinfo.cmake
    |-- beman_execution26-targets.cmake
    `-- src
        `-- execution.cppm

3 directories, 5 files
bash-5.2$ 

* First step to install cxx_module

* Allow CI workflow to run on every branch

* Disable g++ builds for now

* Cleanup

* Set CXX_MODULES_DIRECTORY and CMAKE_DEBUG_POSTFIX

* Fix module example

* Prevent linker problems with sanitizer or gcov
@ClausKlein
Copy link
Collaborator

I have started to implemented a proof-of-concept(POC) on how to export asio names as a CXX_MODULE, but be also usable as a C++ interface / static library with modern CMake

see ClausKlein/asio#4

it is based on Boost modules benchmark and POC

@ClausKlein
Copy link
Collaborator

ClausKlein commented Dec 3, 2024

Dit you read this paper: C++20 modules and Boost: deep dive?

@dietmarkuehl
Copy link
Collaborator Author

I have read the documents now. It seems at most module support could become an option and it may need to be done differently. The current state was an attempt testing things out and I hoped that there is something useful coming from that.

My plan is to do whatever is needed to enable module use for gcc, clang, and MSVC++ to let people use modules. The last two weeks I was blocked by not having easy access to MSVC++. I hope I can get a version viable for MSVC++.

One issue which may cause grief is that various names are defined hidden and imported into the proper namespace with a using alias. It seems MSVC++ doesn't like export using detail::name; based on the document. I'm not sure, yet, what can be done.

@ClausKlein
Copy link
Collaborator

I got the CXX_MODULE work for the fmt library:

https://github.com/ClausKlein/fmt-module

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.

2 participants