Feature/refactory install module#211
Conversation
| include(./cmake/beman-install-library.cmake) | ||
| beman_install_library(${TARGET_PREFIX} TARGETS ${TARGET_NAME} ${TARGET_PREFIX}) |
There was a problem hiding this comment.
NOTE: this is the new call to install both, module lib and interface header only library
| #====================================================================== | ||
| # 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() |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Do not add sanitizer flags for Release builds, it would be exported!
| "Debug.Default", "Debug.Coverage", | ||
| "Debug.MaxSan", "Debug.Werror", |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
For Windows, static and dynamic must be build in Release and tested after install!
| install( | ||
| EXPORT ${BEMAN_EXPORT_NAME} | ||
| NAMESPACE ${BEMAN_NAMESPACE} | ||
| CXX_MODULES_DIRECTORY | ||
| cxx-modules | ||
| DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${name} | ||
| ) |
There was a problem hiding this comment.
This does not work! File will be deleted later
| 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}" | ||
| ) |
There was a problem hiding this comment.
This results in error an error if we do not have Modules!
| @@ -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() | |||
There was a problem hiding this comment.
this part was my first experiment based on the original infra/cmake module code, not longer used
| # FIXME: target_compile_definitions(beman.execution PUBLIC BEMAN_HAS_MODULES) | ||
| target_compile_definitions(${TARGET_PREFIX} PUBLIC BEMAN_HAS_MODULES) |
There was a problem hiding this comment.
here I have activated the using of the cxx_modules code in tests and examples
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.