Skip to content

Commit

Permalink
feat: Add pkgconfig output for installed target (AztecProtocol/barret…
Browse files Browse the repository at this point in the history
…enberg#208)

* feat: Add pkgconfig output for installed target

* fix: Specify version with the project function

* chore: Add documentation to install targets
  • Loading branch information
phated authored Mar 7, 2023
1 parent 400a35b commit 8cfc9d1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
8 changes: 5 additions & 3 deletions circuits/cpp/barretenberg/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions circuits/cpp/barretenberg/cpp/cmake/barretenberg.pc.in
Original file line number Diff line number Diff line change
@@ -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}
20 changes: 20 additions & 0 deletions circuits/cpp/barretenberg/cpp/src/aztec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 2 additions & 0 deletions circuits/cpp/barretenberg/cpp/src/aztec/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 8cfc9d1

Please sign in to comment.