From 50fd45995a336fd670bc44777f440cd4cbe67e33 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Tue, 5 Mar 2024 19:24:17 +0100 Subject: [PATCH] Add options to enable or disable installation of mujoco samples and simulate --- sample/CMakeLists.txt | 40 ++++++++++++++++++++++------------------ simulate/CMakeLists.txt | 30 +++++++++++++++++------------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index 660c85be52..6343b741f9 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -118,24 +118,28 @@ if(APPLE AND MUJOCO_BUILD_MACOS_FRAMEWORKS) set(_INSTALL_SAMPLES OFF) endif() -if(_INSTALL_SAMPLES) - - include(TargetAddRpath) - - # Add support to RPATH for the samples. - target_add_rpath( - TARGETS - basic - compile - record - testspeed - INSTALL_DIRECTORY - "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" - LIB_DIRS - "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" - DEPENDS - MUJOCO_ENABLE_RPATH - ) +option(MUJOCO_SAMPLES_INSTALL "If ON, also install samples executables." ${_INSTALL_SAMPLES}) + +if(MUJOCO_SAMPLES_INSTALL) + + if(MUJOCO_ENABLE_RPATH) + include(TargetAddRpath) + + # Add support to RPATH for the samples. + target_add_rpath( + TARGETS + basic + compile + record + testspeed + INSTALL_DIRECTORY + "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" + LIB_DIRS + "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" + DEPENDS + MUJOCO_ENABLE_RPATH + ) + endif() install( TARGETS basic diff --git a/simulate/CMakeLists.txt b/simulate/CMakeLists.txt index 4762100e07..504ec330a6 100644 --- a/simulate/CMakeLists.txt +++ b/simulate/CMakeLists.txt @@ -223,21 +223,25 @@ if(SIMULATE_BUILD_EXECUTABLE) set(_INSTALL_SIMULATE OFF) endif() - if(_INSTALL_SIMULATE) + option(MUJOCO_SIMULATE_INSTALL "If ON, also install simulate executable." ${_INSTALL_SIMULATE}) - include(TargetAddRpath) + if(MUJOCO_SIMULATE_INSTALL) - # Add support to RPATH for the samples. - target_add_rpath( - TARGETS - simulate - INSTALL_DIRECTORY - "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" - LIB_DIRS - "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" - DEPENDS - MUJOCO_ENABLE_RPATH - ) + if(MUJOCO_ENABLE_RPATH) + include(TargetAddRpath) + + # Add support to RPATH for the samples. + target_add_rpath( + TARGETS + simulate + INSTALL_DIRECTORY + "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" + LIB_DIRS + "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" + DEPENDS + MUJOCO_ENABLE_RPATH + ) + endif() install( TARGETS simulate