Page MenuHomePhabricator

[cmake] Support custom package install paths

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



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

Unit TestsFailed

60,080 msx64 debian > Clang.Driver::emit-reproducer.c
Script: -- : 'RUN: at line 1'; rm -rf /var/lib/buildkite-agent/builds/llvm-project/build/tools/clang/test/Driver/Output/emit-reproducer.c.tmp && mkdir /var/lib/buildkite-agent/builds/llvm-project/build/tools/clang/test/Driver/Output/emit-reproducer.c.tmp
60,690 msx64 debian > Clang.Driver::fsanitize.c
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/bin/clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-trap=undefined /var/lib/buildkite-agent/builds/llvm-project/clang/test/Driver/fsanitize.c -### 2>&1 | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck /var/lib/buildkite-agent/builds/llvm-project/clang/test/Driver/fsanitize.c --check-prefix=CHECK-UNDEFINED-TRAP
1,480 msx64 debian > libFuzzer.libFuzzer::fuzzer-finalstats.test
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/var/lib/buildkite-agent/builds/llvm-project/compiler-rt/lib/fuzzer -m64 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/fuzzer/SimpleTest.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/fuzzer/X86_64DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest

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)Thu, Jul 21, 12:29 PM
Ericson2314 edited the summary of this revision. (Show Details)Thu, Jul 21, 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.


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


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.Mon, Jul 25, 8:57 AM
Ericson2314 added inline comments.

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


Added comments to both branches.

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

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

This revision is now accepted and ready to land.Mon, Jul 25, 9:08 AM
This revision was landed with ongoing or failed builds.Mon, Jul 25, 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.