Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ jobs:
"tests": [
{ "stdlibs": ["libstdc++"],
"tests": [
"Debug.Default", "Release.Default",
"Release.MaxSan", "Debug.Werror",
"Debug.Dynamic", "Debug.Coverage"
"Debug.Default", "Debug.Coverage",
"Debug.MaxSan", "Debug.Werror",
Comment on lines +43 to +44
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only Debug must be used with sanitizer or coverage!

"Release.Default", "Release.Dynamic"
]
}
]
Expand All @@ -67,8 +67,8 @@ jobs:
"tests": [
{ "stdlibs": ["libc++"],
"tests": [
"Debug.Default", "Release.Default", "Release.MaxSan",
"Debug.Dynamic"
"Debug.Default", "Debug.MaxSan",
"Release.Default", "Release.Dynamic"
]
}
]
Expand Down Expand Up @@ -96,7 +96,10 @@ jobs:
{ "cxxversions": ["c++23"],
"tests": [
{ "stdlibs": ["stl"],
"tests": ["Debug.Default", "Release.Default", "Release.MaxSan"]
"tests": [
"Debug.Default", "Debug.MaxSan",
"Release.Default", "Release.Dynamic"
Copy link
Collaborator Author

@ClausKlein ClausKlein Feb 2, 2026

Choose a reason for hiding this comment

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

For Windows, static and dynamic must be build in Release and tested after install!

]
}
]
}
Expand Down
23 changes: 12 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,32 @@ if(BEMAN_USE_MODULES)

# CMake requires the language standard to be specified as compile feature
# when a target provides C++23 modules and the target will be installed
add_library(beman.execution STATIC)
add_library(beman::execution ALIAS beman.execution)
add_library(${TARGET_PREFIX} STATIC)
add_library(beman::execution ALIAS ${TARGET_PREFIX})
target_compile_features(
beman.execution
${TARGET_PREFIX}
PUBLIC cxx_std_${CMAKE_CXX_STANDARD}
)

include(GenerateExportHeader)

generate_export_header(
beman.execution
BASE_NAME beman.execution
${TARGET_PREFIX}
BASE_NAME ${TARGET_PREFIX}
EXPORT_FILE_NAME beman/execution/modules_export.hpp
)
target_sources(
beman.execution
${TARGET_PREFIX}
PUBLIC
FILE_SET HEADERS
BASE_DIRS include ${CMAKE_CURRENT_BINARY_DIR}
FILES
${CMAKE_CURRENT_BINARY_DIR}/beman/execution/modules_export.hpp
)
# FIXME: target_compile_definitions(beman.execution PUBLIC BEMAN_HAS_MODULES)
target_compile_definitions(${TARGET_PREFIX} PUBLIC BEMAN_HAS_MODULES)
Comment on lines -51 to +50
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

here I have activated the using of the cxx_modules code in tests and examples

endif()

