This is an archive of the discontinued LLVM Phabricator instance.

[cmake] Support custom package install paths
ClosedPublic

Authored by Ericson2314 on Jan 22 2022, 4:30 PM.

Details

Summary

Firstly, we we make an additional GNUInstallDirs-style variable. With
NixOS, for example, this is crucial as we want those to go in
${dev}/lib/cmake not ${out}/lib/cmake as that would a cmake subdir
of the "regular" libdir, which is installed even when no one needs to do
any development.

Secondly, we make *Config.cmake robust to absolute package install
paths. We for NixOS will in fact be passing them absolute paths to make
the ${dev} vs ${out} distinction mentioned above, and the
GNUInstallDirs-style variables are suposed to support absolute paths in
general so it's good practice besides the NixOS use-case.

Thirdly, we make ${project}_INSTALL_PACKAGE_DIR CACHE PATHs like other
install dirs are.

Diff Detail

Event Timeline

Ericson2314 created this revision.Jan 22 2022, 4:30 PM
Herald added a project: Restricted Project. · View Herald Transcript
Ericson2314 requested review of this revision.Jan 22 2022, 4:30 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptJan 22 2022, 4:30 PM

Could one of you review this?

Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2022, 11:07 PM
Herald added a subscriber: bzcheeseman. · View Herald Transcript
This comment was removed by Ericson2314.
Ericson2314 edited the summary of this revision. (Show Details)Jul 21 2022, 12:29 PM
Ericson2314 edited the summary of this revision. (Show Details)Jul 21 2022, 12:34 PM
  • Rebase
  • Some set -> extend_path
  • Fix spelling / comments

@nikic if you are still around, might you want to review this?

Two comments inline, apart from that it looks good to me.

cmake/Modules/FindPrefixFromConfig.cmake
30

Shouldn’t this set config_code instead of prefix_var, which is the output variable in the generated code?

32

This could use a comment to why it ignores path_to_leave and why CMAKE_INSTALL_PREFIX is the correct choice.

Fix bug, and add comments to both branches for clarity

Ericson2314 marked 2 inline comments as done.Jul 25 2022, 8:57 AM
Ericson2314 added inline comments.
cmake/Modules/FindPrefixFromConfig.cmake
30

Yes! Silly mistake me cleaning the code up for upstreaming but not yet testing it with our configuration again. Thanks for noticing.

32

Added comments to both branches.

sebastian-ne accepted this revision.Jul 25 2022, 9:08 AM

Thank you, the comments make it clearer what’s happening. LGTM

This revision is now accepted and ready to land.Jul 25 2022, 9:08 AM
This revision was landed with ongoing or failed builds.Jul 25 2022, 2:03 PM
This revision was automatically updated to reflect the committed changes.
Ericson2314 marked 2 inline comments as done.

I found a regression when llvm is added with CMake’s add_subdirectory. D130555 has a fix.