CMAKE_INSTALL_PREFIX
that the project was configured with.
cmake: configure libsecp256k1.pc during install #1692
pull purpleKarrot wants to merge 1 commits into bitcoin-core:master from purpleKarrot:pkgconf-install-prefix changing 1 files +6 −2-
purpleKarrot commented at 5:10 pm on June 27, 2025: contributorWhen installing to a given prefix, make sure that the .pc file contains that prefix rather than the value of
-
cmake: configure libsecp256k1.pc during install
When installing to a given prefix, make sure that the .pc file contains that prefix rather than the value of CMAKE_INSTALL_PREFIX that the project was configured with.
-
real-or-random added the label bug on Jun 27, 2025
-
real-or-random added the label build on Jun 27, 2025
-
real-or-random commented at 6:29 pm on June 27, 2025: contributor
Thanks! Can you provide instructions for a test case that is fixed by this?
cc @hebasto
-
hebasto commented at 7:45 pm on June 27, 2025: member
cc @hebasto
I haven’t tested this PR yet, but the issue I reported to @purpleKarrot offline can be reproduced on the master branch as follows:
0$ cmake -B build 1$ cmake --build build 2$ install_dir=$(mktemp -d) 3$ cmake --install build --prefix $install_dir 4$ cat ${install_dir}/lib/pkgconfig/libsecp256k1.pc 5prefix=/usr/local 6exec_prefix=${prefix} 7libdir=${exec_prefix}/lib 8includedir=${prefix}/include 9 10Name: libsecp256k1 11Description: Optimized C library for EC operations on curve secp256k1 12URL: https://github.com/bitcoin-core/secp256k1 13Version: 0.6.1 14Cflags: -I${includedir} 15Libs: -L${libdir} -lsecp256k1
Note
prefix=/usr/local
, which is obviously incorrect. -
purpleKarrot commented at 8:47 pm on June 27, 2025: contributor
What @hebasto wrote.
Also, when testing this, try installing as
root
and then verify whether you can delete the build directory with non-root
permission. Also, try installing twice in a row and verify that the second install does not modify the timestamp of the file. -
real-or-random approved
-
real-or-random commented at 6:12 am on June 30, 2025: contributorACK 7106dce6fd410043fc297139c6307cb6016d2a7b I verified that it fixes the path in libsecp256k1.pc
-
real-or-random merged this on Jun 30, 2025
-
real-or-random closed this on Jun 30, 2025
-
purpleKarrot deleted the branch on Jun 30, 2025
-
hebasto commented at 12:20 pm on June 30, 2025: member
While working on this issue earlier, I also considered support for relative paths.
I’m not sure how important this case is, but the current solution does not handle relative paths correctly. Consider the following examples:
- using
CMAKE_INSTALL_PREFIX
during configuration:
0$ cmake -B build -DCMAKE_INSTALL_PREFIX=../install/a 1$ cmake --build build 2$ cmake --install build 3$ cat ../install/a/lib/pkgconfig/libsecp256k1.pc | head -1 4prefix=/home/hebasto/dev/secp256k1/install/a
- using the
--prefix
option during installation:
0$ cmake -B build 1$ cmake --build build 2$ cmake --install build --prefix ../install/b 3$ cat ../install/b/lib/pkgconfig/libsecp256k1.pc | head -1 4prefix=../install/b
- using
-
hebasto referenced this in commit 68094d6972 on Jun 30, 2025
-
purpleKarrot commented at 2:47 pm on June 30, 2025: contributor@real-or-random, what @hebasto shows is a severe regression for the use case of creating packages. When building binary packages for distribution, you usually install to a temporary directory and then create a tarball of that directory. Since pkg-config does not support relocatable packages, the
.pc
file needs to contain the location where the tarball will be extracted to, not the location that cmake installs to. The builtin default of/usr/local
or the value ofCMAKE_INSTALL_PREFIX
is actually more correct than the argument tocmake --install
. -
josibake referenced this in commit bb0dc6d75c on Jul 10, 2025
-
josibake referenced this in commit 90b6c9e668 on Jul 11, 2025
-
josibake referenced this in commit 4340be2236 on Jul 14, 2025
-
josibake referenced this in commit 3a3815d5ee on Jul 16, 2025
This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-07-31 06:15 UTC
More mirrored repositories can be found on mirror.b10c.me