Skip to content

Commit

Permalink
Merge bitcoin-core/secp256k1#1422: cmake: Install libsecp256k1.pc file
Browse files Browse the repository at this point in the history
421d848 ci: Align Autotools/CMake `CI_INSTALL` directory names (Hennadii Stepanov)
9f005c6 cmake: Install `libsecp256k1.pc` file (Hennadii Stepanov)

Pull request description:

  This PR allows downstream projects to use pkg-config to search for the libsecp256k1 library that is built with CMake.

  Addressed bitcoin-core/secp256k1#1419 (comment):
  > We could just ship the pkg-config file also in CMake builds.

ACKs for top commit:
  real-or-random:
    ACK bitcoin-core/secp256k1@421d848 I compared the generated pc files and they match in autotools and CMake

Tree-SHA512: 8e54eb7c76bc727ab18715258c06cc2a419c6c04892a2bd7bfe34392f9a3223f673ff84d2d21b00b3c222b357f02296ec49c872532d98ea0a2f17ef1ed6b6ac1
  • Loading branch information
real-or-random committed Sep 12, 2023
2 parents b10ddd2 + 421d848 commit 4fd00f4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ jobs:

- name: Check installation with Autotools
env:
CI_INSTALL: ${{ runner.temp }}/${{ github.run_id }}${{ github.action }}
CI_INSTALL: ${{ runner.temp }}/${{ github.run_id }}${{ github.action }}/install
run: |
./autogen.sh && ./configure --prefix=${{ env.CI_INSTALL }} && make clean && make install && ls -RlAh ${{ env.CI_INSTALL }}
gcc -o ecdsa examples/ecdsa.c $(PKG_CONFIG_PATH=${{ env.CI_INSTALL }}/lib/pkgconfig pkg-config --cflags --libs libsecp256k1) -Wl,-rpath,"${{ env.CI_INSTALL }}/lib" && ./ecdsa
Expand Down
8 changes: 8 additions & 0 deletions cmake/GeneratePkgConfigFile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function(generate_pkg_config_file in_file)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix \${prefix})
set(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR})
set(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR})
set(PACKAGE_VERSION ${PROJECT_VERSION})
configure_file(${in_file} ${PROJECT_NAME}.pc @ONLY)
endfunction()
10 changes: 9 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,13 @@ if(SECP256K1_INSTALL)
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
)

include(GeneratePkgConfigFile)
generate_pkg_config_file(${PROJECT_SOURCE_DIR}/libsecp256k1.pc.in)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif()

0 comments on commit 4fd00f4

Please sign in to comment.