-
Notifications
You must be signed in to change notification settings - Fork 18
Feature/refactory install module #211
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?
Changes from all commits
04035ca
20704e3
8a30a57
ea36d7c
7aafa44
5515558
642135c
d6eb7d2
7e9f98b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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", | ||
| "Release.Default", "Release.Dynamic" | ||
| ] | ||
| } | ||
| ] | ||
|
|
@@ -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" | ||
| ] | ||
| } | ||
| ] | ||
|
|
@@ -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" | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For Windows, |
||
| ] | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here I have activated the using of the |
||
| 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() | ||
|
|
@@ -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
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
|
||
| 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
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
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.
Only
Debugmust be used withsanitizerorcoverage!