Skip to content

Conversation

@ClausKlein
Copy link
Collaborator

@ClausKlein ClausKlein commented Jan 28, 2026

Create and install an interface libray and CXX_MODULE

Available CMake options:

BEMAN_EXECUTION_BUILD_EXAMPLES:BOOL=ON
BEMAN_EXECUTION_ENABLE_INSTALL:BOOL=ON
BEMAN_EXECUTION_ENABLE_TESTING:BOOL=ON
BEMAN_HAS_IMPORT_STD:BOOL=ON
BEMAN_USE_MODULES:BOOL=ON
BEMAN_USE_STD_MODULE:BOOL=ON

Exported CMake targets:

beman_execution imported as beman::beman_execution
beman_execution_headers imported as beman::beman_execution_headers

Installed CMAKE config package:

bash-5.3$ cpack
CPack: Create package using TGZ
CPack: Install projects
CPack: - Install project: beman_execution []
CPack: Create package
CPack: - package: gcc-release/beman_execution-0.0.1-Darwin.tar.gz generated.
bash-5.3$ tree _CPack_Packages/Darwin/TGZ/beman_execution-0.0.1-Darwin/lib/cmake/
_CPack_Packages/Darwin/TGZ/beman_execution-0.0.1-Darwin/lib/cmake/
└── beman_execution
    ├── beman_execution-config-targets-relwithdebinfo.cmake
    ├── beman_execution-config-targets.cmake
    ├── beman_execution-config-version.cmake
    ├── beman_execution-config.cmake
    ├── cxx-modules-beman_execution-config-targets-RelWithDebInfo.cmake
    ├── cxx-modules-beman_execution-config-targets.cmake
    ├── module
    │   └── execution.cppm
    └── target-beman__execution-RelWithDebInfo.cmake

3 directories, 8 files
bash-5.3$
  • FIX Missing support for CMAKE_CXX_SCAN_FOR_MODULES for non preset CI tests
  • TODO: compile examles/modules.cpp
  • error: using declaration referring to 'fprintf' with internal linkage cannot be exported (on Linux: clang++ with libc++)
  • note: '__tsan_mutex_not_static' declared with internal linkage (on Linux: g++-15 c++26 libstdc++ Release.TSan)

Works on my iMAC with gcc-15 and llvm-21 with CMakeUserPresets.json -> cmake/CMakeUserPresets.json

  • CXX=clang++ cmake --workflow release --fresh
  • CXX=g++ cmake --workflow release --fresh

@ClausKlein ClausKlein self-assigned this Jan 28, 2026
@ClausKlein ClausKlein marked this pull request as draft January 28, 2026 22:46
Copy link
Member

@dietmarkuehl dietmarkuehl left a comment

Choose a reason for hiding this comment

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

On the branch I had meddled a bit and fixed a bunch of things to fix some problems in the code. To get the code to compile I did change in particular examples/modules.cpp.

@ClausKlein ClausKlein force-pushed the feature/install-header-only-lib-too branch from fc4afe4 to fc741e7 Compare January 29, 2026 10:30
Prevent build errors with appleclang too
Quickfix: use import beman.execution;

Show #warning if __cpp_modules is not set right

Quickfix: do not compile examles/modules.cpp yet
@ClausKlein ClausKlein force-pushed the feature/install-header-only-lib-too branch from fc741e7 to 099d115 Compare January 29, 2026 10:41

if(BEMAN_USE_MODULES)
list(APPEND EXAMPLES modules) # modules.cpp
# FIXME: not yet! list(APPEND EXAMPLES modules) # modules.cpp
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dietmarkuehl Note this please

Comment on lines +198 to 211
set(TARGET_LIST ${TARGET_NAME})

if(BEMAN_USE_MODULES)
target_sources(
${TARGET_NAME}
beman_execution
PRIVATE execution.cpp
PUBLIC
FILE_SET CXX_MODULES
BASE_DIRS ${PROJECT_SOURCE_DIR}/src/beman/execution
FILES ${PROJECT_SOURCE_DIR}/src/beman/execution/execution.cppm
)
target_link_libraries(beman_execution PUBLIC ${TARGET_NAME})
list(APPEND TARGET_LIST beman_execution)
endif()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dietmarkuehl I create and install a beman_execution and a beman_execution_headers only lib now

Comment on lines 116 to 126
if(BEMAN_USE_MODULES)
target_compile_definitions(${TARGET_NAME} PUBLIC BEMAN_USE_MODULES)
target_link_libraries(${TEST_EXE} PRIVATE beman::execution)
else()
target_link_libraries(${TEST_EXE} PRIVATE beman::execution_headers)
endif()
target_link_libraries(${TEST_EXE} PRIVATE beman::execution)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dietmarkuehl this are the ALIAS and the IMPORTED libraries!

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense. Now I also understand the copilot comment on that and why my tests gave the impression to work with modules although I think they shouldn’t.

@ClausKlein ClausKlein marked this pull request as ready for review January 29, 2026 11:26
Comment on lines +102 to +105
include(infra/cmake/beman-install-library-config.cmake)
# FIXME: install TARGETS target beman.execution is exported but not all of its interface file sets are installed
# TODO: beman_install_library(beman_execution beman_execution_headers)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ednolan How to install a project like execution with this CMake module?

@ClausKlein ClausKlein marked this pull request as draft January 29, 2026 18:16
@ClausKlein
Copy link
Collaborator Author

@dietmarkuehl we need something like this:

diff --git a/include/beman/execution/detail/common.hpp b/include/beman/execution/detail/common.hpp
index eec0f2c..36d7c0f 100644
--- a/include/beman/execution/detail/common.hpp
+++ b/include/beman/execution/detail/common.hpp
@@ -6,7 +6,13 @@
 
 // ----------------------------------------------------------------------------
 
+#if __has_include (<beman/execution/modules_export.hpp>)
+#include <beman/execution/modules_export.hpp>
+#endif
+
+#ifndef BEMAN_EXECUTION_EXPORT
 #define BEMAN_EXECUTION_EXPORT
+#endif
 
 #if defined(disabled__cpp_deleted_function)
 #define BEMAN_EXECUTION_DELETE(msg) delete (msg)

@ClausKlein ClausKlein marked this pull request as ready for review January 29, 2026 19:31
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