Skip to content

Support CMake's BUILD_SHARED_LIBS flag - #80

Open
orlitzky wants to merge 1 commit into
pine64:masterfrom
orlitzky:build-shared-libs
Open

Support CMake's BUILD_SHARED_LIBS flag#80
orlitzky wants to merge 1 commit into
pine64:masterfrom
orlitzky:build-shared-libs

Conversation

@orlitzky

@orlitzky orlitzky commented Sep 7, 2026

Copy link
Copy Markdown

Currently both shared and static libraries are built via duplicate calls to add_library(), set_target_properties(), target_link_libraries(), etc. Typically only one of these is desired, and CMake provides a BUILD_SHARED_LIBS variable to control it.

We noticed this on Gentoo where BUILD_SHARED_LIBS=ON is passed by default, but static libraries were still installed.

This commit removes the explicit static libraries, and then removes the explicit "SHARED" from the remaining add_library(). The end result is that one type of library is installed, and it is controlled by the BUILD_SHARED_LIBS flag.

To build static libraries rather than shared ones, you would now use cmake -DBUILD_SHARED_LIBS=OFF .... A little more annoying if you want static libs, but it is the standard way of doing it.

Currently both shared and static libraries are built via duplicate
calls to add_library, set_target_properties, target_link_libraries,
etc. Typically only one of these is desired, and CMake provides a
variable to control it:

  https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

This commit removes the explicit static libraries, and then removes
the explicit "SHARED" from the remaining add_library(). The end result
is that one type of library is installed, and it is controlled by the
BUILD_SHARED_LIBS flag.

Gentoo-bug: https://bugs.gentoo.org/982096
@robertlipe

Copy link
Copy Markdown
Collaborator

Please investigate and correct the build failures so this can be considered or withdraw it back to draft status until you can do so.

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.

2 participants