Skip to content

Add granular CMake targets with BUILD_SHARED_LIBS support#166

Open
afrind wants to merge 1 commit intofacebookincubator:mainfrom
afrind:export-D91009035
Open

Add granular CMake targets with BUILD_SHARED_LIBS support#166
afrind wants to merge 1 commit intofacebookincubator:mainfrom
afrind:export-D91009035

Conversation

@afrind
Copy link
Contributor

@afrind afrind commented Jan 22, 2026

Summary:
This adds granular CMake targets to fizz, similar to folly's granular targets.
Each fizz library (e.g., fizz_crypto_hkdf, fizz_protocol_certificate) can now
be linked individually, reducing binary sizes for applications that only need
specific functionality.

Key changes:

  • Added FizzFunctions.cmake with fizz_add_library() function that:

    • Creates OBJECT libraries (compiled once, used for both granular and monolithic)
    • Creates STATIC libraries for individual linking (static builds)
    • Creates INTERFACE libraries linking to monolithic fizz (shared builds)
    • Handles deferred dependency resolution for internal fizz deps
    • Links Folly::folly and optional deps (OQS, aegis) in shared builds
  • Added granular CMakeLists.txt for each subdirectory, generated from BUCK
    files using generate_cmake.py. Manually maintained for:

    • backend/ (conditional libaegis/liboqs logic)
    • compression/ (conditional brotli logic)
  • Added generate_cmake.py to auto-generate CMakeLists.txt from BUCK files

  • Added lint_cmake_sync.py for arc lint integration

Build behavior:

  • BUILD_SHARED_LIBS=OFF: Creates individual .a files + monolithic libfizz.a
  • BUILD_SHARED_LIBS=ON: Creates INTERFACE targets linking to libfizz.so

Differential Revision: D91009035

@meta-cla meta-cla bot added the CLA Signed label Jan 22, 2026
@meta-codesync
Copy link

meta-codesync bot commented Jan 22, 2026

@afrind has exported this pull request. If you are a Meta employee, you can view the originating Diff in D91009035.

…cubator#166)

Summary:

This adds granular CMake targets to fizz, similar to folly's granular targets.
Each fizz library (e.g., fizz_crypto_hkdf, fizz_protocol_certificate) can now
be linked individually, reducing binary sizes for applications that only need
specific functionality.

Key changes:
- Added FizzFunctions.cmake with fizz_add_library() function that:
  - Creates OBJECT libraries (compiled once, used for both granular and monolithic)
  - Creates STATIC libraries for individual linking (static builds)
  - Creates INTERFACE libraries linking to monolithic fizz (shared builds)
  - Handles deferred dependency resolution for internal fizz deps
  - Links Folly::folly and optional deps (OQS, aegis) in shared builds

- Added granular CMakeLists.txt for each subdirectory, generated from BUCK
  files using generate_cmake.py. Manually maintained for:
  - backend/ (conditional libaegis/liboqs logic)
  - compression/ (conditional brotli logic)

- Added generate_cmake.py to auto-generate CMakeLists.txt from BUCK files
- Added lint_cmake_sync.py for arc lint integration

Build behavior:
- BUILD_SHARED_LIBS=OFF: Creates individual .a files + monolithic libfizz.a
- BUILD_SHARED_LIBS=ON: Creates INTERFACE targets linking to libfizz.so

Differential Revision: D91009035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant