Fix documentation typos and CMake framework setup for macOS.

The previous commit missed out some recent changes in the internal repo. This commit brings the public GitHub repo in sync.

PiperOrigin-RevId: 450377010
Change-Id: I59a68ae4a39c5cd5ed5f7df77ba870273243d623
This commit is contained in:
Saran Tunyasuvunakool
2022-05-23 14:03:09 +01:00
parent 64bc6d27b2
commit 7eb4ab3a8f
8 changed files with 103 additions and 384 deletions
+53 -67
View File
@@ -112,18 +112,6 @@ set_target_properties(
# CMake's built-in FRAMEWORK option doesn't give us control over the dylib name inside the # CMake's built-in FRAMEWORK option doesn't give us control over the dylib name inside the
# Framework. We instead make our own Framework here. # Framework. We instead make our own Framework here.
if(APPLE AND MUJOCO_BUILD_MACOS_FRAMEWORKS) if(APPLE AND MUJOCO_BUILD_MACOS_FRAMEWORKS)
include(DuplicateTarget)
duplicate_target(
TARGET
mujoco
NEW_TARGET_NAME
mujoco_framework
)
# Do not add mujoco::mujoco to the ALL target. We do this to speed up the
# build assuming the user is interested in the Frameworks.
set_target_properties(mujoco PROPERTIES EXCLUDE_FROM_ALL TRUE)
set(TAPI set(TAPI
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/tapi" "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/tapi"
) )
@@ -132,31 +120,27 @@ if(APPLE AND MUJOCO_BUILD_MACOS_FRAMEWORKS)
${CMAKE_CURRENT_SOURCE_DIR}/dist/Info.framework.plist ${CMAKE_CURRENT_SOURCE_DIR}/dist/Info.framework.plist
) )
set_target_properties( set_target_properties(
mujoco_framework mujoco
PROPERTIES LIBRARY_OUTPUT_DIRECTORY PROPERTIES LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/mujoco.framework/Versions/A" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/mujoco.framework/Versions/A"
BUILD_WITH_INSTALL_NAME_DIR TRUE BUILD_WITH_INSTALL_NAME_DIR TRUE
INSTALL_NAME_DIR "@rpath/mujoco.framework/Versions/A" INSTALL_NAME_DIR "@rpath/mujoco.framework/Versions/A"
OUTPUT_NAME "mujoco"
) )
add_custom_command( add_custom_command(
TARGET mujoco_framework TARGET mujoco
POST_BUILD POST_BUILD
COMMAND mkdir -p $<TARGET_FILE_DIR:mujoco_framework>/Headers COMMAND mkdir -p $<TARGET_FILE_DIR:mujoco>/Headers
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ${MUJOCO_HEADERS} COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && cp ${MUJOCO_HEADERS} $<TARGET_FILE_DIR:mujoco>/Headers
$<TARGET_FILE_DIR:mujoco_framework>/Headers COMMAND mkdir -p $<TARGET_FILE_DIR:mujoco>/Modules
COMMAND mkdir -p $<TARGET_FILE_DIR:mujoco_framework>/Modules COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/dist/module.modulemap $<TARGET_FILE_DIR:mujoco>/Modules
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/dist/module.modulemap COMMAND mkdir -p $<TARGET_FILE_DIR:mujoco>/Resources
$<TARGET_FILE_DIR:mujoco_framework>/Modules
COMMAND mkdir -p $<TARGET_FILE_DIR:mujoco_framework>/Resources
COMMAND mv ${CMAKE_CURRENT_SOURCE_DIR}/dist/Info.framework.plist COMMAND mv ${CMAKE_CURRENT_SOURCE_DIR}/dist/Info.framework.plist
$<TARGET_FILE_DIR:mujoco_framework>/Resources/Info.plist $<TARGET_FILE_DIR:mujoco>/Resources/Info.plist
COMMAND ln -fhs A $<TARGET_FILE_DIR:mujoco_framework>/../Current COMMAND ln -fhs A $<TARGET_FILE_DIR:mujoco>/../Current
COMMAND ${TAPI} stubify $<TARGET_FILE:mujoco_framework> -o COMMAND ${TAPI} stubify $<TARGET_FILE:mujoco> -o $<TARGET_FILE_DIR:mujoco>/../../mujoco.tbd
$<TARGET_FILE_DIR:mujoco_framework>/../../mujoco.tbd COMMAND ln -fhs Versions/Current/Headers $<TARGET_FILE_DIR:mujoco>/../../Headers
COMMAND ln -fhs Versions/Current/Headers $<TARGET_FILE_DIR:mujoco_framework>/../../Headers COMMAND ln -fhs Versions/Current/Modules $<TARGET_FILE_DIR:mujoco>/../../Modules
COMMAND ln -fhs Versions/Current/Modules $<TARGET_FILE_DIR:mujoco_framework>/../../Modules COMMAND ln -fhs Versions/Current/Resources $<TARGET_FILE_DIR:mujoco>/../../Resources
COMMAND ln -fhs Versions/Current/Resources $<TARGET_FILE_DIR:mujoco_framework>/../../Resources
COMMAND_EXPAND_LISTS COMMAND_EXPAND_LISTS
) )
endif() endif()
@@ -181,48 +165,50 @@ if(BUILD_TESTING AND MUJOCO_TEST_PYTHON_UTIL)
add_subdirectory(python/mujoco/util) add_subdirectory(python/mujoco/util)
endif() endif()
# Install the libraries. if(NOT (APPLE AND MUJOCO_BUILD_MACOS_FRAMEWORKS))
install( # Install the libraries.
TARGETS mujoco install(
EXPORT ${PROJECT_NAME} TARGETS mujoco
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT runtime EXPORT ${PROJECT_NAME}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT runtime RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT runtime
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT dev LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT runtime
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT dev ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT dev
) PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT dev
)
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
# Generate and install the mujocoTargets.cmake file. This defines the targets as # Generate and install the mujocoTargets.cmake file. This defines the targets as
# IMPORTED libraries for downstream users. # IMPORTED libraries for downstream users.
install( install(
EXPORT ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
DESTINATION ${CONFIG_PACKAGE_LOCATION} DESTINATION ${CONFIG_PACKAGE_LOCATION}
NAMESPACE mujoco:: NAMESPACE mujoco::
FILE "${PROJECT_NAME}Targets.cmake" FILE "${PROJECT_NAME}Targets.cmake"
) )
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
write_basic_package_version_file( write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${mujoco_VERSION} VERSION ${mujoco_VERSION}
COMPATIBILITY AnyNewerVersion COMPATIBILITY AnyNewerVersion
) )
configure_package_config_file( configure_package_config_file(
cmake/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" cmake/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION} INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION}
) )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CONFIG_PACKAGE_LOCATION} DESTINATION ${CONFIG_PACKAGE_LOCATION}
) )
# Install also models into share folder. # Install also models into share folder.
install( install(
DIRECTORY model DIRECTORY model
DESTINATION "${CMAKE_INSTALL_DATADIR}/mujoco" DESTINATION "${CMAKE_INSTALL_DATADIR}/mujoco"
PATTERN "CMakeLists.txt" EXCLUDE PATTERN "CMakeLists.txt" EXCLUDE
) )
endif()
-177
View File
@@ -1,177 +0,0 @@
# Copyright 2022 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#.rst:
# duplicate_target
# ----------------------
#
# Duplicates the specified target.
#
# duplicate_target(TARGET target NEW_TARGET_NAME new_target_name)
#
# Duplicates the specified target by creating a new target with the name
# specified by ``NEW_TARGET_NAME`` and copying all properties defined by
# ``TARGET``.
# The command has the following parameters:
#
# Arguments:
# - ``TARGET`` Target to be duplicated.
# - ``NEW_TARGET_NAME`` name of the new target.
#
if(COMMAND duplicate_target)
return()
endif()
macro(duplicate_target)
# Parse arguments.
set(options)
set(one_value_args TARGET NEW_TARGET_NAME)
set(multi_value_args)
cmake_parse_arguments(
_ARGS
"${options}"
"${one_value_args}"
"${multi_value_args}"
${ARGN}
)
# Check required variables are defined.
if(NOT _ARGS_TARGET)
message(FATAL_ERROR "duplicate_target: TARGET must be specified.")
endif()
if(NOT _ARGS_NEW_TARGET_NAME)
message(FATAL_ERROR "duplicate_target: NEW_TARGET_NAME must be specified.")
endif()
# Check for the target to exist.
if(NOT TARGET ${_ARGS_TARGET})
message(FATAL_ERROR "duplicate_target: TARGET ${_ARGS_TARGET} not found.")
endif()
# Non-exausitve list.
set(PROPERTIES_TO_SKIP)
get_target_property(TARGET_TYPE ${_ARGS_TARGET} TYPE)
if(${TARGET_TYPE} STREQUAL "STATIC_LIBRARY")
add_library(${_ARGS_NEW_TARGET_NAME} STATIC)
list(APPEND PROPERTIES_TO_SKIP "IMPORTED_GLOBAL")
elseif(${TARGET_TYPE} STREQUAL "SHARED_LIBRARY")
add_library(${_ARGS_NEW_TARGET_NAME} SHARED)
list(APPEND PROPERTIES_TO_SKIP "IMPORTED_GLOBAL")
elseif(${TARGET_TYPE} STREQUAL "OBJECT_LIBRARY")
add_library(${_ARGS_NEW_TARGET_NAME} OBJECT)
list(APPEND PROPERTIES_TO_SKIP "IMPORTED_GLOBAL")
elseif(${TARGET_TYPE} STREQUAL "INTERFACE_LIBRARY")
add_library(${_ARGS_NEW_TARGET_NAME} INTERFACE)
elseif(${TARGET_TYPE} STREQUAL "EXECUTABLE")
add_executable(${_ARGS_NEW_TARGET_NAME})
list(APPEND PROPERTIES_TO_SKIP "IMPORTED_GLOBAL")
endif()
set(IGNORED_PROPERTIES "HEADER_SETS;INTERFACE_HEADER_SETS;NAME;TYPE")
# Get all CMake target properties.
if(NOT CMAKE_ALL_PROPERTY_LIST)
execute_process(COMMAND cmake --help-property-list OUTPUT_VARIABLE ALL_PROPERTIES)
# Convert command output into a CMake list
string(
REGEX
REPLACE ";"
"\\\\;"
ALL_PROPERTIES
"${ALL_PROPERTIES}"
)
string(
REGEX
REPLACE "\n"
";"
ALL_PROPERTIES
"${ALL_PROPERTIES}"
)
# Post process the properties. We:
# - Remove all properties listed in ``IGNORED_PROPERTIES``.
# - Remove LOCATION as it should not be accessed, See https://stackoverflow.com/questions/32197663/how-can-i-remove-the-the-location-property-may-not-be-read-from-target-error-i
# - Substitute <CONFIG> with all the possible build types. This is needed for multi-config generators as they can change the type of build without invoking again CMake.
set(CMAKE_ALL_PROPERTY_LIST "")
foreach(PROPERTY ${ALL_PROPERTIES})
# Skip reading the LOCAION property as they should not be read.
# See https://stackoverflow.com/questions/32197663/how-can-i-remove-the-the-location-property-may-not-be-read-from-target-error-i
if(PROPERTY STREQUAL "LOCATION"
OR PROPERTY MATCHES "^LOCATION_"
OR PROPERTY MATCHES "_LOCATION$"
)
continue()
endif()
set(_ignore OFF)
foreach(_pro ${IGNORED_PROPERTIES})
if(PROPERTY STREQUAL ${_pro})
set(_ignore ON)
break()
endif()
endforeach()
if(_ignore)
continue()
endif()
string(FIND ${PROPERTY} "<CONFIG>" FOUND)
if(${FOUND} EQUAL -1)
# Simply append the property.
list(APPEND CMAKE_ALL_PROPERTY_LIST ${PROPERTY})
else()
# Iterate on the build types to add the correct property.
foreach(BUILD_TYPE ${BUILD_TYPES})
string(
REPLACE "<CONFIG>"
"${BUILD_TYPE}"
CONFIG_PROPERTY
${PROPERTY}
)
list(APPEND CMAKE_ALL_PROPERTY_LIST ${CONFIG_PROPERTY})
endforeach()
endif()
endforeach()
endif()
foreach(PROPERTY ${CMAKE_ALL_PROPERTY_LIST})
# Search if we should skip this property.
list(
FIND
PROPERTIES_TO_SKIP
${PROPERTY}
SHOULD_SKIP
)
if(${SHOULD_SKIP} GREATER_EQUAL 0)
continue()
endif()
# First check if the property was set on the target
get_property(
PROPERTY_FOUND
TARGET ${_ARGS_TARGET}
PROPERTY ${PROPERTY}
SET
)
if(PROPERTY_FOUND)
get_target_property(PROPERTY_VALUE ${_ARGS_TARGET} ${PROPERTY})
set_target_properties(${_ARGS_NEW_TARGET_NAME} PROPERTIES ${PROPERTY} "${PROPERTY_VALUE}")
endif()
endforeach()
endmacro()
+1 -1
View File
@@ -3242,7 +3242,7 @@ users of MuJoCo -- we do our own work with the public library instead of relying
Activation Activation
^^^^^^^^^^ ^^^^^^^^^^
The functions in this section are maintained for backward compatibillity with the now-removed activation mechanism. The functions in this section are maintained for backward compatibility with the now-removed activation mechanism.
.. _mj_activate: .. _mj_activate:
+3 -2
View File
@@ -58,9 +58,10 @@ General
Bug fixes Bug fixes
^^^^^^^^^ ^^^^^^^^^
10. Antialiasing was disabled for segmentation rendering. Before this change, if the :ref:`offsamples<quality>` 10. Antialiasing was disabled for segmentation rendering. Before this change, if the :ref:`offsamples<quality>`
attribute was greater than 0 (the default value is 4), pixels that overlapped with multiple geoms would receive attribute was greater than 0 (the default value is 4), pixels that overlapped with multiple geoms would receive
averaged segmentation IDs, leading to incorrect or non-existant IDs. After this change :at:`offsamples` is ignored averaged segmentation IDs, leading to incorrect or non-existent IDs. After this change :at:`offsamples` is ignored
during segmentation rendering. during segmentation rendering.
#. The value of the enable flag for the experimental multiCCD feature was made sequential with other enable flags. #. The value of the enable flag for the experimental multiCCD feature was made sequential with other enable flags.
@@ -397,7 +398,7 @@ License manager
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
23. Removed the entire license manager. The functions ``mj_activate`` and ``mj_deactivate`` are still there for 23. Removed the entire license manager. The functions ``mj_activate`` and ``mj_deactivate`` are still there for
backward compabitibily, but now they do nothing and it is no longer necessary to call them. backward compatibility, but now they do nothing and it is no longer necessary to call them.
#. Removed the remote license certificate functions ``mj_certXXX``. #. Removed the remote license certificate functions ``mj_certXXX``.
Earlier versions Earlier versions
+1 -1
View File
@@ -1207,7 +1207,7 @@ existing URDF models have non-physical dynamics parameters which MuJoCo's built-
unmodified. This extension is also needed to specify mesh directories. unmodified. This extension is also needed to specify mesh directories.
Note that the while MJCF models are checked against a custom XML schema by the parser, URDF models are not. Even the Note that the while MJCF models are checked against a custom XML schema by the parser, URDF models are not. Even the
MuJoCo-specific elements emebdded in the URDF file are not checked. As a result, mis-typed attribute names are MuJoCo-specific elements embedded in the URDF file are not checked. As a result, mis-typed attribute names are
silently ignored, which can result in major confusion if the typo remains unnoticed. silently ignored, which can result in major confusion if the typo remains unnoticed.
Here is an example extension section of a URDF model: Here is an example extension section of a URDF model:
+1 -1
View File
@@ -602,7 +602,7 @@ Divergence of a simulation happens when elements of the state tend quickly to in
manifested as an :ref:`mjWARN_BADQACC<mjtwarning>` warning. Divergence is endemic to all physics simulation and is not manifested as an :ref:`mjWARN_BADQACC<mjtwarning>` warning. Divergence is endemic to all physics simulation and is not
necessarily indicative of a bad model or bug in the simulator, but is rather a hint that the timestep is too large for necessarily indicative of a bad model or bug in the simulator, but is rather a hint that the timestep is too large for
the given choice of integrator. In physics simulation there is always a tension between speed (large time steps) and the given choice of integrator. In physics simulation there is always a tension between speed (large time steps) and
stabillity (small timesteps). A model which is well-tuned for speed has the largest possible timestep that does not stability (small timesteps). A model which is well-tuned for speed has the largest possible timestep that does not
diverge, which usually means that it *can* be made to diverge under extreme conditions. In that sense *rare* cases of diverge, which usually means that it *can* be made to diverge under extreme conditions. In that sense *rare* cases of
divergence can actually be indicative of a well-tuned model. In all cases it should be possible to prevent divergence by divergence can actually be indicative of a well-tuned model. In all cases it should be possible to prevent divergence by
reducing the timestep and/or switching to a more stable :ref:`integrator <geIntegration>`. If that fails, the culprit is reducing the timestep and/or switching to a more stable :ref:`integrator <geIntegration>`. If that fails, the culprit is
+2 -2
View File
@@ -238,7 +238,7 @@ to terminate the process, otherwise the behavior of MuJoCo after the callback re
sufficient to ensure that error callbacks do not return *to MuJoCo*, but it is permitted to use sufficient to ensure that error callbacks do not return *to MuJoCo*, but it is permitted to use
`longjmp <https://en.cppreference.com/w/c/program/longjmp>`__ to skip MuJoCo's call stack back to the external callsite. `longjmp <https://en.cppreference.com/w/c/program/longjmp>`__ to skip MuJoCo's call stack back to the external callsite.
The Python bindings utilises longjmp to allow it to convert irrecoverable MuJoCo errors into Python exceptions of type The Python bindings utilizes longjmp to allow it to convert irrecoverable MuJoCo errors into Python exceptions of type
``mujoco.FatalError`` that can be caught and processed in the usual Pythonic way. Furthermore, it installs its error ``mujoco.FatalError`` that can be caught and processed in the usual Pythonic way. Furthermore, it installs its error
callback in a thread-local manner using a currently private API, thus allowing for concurrent calls into MuJoCo from callback in a thread-local manner using a currently private API, thus allowing for concurrent calls into MuJoCo from
multiple threads. multiple threads.
@@ -270,7 +270,7 @@ Migration Notes for mujoco-py
----------------------------- -----------------------------
In mujoco-py, the main entry point is the `MjSim <https://github.com/openai/mujoco-py/blob/master/mujoco_py/mjsim.pyx>`_ In mujoco-py, the main entry point is the `MjSim <https://github.com/openai/mujoco-py/blob/master/mujoco_py/mjsim.pyx>`_
class. Users constuct a stateful ``MjSim`` instance from an MJCF model (similar to ``dm_control.Physics``), and this class. Users construct a stateful ``MjSim`` instance from an MJCF model (similar to ``dm_control.Physics``), and this
instance holds references to an ``mjModel`` instance and its associated ``mjData``. In contrast, the MuJoCo Python instance holds references to an ``mjModel`` instance and its associated ``mjData``. In contrast, the MuJoCo Python
bindings (``mujoco``) take a more low-level approach, as explained above: following the design principle of the C bindings (``mujoco``) take a more low-level approach, as explained above: following the design principle of the C
library, the ``mujoco`` module itself is stateless, and merely wraps the underlying native structs and functions. library, the ``mujoco`` module itself is stateless, and merely wraps the underlying native structs and functions.
+42 -133
View File
@@ -24,7 +24,7 @@ set(MSVC_INCREMENTAL_DEFAULT ON)
project( project(
mujoco_samples mujoco_samples
VERSION 2.1.5 VERSION 2.2.0
DESCRIPTION "MuJoCo samples binaries" DESCRIPTION "MuJoCo samples binaries"
HOMEPAGE_URL "https://mujoco.org" HOMEPAGE_URL "https://mujoco.org"
) )
@@ -161,145 +161,54 @@ if(APPLE)
target_link_libraries(simulate "-framework Cocoa") target_link_libraries(simulate "-framework Cocoa")
endif() endif()
if(NOT SAMPLE_STANDALONE) if(APPLE AND MUJOCO_BUILD_MACOS_FRAMEWORKS)
if(APPLE AND MUJOCO_BUILD_MACOS_FRAMEWORKS) set_target_properties(
simulate
macro(link_to_mujoco_framework target) PROPERTIES INSTALL_RPATH @executable_path/../Frameworks
get_target_property(interface_link_libraries ${target} INTERFACE_LINK_LIBRARIES) BUILD_WITH_INSTALL_RPATH TRUE
get_target_property(link_libraries ${target} LINK_LIBRARIES) RESOURCE ${SIMULATE_RESOURCE_FILES}
# Remove mujoco::mujoco target which is the not-framework library. MACOSX_BUNDLE TRUE
list(REMOVE_ITEM interface_link_libraries mujoco::mujoco) MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/../dist/Info.plist.simulate.in
list(REMOVE_ITEM link_libraries mujoco::mujoco) MACOSX_BUNDLE_BUNDLE_NAME "MuJoCo"
set_target_properties( MACOSX_BUNDLE_GUI_IDENTIFIER "org.mujoco.mujoco"
${target} PROPERTIES INTERFACE_LINK_LIBRARIES "${interface_link_libraries}" MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
) MACOSX_BUNDLE_INFO_STRING ${PROJECT_VERSION}
set_target_properties(${target} PROPERTIES LINK_LIBRARIES "${link_libraries}") MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}
# Add mujoco_framework. MACOSX_BUNDLE_ICON_FILE "mujoco.icns"
target_link_libraries(${target} mujoco_framework) MACOSX_BUNDLE_COPYRIGHT "Copyright 2021 DeepMind Technologies Limited."
endmacro() )
include(DuplicateTarget)
duplicate_target(
TARGET
simulate
NEW_TARGET_NAME
simulate_macos
)
link_to_mujoco_framework(simulate_macos)
macro(embed_in_bundle target)
add_dependencies(${target} simulate)
set_target_properties( set_target_properties(
simulate_macos ${target}
PROPERTIES INSTALL_RPATH @executable_path/../Frameworks PROPERTIES INSTALL_RPATH @executable_path/../Frameworks
BUILD_WITH_INSTALL_RPATH TRUE BUILD_WITH_INSTALL_RPATH TRUE
RESOURCE ${SIMULATE_RESOURCE_FILES} RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:simulate>
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/../dist/Info.plist.simulate.in
MACOSX_BUNDLE_BUNDLE_NAME "MuJoCo"
MACOSX_BUNDLE_GUI_IDENTIFIER "org.mujoco.mujoco"
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_INFO_STRING ${PROJECT_VERSION}
MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}
MACOSX_BUNDLE_ICON_FILE "mujoco.icns"
MACOSX_BUNDLE_COPYRIGHT "Copyright 2021 DeepMind Technologies Limited."
OUTPUT_NAME "simulate"
) )
endmacro()
macro(embed_in_bundle target) embed_in_bundle(basic simulate)
add_dependencies(${target} simulate_macos) embed_in_bundle(compile simulate)
set_target_properties( embed_in_bundle(derivative simulate)
${target} embed_in_bundle(record simulate)
PROPERTIES INSTALL_RPATH @executable_path/../Frameworks embed_in_bundle(testspeed simulate)
BUILD_WITH_INSTALL_RPATH TRUE embed_in_bundle(testxml simulate)
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:simulate_macos>
)
endmacro()
duplicate_target( # Embed mujoco.framework inside the App bundle ane move the icon file over too.
TARGET add_custom_command(
basic TARGET simulate
NEW_TARGET_NAME POST_BUILD
basic_macos COMMAND mkdir -p $<TARGET_FILE_DIR:simulate>/../Frameworks
) COMMAND rm -rf $<TARGET_FILE_DIR:simulate>/../Frameworks/mujoco.framework
set_target_properties(basic_macos PROPERTIES OUTPUT_NAME basic) COMMAND cp -a $<TARGET_FILE_DIR:mujoco::mujoco>/../../../mujoco.framework
link_to_mujoco_framework(basic_macos) $<TARGET_FILE_DIR:simulate>/../Frameworks/
embed_in_bundle(basic_macos simulate_macos) # Delete the symlink and the TBD, otherwise we can't sign and notarize.
COMMAND rm -rf $<TARGET_FILE_DIR:simulate>/../Frameworks/mujoco.framework/mujoco.tbd
duplicate_target( COMMAND rm -rf
TARGET $<TARGET_FILE_DIR:simulate>/../Frameworks/mujoco.framework/Versions/A/libmujoco.dylib
compile )
NEW_TARGET_NAME
compile_macos
)
set_target_properties(compile_macos PROPERTIES OUTPUT_NAME compile)
link_to_mujoco_framework(compile_macos)
embed_in_bundle(compile_macos simulate_macos)
duplicate_target(
TARGET
derivative
NEW_TARGET_NAME
derivative_macos
)
set_target_properties(derivative_macos PROPERTIES OUTPUT_NAME derivative)
link_to_mujoco_framework(derivative_macos)
embed_in_bundle(derivative_macos simulate_macos)
duplicate_target(
TARGET
record
NEW_TARGET_NAME
record_macos
)
set_target_properties(record_macos PROPERTIES OUTPUT_NAME record)
link_to_mujoco_framework(record_macos)
embed_in_bundle(record_macos simulate_macos)
duplicate_target(
TARGET
testspeed
NEW_TARGET_NAME
testspeed_macos
)
set_target_properties(testspeed_macos PROPERTIES OUTPUT_NAME testspeed)
link_to_mujoco_framework(testspeed_macos)
embed_in_bundle(testspeed_macos simulate_macos)
duplicate_target(
TARGET
testxml
NEW_TARGET_NAME
testxml_macos
)
set_target_properties(testxml_macos PROPERTIES OUTPUT_NAME testxml)
link_to_mujoco_framework(testxml_macos)
embed_in_bundle(testxml_macos simulate_macos)
# Do not add the original binaries to the ALL target. We do this to speed up the
# build assuming the user is interested in the Frameworks.
set_target_properties(simulate PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(basic PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(derivative PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(record PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(testxml PROPERTIES EXCLUDE_FROM_ALL TRUE)
# Note: compile and testspeed are needed by the tests.
# Embed mujoco.framework inside the App bundle ane move the icon file over too.
add_custom_command(
TARGET simulate_macos
POST_BUILD
COMMAND mkdir -p $<TARGET_FILE_DIR:simulate_macos>/../Frameworks
COMMAND rm -rf $<TARGET_FILE_DIR:simulate_macos>/../Frameworks/mujoco.framework
COMMAND cp -a $<TARGET_FILE_DIR:mujoco_framework>/../../../mujoco.framework
$<TARGET_FILE_DIR:simulate_macos>/../Frameworks/
# Delete the symlink and the TBD, otherwise we can't sign and notarize.
COMMAND rm -rf $<TARGET_FILE_DIR:simulate_macos>/../Frameworks/mujoco.framework/mujoco.tbd
COMMAND
rm -rf
$<TARGET_FILE_DIR:simulate_macos>/../Frameworks/mujoco.framework/Versions/A/libmujoco.dylib
)
endif()
endif() endif()
# Do not install if macOS Bundles are created as RPATH is managed manually there. # Do not install if macOS Bundles are created as RPATH is managed manually there.