R-macos / recipes

System for building static dependent libraries for CRAN packages
44 stars 17 forks source link

Recipe for libsbml v5.20.2 #49

Closed Waschina closed 3 months ago

Waschina commented 10 months ago

The PR adds a recipe for libsbml.

libsbml is a library for handling text files in Systems Biology Markup Language (SBML). The library is a dependency of an R package (cobrar) that we have developed and are preparing to submit to CRAN.

The package is available for Linux build systems from the dnf and apt package managers. With this PR, I hope to make the libsbml dependency available on CRAN's MacOS build system as well.

Waschina commented 10 months ago

Just a brief explanation for the additional configure flags (-DENABLE_FBC=ON -DENABLE_GROUPS=ON):

These enable two optional extensions for the libsbml library, namely "fbc" and "groups". Both are relevant for the research community that uses linear programming to predict metabolic processes in living cells (i.e., flux balance analysis). apt and dnf linux builds also include these two extensions.

Thank you for considering the recipe.

s-u commented 10 months ago

@Waschina thanks, unfortunately this doesn't work, because the libsbml CMake is broken and doesn't honor -BUILD_SHARED_LIBS=OFF so I'll have to have look to see how it can be fixed. (There are more problems - it checks for expat but then uses xml2 instead).

FWIW your package doesn't work, either, because you are hard-coding flags which are incorrect - please consider using pkg-config to determine necessary flags for your dependent libraries if you want to publish it on CRAN.

Waschina commented 10 months ago

@Waschina thanks, unfortunately this doesn't work, because the libsbml CMake is broken and doesn't honor -BUILD_SHARED_LIBS=OFF so I'll have to have look to see how it can be fixed. (There are more problems - it checks for expat but then uses xml2 instead).

@s-u thank you! I modified the recipe in the way that it used the default XML toolkit libxml2 and not expat. Is there anything I can help with to fix the problem that libsbml's CMake build system does not honour -BUILD_SHARED_LIBS=OFF?

FWIW your package doesn't work, either, because you are hard-coding flags which are incorrect - please consider using pkg-config to determine necessary flags for your dependent libraries if you want to publish it on CRAN.

Thanks for the feedback! I updated the cobrar package so that a configure script creates the src/Makevars file with the correct flags.

Waschina commented 8 months ago

Hi @s-u I noticed that instead of the common BUILD_SHARED_LIB option, libSBML expects a different option: LIBSBML_SKIP_SHARED_LIBRARY. I made a pull request at the libsbml GitHub project, so it also respects the BUILD_SHARED_LIB. In the meanwhile, would it perhaps make sense to add -DLIBSBML_SKIP_SHARED_LIBRARY=ON to the configure flags of the recipe and thereby disable shared library build?

s-u commented 3 months ago

Thanks! I verified that this works and doesn't pull any additional deps. Technically, it checks for pkg-config, but it actually never uses it, so I didn't add to the deps.