sbmlteam / libsbml

LibSBML is a native library for reading, writing and manipulating files and data streams containing the Systems Biology Markup Language (SBML). It offers language bindings for C, C++, C#, Java, JavaScript, MATLAB, Perl, PHP, Python, R and Ruby.
https://sbml.org/software/libsbml
Other
39 stars 28 forks source link

Enable CMake user option `BUILD_SHARED_LIB` #366

Closed Waschina closed 1 month ago

Waschina commented 7 months ago

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 (LIBSBMLSKIP<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

Checklist:

Testing