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
  1. purpleKarrot commented at 5:10 PM on June 27, 2025: contributor

    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.

  2. 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.
    7106dce6fd
  3. real-or-random added the label bug on Jun 27, 2025
  4. real-or-random added the label build on Jun 27, 2025
  5. 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

  6. 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:

    $ cmake -B build
    $ cmake --build build
    $ install_dir=$(mktemp -d)
    $ cmake --install build --prefix $install_dir
    $ cat ${install_dir}/lib/pkgconfig/libsecp256k1.pc 
    prefix=/usr/local
    exec_prefix=${prefix}
    libdir=${exec_prefix}/lib
    includedir=${prefix}/include
    
    Name: libsecp256k1
    Description: Optimized C library for EC operations on curve secp256k1
    URL: https://github.com/bitcoin-core/secp256k1
    Version: 0.6.1
    Cflags: -I${includedir}
    Libs: -L${libdir} -lsecp256k1
    
    

    Note prefix=/usr/local, which is obviously incorrect.

  7. 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.

  8. real-or-random approved
  9. real-or-random commented at 6:12 AM on June 30, 2025: contributor

    ACK 7106dce6fd410043fc297139c6307cb6016d2a7b I verified that it fixes the path in libsecp256k1.pc

  10. real-or-random merged this on Jun 30, 2025
  11. real-or-random closed this on Jun 30, 2025

  12. purpleKarrot deleted the branch on Jun 30, 2025
  13. 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:
    $ cmake -B build -DCMAKE_INSTALL_PREFIX=../install/a
    $ cmake --build build
    $ cmake --install build
    $ cat ../install/a/lib/pkgconfig/libsecp256k1.pc | head -1
    prefix=/home/hebasto/dev/secp256k1/install/a
    
    • using the --prefix option during installation:
    $ cmake -B build
    $ cmake --build build
    $ cmake --install build --prefix ../install/b
    $ cat ../install/b/lib/pkgconfig/libsecp256k1.pc | head -1
    prefix=../install/b
    
  14. hebasto referenced this in commit 68094d6972 on Jun 30, 2025
  15. 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 of CMAKE_INSTALL_PREFIX is actually more correct than the argument to cmake --install.

  16. fanquake commented at 12:24 PM on July 16, 2025: member

    Reverted in #1694.

  17. Sjors referenced this in commit 1b7453ea88 on Jul 17, 2025
  18. hebasto referenced this in commit 28310efba4 on Jul 18, 2025
  19. fanquake referenced this in commit 5600e6fc4b on Jul 22, 2025
  20. fjahr referenced this in commit b6fc8c52d5 on Jul 24, 2025
  21. saikiran57 referenced this in commit abe11bd67c on Jul 28, 2025
  22. janus referenced this in commit e0ffd31e87 on Sep 14, 2025
  23. vmta referenced this in commit 2b25f561a0 on Sep 21, 2025
  24. real-or-random referenced this in commit a3733f33c1 on Feb 25, 2026
  25. github-actions[bot] referenced this in commit 758d4e90b4 on Mar 1, 2026
  26. github-actions[bot] referenced this in commit 68a2178f22 on Mar 1, 2026
  27. github-actions[bot] referenced this in commit a8bc1a0b2b on Mar 1, 2026
  28. 0x000000000019d6689c085ae165831e934ff76 referenced this in commit 3b9450150d on Mar 2, 2026
  29. csjones referenced this in commit a4d92824ae on Mar 2, 2026

github-metadata-mirror

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: 2026-05-19 06:52 UTC