Skip to content

Add ability to customize Simbody in superbuild #3455

@adamkewley

Description

@adamkewley

I am currently on OpenSim Creator, which supplies its own 3D rendering backend and, for various dependency-shaped reasons, shouldn't package Simbody's visualizer.

The way I previously got around this problem is to (e.g. in OSC 0.4.1):

  • Make OSC point at a custom fork of opensim-core (here)
  • Have that custom fork contain a patch that disables building the visualizer (here)
  • Build OSC

This works, but requires maintaining a fork.

However, later, I also wanted to try building Simbody against OpenBLAS, so that I could nuke the build's dependency on libgcc_s and libgfortran. This requires setting -DBUILD_USING_OTHER_LAPACK on the Simbody build plus adding a patch to the patched fork. The main headache is that managing those patches/forks/submodules gets a bit cumbersome.

The solution that worked for me was to add a SIMBODY_EXTRA_CMAKE_ARGS argument to dependencies/CMakeLists.txt in opensim-core. This enables customizing simbody when building OpenSim.

I'll PR the patch, but it effectively enables writing buildscripts that (e.g.) customize parts of Simbody.

Example

Here is how one would custom-build OpenSim to statically-compile OpenBLAS into simbody, removing one link from the dependency chain:

# build custom statically-linkable OpenBLAS that does not depend on libgfortran
cmake \
    -S . \
    -B build \
    -DCMAKE_BUILD_TYPE=Release \
    -DC_LAPACK=ON \
    -DBUILD_STATIC_LIBS=ON \
    -G Ninja \
    -DCMAKE_INSTALL_PREFIX=install
cmake --build build/ --target install

# build opensim's dependencies with static linking
CXXFLAGS="-static-libgcc -static-libstdc++" cmake \
    -S dependencies/ \
    -B ../opensim-deps-build \
    -DSIMBODY_EXTRA_CMAKE_ARGS="-DBUILD_USING_OTHER_LAPACK:STRING=/home/adam/Desktop/OpenBLAS/install/lib/libopenblas.a" \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DCMAKE_INSTALL_PREFIX="opensim-deps-install" \
    -DOPENSIM_WITH_TROPTER=OFF \
    -DOPENSIM_WITH_CASADI=OFF
cmake --build ../opensim-deps-build/ -j16 -v

# build custom OpenSim fork with ability to customize simbody build
CXXFLAGS="-static-libgcc -static-libstdc++" cmake \
    -S . \
    -B ../opensim-build \
    -DOPENSIM_DEPENDENCIES_DIR=${PWD}/opensim-deps-install \
    -DBUILD_JAVA_WRAPPING=ON \
    -DCMAKE_BUILD_TYPE=Release \
    -DOPENSIM_WITH_TROPTER=OFF \
    -DOPENSIM_WITH_CASADI=OFF \
    -DCMAKE_INSTALL_PREFIX=/usr/local
sudo cmake --build ../opensim-build/ -j16 --target install

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions