From 8cfc9d1dde5ae0b3263ffea6a8afbe162759f9ca Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Tue, 7 Mar 2023 11:22:36 -0700 Subject: [PATCH] feat: Add pkgconfig output for installed target (https://github.com/AztecProtocol/barretenberg/pull/208) * feat: Add pkgconfig output for installed target * fix: Specify version with the project function * chore: Add documentation to install targets --- circuits/cpp/barretenberg/cpp/CMakeLists.txt | 8 +++++--- .../barretenberg/cpp/cmake/barretenberg.pc.in | 12 +++++++++++ .../barretenberg/cpp/src/aztec/CMakeLists.txt | 20 +++++++++++++++++++ .../cpp/src/aztec/common/CMakeLists.txt | 2 ++ 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 circuits/cpp/barretenberg/cpp/cmake/barretenberg.pc.in diff --git a/circuits/cpp/barretenberg/cpp/CMakeLists.txt b/circuits/cpp/barretenberg/cpp/CMakeLists.txt index bff44b7bbf9..5cc744d9eda 100644 --- a/circuits/cpp/barretenberg/cpp/CMakeLists.txt +++ b/circuits/cpp/barretenberg/cpp/CMakeLists.txt @@ -3,10 +3,12 @@ cmake_minimum_required(VERSION 3.24) -set(PROJECT_VERSION 0.1.0) -project(Barretenberg +project( + Barretenberg DESCRIPTION "BN254 elliptic curve library, and PLONK SNARK prover" - LANGUAGES CXX C) + VERSION 0.1.0 + LANGUAGES CXX C +) option(DISABLE_ASM "Disable custom assembly" OFF) option(DISABLE_ADX "Disable ADX assembly variant" OFF) diff --git a/circuits/cpp/barretenberg/cpp/cmake/barretenberg.pc.in b/circuits/cpp/barretenberg/cpp/cmake/barretenberg.pc.in new file mode 100644 index 00000000000..6aecb0c9ad7 --- /dev/null +++ b/circuits/cpp/barretenberg/cpp/cmake/barretenberg.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ +Description: Optimized elliptic curve library for the bn128 curve, and PLONK SNARK prover +Version: @PROJECT_VERSION@ + +Libs: -L${libdir} +Libs.private: -lomp +Cflags: -I${includedir} diff --git a/circuits/cpp/barretenberg/cpp/src/aztec/CMakeLists.txt b/circuits/cpp/barretenberg/cpp/src/aztec/CMakeLists.txt index 301be6ab139..98a1e1a1586 100644 --- a/circuits/cpp/barretenberg/cpp/src/aztec/CMakeLists.txt +++ b/circuits/cpp/barretenberg/cpp/src/aztec/CMakeLists.txt @@ -168,11 +168,31 @@ else() ) if(INSTALL_BARRETENBERG) + # The `install` function takes targets to install in different destinations on the system. install( TARGETS barretenberg barretenberg_headers + # We also give it an optional export name in case something wants to target the install. EXPORT barretenbergTargets + # The ARCHIVE output signifies static libraries that should be installed + # and we use the GNUInstallDirs location to install into the standard system library location ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + # The FILE_SET output is used instead of PUBLIC_HEADER & PRIVATE_HEADER outputs because + # our headers don't have a clear delineation between public & private, but we still use + # the GNUInstallDirs location to install into the standard system header location FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) + + set(pkg_config "${PROJECT_BINARY_DIR}/barretenberg.pc") + + configure_file( + "${PROJECT_SOURCE_DIR}/cmake/barretenberg.pc.in" + "${pkg_config}" + @ONLY + ) + + install( + FILES "${pkg_config}" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" + ) endif() endif() diff --git a/circuits/cpp/barretenberg/cpp/src/aztec/common/CMakeLists.txt b/circuits/cpp/barretenberg/cpp/src/aztec/common/CMakeLists.txt index 4f815063ff4..612adc04b0f 100644 --- a/circuits/cpp/barretenberg/cpp/src/aztec/common/CMakeLists.txt +++ b/circuits/cpp/barretenberg/cpp/src/aztec/common/CMakeLists.txt @@ -1,4 +1,6 @@ # Collect our common/*.hpp files and include in installation +# This is only necessary because nothing in `common/` has an +# implementation and doesn't use the `barretenberg_module` function file(GLOB_RECURSE HEADER_FILES *.hpp) target_sources( barretenberg_headers