Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add installation targets for libbarretenberg, wasm & headers #185

Merged
merged 5 commits into from
Mar 6, 2023

Conversation

phated
Copy link
Contributor

@phated phated commented Feb 24, 2023

Description

Closes #176

This adds install targets for libbarretenberg.a, barretenberg.wasm and all the headers. It uses an "interface library" to collect headers as the subdirectories call the barretenberg_module function. I couldn't come up with a better way to collect the headers for installation because they exist in the subdirectories (instead of something like an include/ directory where the public headers exist, such as https://github.com/google/benchmark/tree/main/include/benchmark), which means that we promote all header files instead of just public ones.

We should open a follow up issue to differentiate public from private headers.

With installation targets, we can now do cmake --install build --prefix "/usr/local" and it'll install like a normal C++ library.

I also added the INSTALL_BARRETENBERG option in emulation of googletest and benchmark because using FetchContent_MakeAvailable will add them as install targets. You can see how the BENCHMARK_ENABLE_INSTALL and INSTALL_GTEST are turned off now too.

This is the minimal setup we need to have installation targets, but many more improvements can be made so projects can consume this via other CMake builds, pkg-config, etc. These improvements are currently unnecessary for Noir to use barretenberg, but I can create follow up issues.

Checklist:

  • I have reviewed my diff in github, line by line.
  • Every change is related to the PR description.
  • I have linked this pull request to the issue(s) that it resolves.
  • There are no unexpected formatting changes, superfluous debug logs, or commented-out code.
  • There are no circuit changes, OR specifications in /markdown/specs have been updated.
  • There are no circuit changes, OR a cryptographer has been assigned for review.
  • I've updated any terraform that needs updating (e.g. environment variables) for deployment.
  • The branch has been rebased against the head of its merge target.
  • I'm happy for the PR to be merged at the reviewer's next convenience.
  • New functions, classes, etc. have been documented according to the doxygen comment format. Classes and structs must have @brief describing the intended functionality.
  • If existing code has been modified, such documentation has been added or updated.

@phated
Copy link
Contributor Author

phated commented Mar 6, 2023

I found a couple more things that needed to change to install all headers got installed:

  1. *.tcc files are included by headers
  2. We needed to collect the common headers

Copy link
Collaborator

@codygunton codygunton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Could you add something to the readme about how to install?

@phated phated force-pushed the phated/install-targets branch from 963e40e to f663ecd Compare March 6, 2023 16:56
@codygunton codygunton force-pushed the phated/install-targets branch from f663ecd to 80317d9 Compare March 6, 2023 19:35
@phated phated mentioned this pull request Mar 6, 2023
11 tasks
@codygunton codygunton merged commit f2fdebe into master Mar 6, 2023
@codygunton codygunton deleted the phated/install-targets branch March 6, 2023 20:13
INTERFACE
FILE_SET HEADERS
FILES ${HEADER_FILES}
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only necessary here because common is not a barretenberg_module?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct!

ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment explaining what this is doing (especially for EXPORT and each DESTINATION arg). I had to look it up and I'm sure others will too. Still not 100% sure I know what this command is doing after doing a bit of digging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do in a follow up PR.

ludamad pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jul 22, 2023
…ztecProtocol/barretenberg#185)

* feat: Add installation targets for libbarretenberg, wasm & headers

* chore: Disable installation targets for gtest & benchmark

* Collect tcc files for headers

* Collect common headers for install target

* chore(docs): Add installation section to README.
ludamad pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jul 24, 2023
…ztecProtocol/barretenberg#185)

* feat: Add installation targets for libbarretenberg, wasm & headers

* chore: Disable installation targets for gtest & benchmark

* Collect tcc files for headers

* Collect common headers for install target

* chore(docs): Add installation section to README.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should have install targets
3 participants