if(BEMAN_USE_MODULES AND CMAKE_CXX_MODULE_STD)
target_compile_definitions(beman.execution PUBLIC BEMAN_HAS_IMPORT_STD)
target_compile_definitions(${TARGET_PREFIX} PUBLIC BEMAN_HAS_IMPORT_STD)
else()
message(WARNING "Missing support for CMAKE_CXX_MODULE_STD!")
endif()
Expand All @@ -72,9 +71,11 @@ option(

add_subdirectory(src/beman/execution)

#===============================================================================
# NOTE: this must be done before tests! CK
include(./cmake/beman-install-library-config.cmake)
beman_install_library(${TARGET_PREFIX} headers)
include(./cmake/beman-install-library.cmake)
beman_install_library(${TARGET_PREFIX} TARGETS ${TARGET_NAME} ${TARGET_PREFIX})
Comment on lines +76 to +77
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NOTE: this is the new call to install both, module lib and interface header only library

#===============================================================================

if(BEMAN_EXECUTION_ENABLE_TESTING)
enable_testing()
Expand Down
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SANITIZERS := run
# SANITIZERS += asan # TODO: tsan msan
# endif

.PHONY: default release debug doc run update check ce todo distclean clean codespell clang-tidy build test install all format unstage $(SANITIZERS) module build-module test-module
.PHONY: default release debug doc run update check ce todo distclean clean codespell clang-tidy build test install all format unstage $(SANITIZERS) module build-module test-module build-interface

SYSROOT ?=
TOOLCHAIN ?=
Expand Down Expand Up @@ -99,7 +99,7 @@ endif
# TODO: beman.execution.examples.modules
# FIXME: beman.execution.execution-module.test beman.execution.stop-token-module.test

default: release
default: module

all: $(SANITIZERS)

Expand All @@ -116,7 +116,7 @@ doc:
# ==========================================================
# NOTE: cmake configure to only test without modules! CK
# ==========================================================
build:
build build-interface:
cmake -G Ninja -S $(SOURCEDIR) -B $(BUILD) $(TOOLCHAIN) $(SYSROOT) \
-D CMAKE_EXPORT_COMPILE_COMMANDS=ON \
-D CMAKE_SKIP_INSTALL_RULES=ON \
Expand All @@ -126,9 +126,11 @@ build:
-D CMAKE_CXX_SCAN_FOR_MODULES=OFF \
-D BEMAN_USE_MODULES=OFF \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_SKIP_TEST_ALL_DEPENDENCY=OFF \
-D CMAKE_CXX_COMPILER=$(CXX) --log-level=VERBOSE
cmake --build $(BUILD)
# XXX --fresh -D CMAKE_CXX_FLAGS="$(CXX_FLAGS) $(SAN_FLAGS)"
# XXX --fresh -D CMAKE_CXX_FLAGS="$(CXX_FLAGS) $(SAN_FLAGS)"
cmake --build $(BUILD) --target all_verify_interface_header_sets
cmake --build $(BUILD) --target all

# NOTE: without install, see CMAKE_SKIP_INSTALL_RULES! CK
test: build
Expand All @@ -137,13 +139,15 @@ test: build
module build-module:
cmake -G Ninja -S $(SOURCEDIR) -B $(BUILD) $(TOOLCHAIN) $(SYSROOT) \
-D CMAKE_EXPORT_COMPILE_COMMANDS=ON \
-D CMAKE_SKIP_INSTALL_RULES=ON \
-D CMAKE_SKIP_INSTALL_RULES=OFF \
-D CMAKE_CXX_STANDARD=23 \
-D CMAKE_CXX_EXTENSIONS=ON \
-D CMAKE_CXX_STANDARD_REQUIRED=ON \
-D CMAKE_CXX_SCAN_FOR_MODULES=ON \
-D BEMAN_USE_MODULES=ON \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_MESSAGE=LAZY \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_COMPILER=$(CXX) --log-level=VERBOSE
cmake --build $(BUILD)

Expand Down
226 changes: 226 additions & 0 deletions cmake/beman-install-library-config-package.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
cmake_minimum_required(VERSION 3.30)

include_guard(GLOBAL)

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

# beman_install_library
# =====================
#
# Installs a library (or set of targets) along with headers, C++ modules,
# and optional CMake package configuration files.
#
# Usage:
# ------
# beman_install_library(<name>
# TARGETS target1 [target2 ...]
# [NAMESPACE <namespace>]
# [EXPORT_NAME <export-name>]
# [DESTINATION <install-prefix>]
# )
#
# Arguments:
# ----------
# name
# Logical package name (e.g. "beman.utility").
# Used to derive config file names and cache variable prefixes.
#
# TARGETS (required)
# List of CMake targets to install.
#
# NAMESPACE (optional)
# Namespace for exported targets.
# Defaults to "beman::".
#
# EXPORT_NAME (optional)
# Name of the CMake export set.
# Defaults to "<name>-targets".
#
# DESTINATION (optional)
# The install destination for CXX_MODULES.
# Defaults to CMAKE_INSTALL_INCLUDEDIR/beman/modules.
#
# Brief
# -----
#
# This function installs the specified project TARGETS and its FILE_SET
# HEADERS to the default CMAKE install Destination.
#
# It also handles the installation of the CMake config package files if
# needed. If the given targets has FILE_SET CXX_MODULE, it will also
# installed to the given DESTINATION
#
# Cache variables:
# ----------------
# BEMAN_INSTALL_CONFIG_FILE_PACKAGES
# List of package names for which config files should be installed.
#
# <PREFIX>_INSTALL_CONFIG_FILE_PACKAGE
# Per-package override to enable/disable config file installation.
# <PREFIX> is the uppercased package name with dots replaced by underscores.
#
function(beman_install_library name)
# ----------------------------
# Argument parsing
# ----------------------------
set(options)
set(oneValueArgs NAMESPACE EXPORT_NAME DESTINATION)
set(multiValueArgs TARGETS)

cmake_parse_arguments(
BEMAN
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)

if(NOT BEMAN_TARGETS)
message(
FATAL_ERROR
"beman_install_library(${name}): TARGETS must be specified"
)
endif()

# ----------------------------
# Defaults
# ----------------------------
if(NOT BEMAN_NAMESPACE)
set(BEMAN_NAMESPACE "beman::")
endif()

if(NOT BEMAN_EXPORT_NAME)
set(BEMAN_EXPORT_NAME "${name}-targets")
endif()

if(NOT BEMAN_DESTINATION)
set(BEMAN_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/beman/modules")
endif()

if(CMAKE_SKIP_INSTALL_RULES)
message(
WARNING
"beman_install_library(${name}): not installing targets '${BEMAN_TARGETS}' due to CMAKE_SKIP_INSTALL_RULES"
)
return()
endif()

string(REPLACE "beman." "" install_component_name "${name}")

# ----------------------------------------
# Install targets and headers (always)
# ----------------------------------------
install(
TARGETS ${BEMAN_TARGETS}
EXPORT ${BEMAN_EXPORT_NAME}
ARCHIVE # DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY # DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME # DESTINATION ${CMAKE_INSTALL_BINDIR}
FILE_SET
HEADERS # DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

# ----------------------------------------
# Conditionally install C++ modules
# ----------------------------------------
foreach(_tgt IN LISTS BEMAN_TARGETS)
if(NOT TARGET "${_tgt}")
message(
FATAL_ERROR
"beman_install_library(${name}): '${_tgt}' is not a target"
)
endif()

# Detect presence of C++ module file sets, exact one expected!
get_target_property(_module_sets "${_tgt}" CXX_MODULE_SETS)

if(_module_sets)
install(
TARGETS "${_tgt}"
FILE_SET CXX_MODULES DESTINATION "${BEMAN_DESTINATION}"
)
endif()
endforeach()

# --------------------------------------------------
# Export targets
# --------------------------------------------------
install(
EXPORT ${BEMAN_EXPORT_NAME}
NAMESPACE ${BEMAN_NAMESPACE}
CXX_MODULES_DIRECTORY
cxx-modules
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${name}
COMPONENT "${install_component_name}"
)
Comment on lines 150 to 157
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This does not work! File will be deleted later


# ----------------------------------------
# Config file installation logic
# ----------------------------------------
string(TOUPPER "${name}" _pkg_upper)
string(REPLACE "." "_" _pkg_prefix "${_pkg_upper}")

option(
${_pkg_prefix}_INSTALL_CONFIG_FILE_PACKAGE
"Enable creating and installing a CMake config-file package. Default: ON. Values: { ON, OFF }."
ON
)

set(_pkg_var "${_pkg_prefix}_INSTALL_CONFIG_FILE_PACKAGE")

if(NOT DEFINED ${_pkg_var})
set(${_pkg_var}
OFF
CACHE BOOL
"Install CMake package config files for ${name}"
)
endif()

set(_install_config OFF)

if(${_pkg_var})
set(_install_config ON)
elseif(BEMAN_INSTALL_CONFIG_FILE_PACKAGES)
list(FIND BEMAN_INSTALL_CONFIG_FILE_PACKAGES "${name}" _idx)
if(NOT _idx EQUAL -1)
set(_install_config ON)
endif()
endif()

# ----------------------------------------
# Generate + install config files
# ----------------------------------------
if(_install_config)
set(_config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${name}")

configure_package_config_file(
"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/${name}-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${name}-config.cmake"
INSTALL_DESTINATION ${_config_install_dir}
)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${name}-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${name}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${name}-config-version.cmake"
DESTINATION ${_config_install_dir}
COMPONENT "${install_component_name}"
)
else()
message(
WARNING
"beman-install-library(${name}): Not installing a config package for '${name}'"
)
endif()
endfunction()

set(CPACK_GENERATOR TGZ)
include(CPack)
Loading
Loading