Skip to content
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

Address relocatable package installs and usage of <Package>Config.cmake files #563

Open
bartlettroscoe opened this issue Feb 21, 2023 · 0 comments

Comments

@bartlettroscoe
Copy link
Member

bartlettroscoe commented Feb 21, 2023

Parent Issue:

Description

As mentioned in #63 (comment) and discussed in more detail in CMake Issue #24378 there is a problem with building, packaging, and installing from a binary package, and then downstream CMake projects using the installed CMake packages using find_package(<Package>). The problem is that the <Package>Config.cmake files will not easily know where to find their upstream dependencies.

Proposed implementation

The proposed solution to this problem discussed in CMake Issue #24378 comment is outlined below:

  • Add new var <Project>_SUPER_INSTALL_PREFIX (in addition to <Project>_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR as they have different purposes) ...

  • Have TriBITS-generated <Package>Config.cmake files use set(<ExternalPackage>_DIR "???") and find_dependency(<ExternalPackage>) (where <ExternalPackage>_DIR is either set to a relative or absolute path as described below).

  • Add new var <ExternalPackage>_USE_RELATIVE_PATH:

    • If <ExternalPackage>_USE_RELATIVE_PATH is empty, then set to TRUE if <ExternalPackage>_DIR returned from find_package(<ExternalPackage>) (or <Package>_TRIBITS_COMPLIANT_PACKAGE_CONFIG_FILE_DIR if <ExternalPackage>_DIR is not set) is a subdir of <Project>_SUPER_INSTALL_PREFIX

    • If <ExternalPackage>_USE_RELATIVE_PATH is TRUE, then use a relative path from the TriBITS-generated installed <Package>Config.cmake file to <ExternalPackage>_DIR (or <Package>_TRIBITS_COMPLIANT_PACKAGE_CONFIG_FILE_DIR if <ExternalPackage>_DIR is not set)

    • If <ExternalPackage>_USE_RELATIVE_PATH is FALSE, then use the absolute path to <ExternalPackage>_DIR (or <Package>_TRIBITS_COMPLIANT_PACKAGE_CONFIG_FILE_DIR if <ExternalPackage>_DIR is not set)

  • Change TriBITS-generated <Package>Config.cmake files to call find_dependency(<ExternalPackage> CONFIG REQUIRED) on all upstream dependencies and find a way for that to not interfere with inner find_dependency(<ExternalPackage) calls that find non-TriBITS-compliant external packages. (Idea: pass in TRIBITS_COMPLIANT as the version to find_package() or find_dependency() and make the TriBITS-generated <ExternalPackage>ConfigVersion.cmake file look for that instead of the current hack based on the variable TRIBITS_FINDING_RAW_<tplName>_PACKAGE_FIRST.)

The above proposed implementation would solve the Spack binary install use case by setting <Project>_SUPER_INSTALL_PREFIX to the base Spack package install dir and then all paths would be relative to that directory as well.

NOTE: We would have to also make all library paths relative as well according to the above process (i.e. based on the values of <ExternalPackage>_USE_RELATIVE_PATH and <Project>_SUPER_INSTALL_PREFIX).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Selected
Development

No branches or pull requests

1 participant