Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to customize Simbody in superbuild #3455

Closed
adamkewley opened this issue May 22, 2023 · 2 comments
Closed

Add ability to customize Simbody in superbuild #3455

adamkewley opened this issue May 22, 2023 · 2 comments
Assignees

Comments

@adamkewley
Copy link
Contributor

adamkewley commented May 22, 2023

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
@adamkewley
Copy link
Contributor Author

An example of using the flag in a downstream build is in OSC's third_party/CMakeLists.txt:

@adamkewley adamkewley self-assigned this May 22, 2023
adamkewley added a commit that referenced this issue May 24, 2023
Added SIMBODY_EXTRA_CMAKE_ARGS to dependencies/ (#3455)
@nickbianco
Copy link
Member

@adamkewley, is this good to close?

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

No branches or pull requests

2 participants