Skip to content

Conversation

@ClausKlein
Copy link
Collaborator

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(
TARGETS target1 [target2 ...]
[NAMESPACE ]
[EXPORT_NAME ]
[DESTINATION ]
)

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 "-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.

_INSTALL_CONFIG_FILE_PACKAGE
Per-package override to enable/disable config file installation.
is the uppercased package name with dots replaced by underscores.

@ClausKlein ClausKlein self-assigned this Feb 2, 2026
@ClausKlein ClausKlein requested a review from ednolan February 2, 2026 14:52
@ClausKlein ClausKlein marked this pull request as draft February 2, 2026 14:52
Comment on lines +76 to +77
include(./cmake/beman-install-library.cmake)
beman_install_library(${TARGET_PREFIX} TARGETS ${TARGET_NAME} ${TARGET_PREFIX})
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

Comment on lines 129 to 160
#======================================================================
# NOTE: Only for Release build with enabled install rules useful! CK
#======================================================================
if(BEMAN_EXECUTION_INSTALL_CONFIG_FILE_PACKAGE AND NOT CMAKE_SKIP_INSTALL_RULES)
# test if the targets are usable from the install directory
add_test(
NAME install-to-stagedir
COMMAND
${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix
${CMAKE_BINARY_DIR}/stagedir --config $<CONFIG>
)
add_test(
NAME find-package-test
COMMAND
${CMAKE_CTEST_COMMAND} # --verbose
--output-on-failure -C $<CONFIG> #
--build-and-test "${CMAKE_SOURCE_DIR}/examples"
"${CMAKE_CURRENT_BINARY_DIR}/find-package-test" #
--build-generator ${CMAKE_GENERATOR} #
--build-makeprogram ${CMAKE_MAKE_PROGRAM} #
--build-options #
"-D BEMAN_USE_MODULES=${BEMAN_USE_MODULES}"
"-D CMAKE_BUILD_TYPE=$<CONFIG>"
"-D CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-D CMAKE_CXX_EXTENSIONS=${CMAKE_CXX_EXTENSIONS}"
"-D CMAKE_CXX_MODULE_STD=${CMAKE_CXX_MODULE_STD}"
"-D CMAKE_CXX_SCAN_FOR_MODULES=${CMAKE_CXX_SCAN_FOR_MODULES}"
"-D CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
"-D CMAKE_CXX_STANDARD_REQUIRED=${CMAKE_CXX_STANDARD_REQUIRED}"
"-D CMAKE_PREFIX_PATH=${CMAKE_BINARY_DIR}/stagedir"
)
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.

This add a test to build examples with the installed targets

set(CMAKE_CXX_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}")

set(RELEASE_FLAGS "-O3 ${SANITIZER_FLAGS}")
set(RELEASE_FLAGS "-O3")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do not add sanitizer flags for Release builds, it would be exported!

Comment on lines +43 to +44
"Debug.Default", "Debug.Coverage",
"Debug.MaxSan", "Debug.Werror",
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!

"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!

Comment on lines 137 to 143
install(
EXPORT ${BEMAN_EXPORT_NAME}
NAMESPACE ${BEMAN_NAMESPACE}
CXX_MODULES_DIRECTORY
cxx-modules
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${name}
)
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

Comment on lines +113 to +122
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}
FILE_SET CXX_MODULES DESTINATION "${BEMAN_DESTINATION}"
)
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 results in error an error if we do not have Modules!

Comment on lines 14 to 49
@@ -37,6 +43,7 @@ function(beman_install_library name interface)
# replaced by underscores.
#

# NOTE: in case of an interface only, the name is the project name! CK
# if(NOT TARGET "${name}")
# message(FATAL_ERROR "Target '${name}' does not exist.")
# 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.

this part was my first experiment based on the original infra/cmake module code, not longer used

Comment on lines -51 to +50
# FIXME: target_compile_definitions(beman.execution PUBLIC BEMAN_HAS_MODULES)
target_compile_definitions(${TARGET_PREFIX} PUBLIC BEMAN_HAS_MODULES)
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

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.

1 participant