-
Notifications
You must be signed in to change notification settings - Fork 17
Feature/fix build without modules #208
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
Draft
ClausKlein
wants to merge
3
commits into
bemanproject:mk-module
Choose a base branch
from
ClausKlein:feature/fix-build-without-modules
base: mk-module
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,202 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| include_guard(GLOBAL) | ||
|
|
||
| # This file defines the function `beman_install_library` which is used to | ||
| # install a library target and its headers, along with optional CMake | ||
| # configuration files. | ||
| # | ||
| # The function is designed to be reusable across different Beman libraries. | ||
|
|
||
| function(beman_install_library name interface) | ||
| # Usage | ||
| # ----- | ||
| # | ||
| # beman_install_library(NAME INTERFACE) | ||
| # | ||
| # Brief | ||
| # ----- | ||
| # | ||
| # This function installs the specified library target and its headers. | ||
| # It also handles the installation of the CMake configuration files if needed. | ||
| # | ||
| # CMake variables | ||
| # --------------- | ||
| # | ||
| # Note that configuration of the installation is generally controlled by CMake | ||
| # cache variables so that they can be controlled by the user or tool running the | ||
| # `cmake` command. Neither `CMakeLists.txt` nor `*.cmake` files should set these | ||
| # variables directly. | ||
| # | ||
| # - BEMAN_INSTALL_CONFIG_FILE_PACKAGES: | ||
| # List of packages that require config file installation. | ||
| # If the package name is in this list, it will install the config file. | ||
| # | ||
| # - <PREFIX>_INSTALL_CONFIG_FILE_PACKAGE: | ||
| # Boolean to control config file installation for the specific library. | ||
| # The prefix `<PREFIX>` is the uppercased name of the library with dots | ||
| # replaced by underscores. | ||
| # | ||
| # if(NOT TARGET "${name}") | ||
| # message(FATAL_ERROR "Target '${name}' does not exist.") | ||
| # endif() | ||
|
|
||
| # if(NOT ARGN STREQUAL "") | ||
| # message( | ||
| # FATAL_ERROR | ||
| # "beman_install_library does not accept extra arguments: ${ARGN}" | ||
| # ) | ||
| # endif() | ||
|
|
||
| # XXX Given foo.bar, the component name is bar | ||
| # string(REPLACE "." ";" name_parts "${name}") | ||
| # XXX fail if the name doesn't look like foo.bar | ||
| # list(LENGTH name_parts name_parts_length) | ||
| # if(NOT name_parts_length EQUAL 2) | ||
| # message( | ||
| # FATAL_ERROR | ||
| # "beman_install_library expects a name of the form 'beman.<name>', got '${name}'" | ||
| # ) | ||
| # endif() | ||
|
|
||
| string(REPLACE "beman_" "" name_parts "${name}") | ||
| set(component_name ${name_parts}) | ||
|
|
||
| set(target_name "${name}") | ||
|
|
||
| # COMPONENT <component> | ||
| # Specify an installation component name with which the install rule is associated, | ||
| # such as Runtime or Development. | ||
| set(install_component_name "${name}") # TODO(CK): this is not common name! | ||
|
|
||
| set(export_name "${name}") | ||
| set(package_name "${name}") | ||
| # XXX list(GET name_parts -1 component_name) | ||
|
|
||
| set(target_list) | ||
| if(TARGET "${target_name}") | ||
| set_target_properties( | ||
| "${target_name}" | ||
| PROPERTIES EXPORT_NAME "${component_name}" | ||
| ) | ||
| message( | ||
| VERBOSE | ||
| "beman-install-library: COMPONENT ${component_name} for TARGET '${target_name}'" | ||
| ) | ||
| list(APPEND target_list "${target_name}") | ||
| endif() | ||
|
|
||
| if(interface AND TARGET "${target_name}_${interface}") | ||
| set_target_properties( | ||
| "${target_name}_${interface}" | ||
| PROPERTIES EXPORT_NAME "${component_name}_${interface}" | ||
| ) | ||
| message( | ||
| VERBOSE | ||
| "beman-install-library: COMPONENT ${component_name}_${interface} for TARGET '${name}_${interface}'" | ||
| ) | ||
| list(APPEND target_list "${target_name}_${interface}") | ||
| endif() | ||
|
|
||
| include(GNUInstallDirs) | ||
|
|
||
| install( | ||
| TARGETS ${target_list} | ||
| COMPONENT "${install_component_name}" | ||
| EXPORT "${export_name}" | ||
| FILE_SET HEADERS | ||
| FILE_SET CXX_MODULES | ||
| DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${package_name}/modules | ||
| ) | ||
|
|
||
| # Determine the prefix for project-specific variables | ||
| string(TOUPPER "${name}" project_prefix) | ||
| # XXX string(REPLACE "." "_" project_prefix "${project_prefix}") | ||
|
|
||
| option( | ||
| ${project_prefix}_INSTALL_CONFIG_FILE_PACKAGE | ||
| "Enable creating and installing a CMake config-file package. Default: ON. Values: { ON, OFF }." | ||
| ON | ||
| ) | ||
|
|
||
| # By default, install the config package | ||
| set(install_config_package ON) | ||
|
|
||
| # Turn OFF installation of config package by default if, | ||
| # in order of precedence: | ||
| # 1. The specific package variable is set to OFF | ||
| # 2. The package name is not in the list of packages to install config files | ||
| if(DEFINED BEMAN_INSTALL_CONFIG_FILE_PACKAGES) | ||
| if( | ||
| NOT "${install_component_name}" | ||
| IN_LIST | ||
| BEMAN_INSTALL_CONFIG_FILE_PACKAGES | ||
| ) | ||
| set(install_config_package OFF) | ||
| endif() | ||
| endif() | ||
| if(DEFINED ${project_prefix}_INSTALL_CONFIG_FILE_PACKAGE) | ||
| set(install_config_package | ||
| ${${project_prefix}_INSTALL_CONFIG_FILE_PACKAGE} | ||
| ) | ||
| endif() | ||
|
|
||
| if(install_config_package) | ||
| message( | ||
| VERBOSE | ||
| "beman-install-library: Installing a config package for '${name}'" | ||
| ) | ||
|
|
||
| include(CMakePackageConfigHelpers) | ||
|
|
||
| find_file( | ||
| config_file_template | ||
| NAMES "${package_name}-config.cmake.in" | ||
| PATHS "${PROJECT_SOURCE_DIR}/cmake" | ||
| NO_DEFAULT_PATH | ||
| NO_CACHE | ||
| REQUIRED | ||
| ) | ||
| set(config_package_file | ||
| "${CMAKE_CURRENT_BINARY_DIR}/${package_name}-config.cmake" | ||
| ) | ||
| set(package_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${package_name}") | ||
| configure_package_config_file( | ||
| "${config_file_template}" | ||
| "${config_package_file}" | ||
| INSTALL_DESTINATION "${package_install_dir}" | ||
| PATH_VARS PROJECT_NAME PROJECT_VERSION | ||
| ) | ||
|
|
||
| set(config_version_file | ||
| "${CMAKE_CURRENT_BINARY_DIR}/${package_name}-config-version.cmake" | ||
| ) | ||
| write_basic_package_version_file( | ||
| "${config_version_file}" | ||
| VERSION "${PROJECT_VERSION}" | ||
| COMPATIBILITY ExactVersion | ||
| ) | ||
|
|
||
| install( | ||
| FILES "${config_package_file}" "${config_version_file}" | ||
| DESTINATION "${package_install_dir}" | ||
| COMPONENT "${install_component_name}" | ||
| ) | ||
|
|
||
| # NOTE: must be same value as ${TARGETS_EXPORT_NAME}.cmake! CK | ||
| set(config_targets_file "${package_name}-targets.cmake") | ||
| install( | ||
| EXPORT "${export_name}" | ||
| DESTINATION "${package_install_dir}" | ||
| NAMESPACE beman:: | ||
| FILE "${config_targets_file}" | ||
| CXX_MODULES_DIRECTORY | ||
| cxx-modules | ||
| COMPONENT "${install_component_name}" | ||
| ) | ||
| else() | ||
| message( | ||
| WARNING | ||
| "beman-install-library: Not installing a config package for '${name}'" | ||
| ) | ||
| endif() | ||
| endfunction() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # cmake/Config.cmake.in -*-makefile-*- | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| @PACKAGE_INIT@ | ||
|
|
||
| include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
| check_required_components("@TARGET_LIBRARY@") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@ednolan my quick and dirty hack to install the module library and the interface library