Skip to content

Conversation

@Waschina
Copy link
Contributor

@Waschina Waschina commented Feb 19, 2024

Description

The CMake configuration does not respect the user option "-DBUILD_SHARED_LIB=<ON/OFF>". Package managers (and users) commonly use this main configuration option to decide whether to build the project as a shared or static library. Specifically, library build systems for dependencies of R-packages expect the BUILD_SHARED_LIB option: (Windows build system, MacOS build system).

Generally, the BUILD_SHARED_LIB variable directly affects the command add_library() if no type (SHARED or STATIC) is given to the function. Instead of BUILD_SHARED_LIB, libsbml's CMake setup seems to use the non-canonical options LIBSBML_SKIP_SHARED_LIBRARY and LIBSBML_SKIP_STATIC_LIBRARY:

https://github.com/sbmlteam/libsbml/blob/a3e217851f18d3c5e8e2b0082fb98176738491e8/src/CMakeLists.txt#L512C1-L513C2
https://github.com/sbmlteam/libsbml/blob/a3e217851f18d3c5e8e2b0082fb98176738491e8/src/CMakeLists.txt#L462C1-L464C2

Motivation and Context

Although I think the libsbml-specific shared/static build config options (LIBSBML_SKIP_<SHARED/STATIC>_LIBRARY) are totally fine, I would suggest enabling the widespread user option BUILD_SHARED_LIB as well, which would make libsbml also more accessible and easier to implement for developers of packages and toolchains.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Change in documentation

Checklist:

  • I have updated all documentation necessary.
  • I have checked spelling in (new) comments.

Testing

  • Testing is done automatically and codecov shows test coverage
  • This cannot be tested automatically
    I tested the new option manually using the CMake GUI in Windows. It worked as expected: Shared library build can be skipped with the new option "-DBUILD_SHARED_LIB=OFF".

@fbergmann fbergmann self-requested a review August 5, 2024 09:46
Copy link
Member

@fbergmann fbergmann left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, I agree we should honor the BUILD_SHARED_LIBS option if specified. But we should not set a default. I'll make slight changes so that

  • if BUILD_SHARED_LIBS is defined and TRUE, only the shared lib is built,
  • if it is defined and FALSE only the static one is built
  • if not defined the build behavior is the same as before (building both by default, or honoring LIBSBML_SKIP variables)

that should solve your issue, and not change the behavior for anyone else.

@fbergmann fbergmann merged commit b7b6bd2 into sbmlteam:development Aug 5, 2024
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