Skip to content

Allow static library builds via BUILD_SHARED_LIBS#314

Merged
spe-ciellt merged 1 commit intogerbv:developfrom
SourceParts:fix/static-library-build
Mar 3, 2026
Merged

Allow static library builds via BUILD_SHARED_LIBS#314
spe-ciellt merged 1 commit intogerbv:developfrom
SourceParts:fix/static-library-build

Conversation

@rampageservices
Copy link
Copy Markdown
Contributor

@rampageservices rampageservices commented Mar 1, 2026

Summary

  • Remove explicit SHARED keyword from add_library(gerbv) in src/CMakeLists.txt
  • CMake's built-in BUILD_SHARED_LIBS variable now controls the library type
  • Default behavior is unchanged (shared library)
  • Users can pass -DBUILD_SHARED_LIBS=OFF for static builds

Details

This is the standard CMake idiom for letting users choose between shared and static libraries. The name-clash concern raised in #272 is already solved — the app target is gerbv-app (with OUTPUT_NAME gerbv), and the library target is gerbv, so there's no conflict regardless of library type.

Usage

cmake -B build                          # Default: shared (unchanged)
cmake -B build -DBUILD_SHARED_LIBS=OFF  # Static: produces libgerbv.a

Test plan

  • Default build still produces shared library (libgerbv.so)
  • -DBUILD_SHARED_LIBS=OFF produces static library (libgerbv.a)
  • Application links correctly against both shared and static library
  • Existing tests pass

Closes #272

Remove the explicit SHARED keyword from add_library(gerbv) so that
CMake's BUILD_SHARED_LIBS variable controls the library type. Default
behavior is unchanged (shared), but users can now pass
-DBUILD_SHARED_LIBS=OFF to build libgerbv as a static library.

Closes gerbv#272
@spe-ciellt
Copy link
Copy Markdown
Contributor

Great thing, simple enough. Merging.

@spe-ciellt spe-ciellt merged commit e3b6597 into gerbv:develop Mar 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

buildsystem Updates to the buildsystem (CMake/CTest/CPack)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to build libgerbv as static library?

2 participants