Merge pull request #201 from aftersomemath:refactor-simulate
PiperOrigin-RevId: 465044152 Change-Id: I54e65a30764a444dbd175260314d685fd7ffa6a1
This commit is contained in:
@@ -70,14 +70,6 @@ if(MUJOCO_HARDEN)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Utility library
|
||||
add_library(uitools STATIC)
|
||||
target_sources(uitools PRIVATE uitools.h uitools.c)
|
||||
target_include_directories(uitools PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_compile_options(uitools PUBLIC ${MUJOCO_SAMPLE_COMPILE_OPTIONS})
|
||||
target_link_libraries(uitools PUBLIC glfw mujoco::mujoco)
|
||||
target_link_options(uitools PRIVATE ${MUJOCO_SAMPLE_LINK_OPTIONS})
|
||||
|
||||
# Build sample binaries
|
||||
add_executable(compile compile.cc)
|
||||
target_compile_options(compile PUBLIC ${MUJOCO_SAMPLE_COMPILE_OPTIONS})
|
||||
@@ -126,85 +118,13 @@ target_link_libraries(
|
||||
)
|
||||
target_link_options(record PRIVATE ${MUJOCO_SAMPLE_LINK_OPTIONS})
|
||||
|
||||
if(APPLE)
|
||||
set(SIMULATE_RESOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../dist/mujoco.icns)
|
||||
elseif(WIN32)
|
||||
set(SIMULATE_RESOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../dist/appicon.rc)
|
||||
else()
|
||||
set(SIMULATE_RESOURCE_FILES "")
|
||||
endif()
|
||||
|
||||
add_executable(simulate simulate.cc array_safety.h ${SIMULATE_RESOURCE_FILES})
|
||||
target_compile_options(simulate PUBLIC ${MUJOCO_SAMPLE_COMPILE_OPTIONS})
|
||||
if(WIN32)
|
||||
add_custom_command(
|
||||
TARGET simulate
|
||||
PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../dist/mujoco.ico
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E rm ${CMAKE_CURRENT_SOURCE_DIR}/mujoco.ico
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
simulate
|
||||
mujoco::mujoco
|
||||
uitools
|
||||
glfw
|
||||
Threads::Threads
|
||||
)
|
||||
target_link_options(simulate PRIVATE ${MUJOCO_SAMPLE_LINK_OPTIONS})
|
||||
|
||||
if(APPLE)
|
||||
target_sources(simulate PRIVATE macos_save.mm)
|
||||
target_link_libraries(simulate "-framework Cocoa")
|
||||
endif()
|
||||
|
||||
if(APPLE AND MUJOCO_BUILD_MACOS_FRAMEWORKS)
|
||||
set_target_properties(
|
||||
simulate
|
||||
PROPERTIES INSTALL_RPATH @executable_path/../Frameworks
|
||||
BUILD_WITH_INSTALL_RPATH TRUE
|
||||
RESOURCE ${SIMULATE_RESOURCE_FILES}
|
||||
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.app"
|
||||
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."
|
||||
)
|
||||
|
||||
macro(embed_in_bundle target)
|
||||
add_dependencies(${target} simulate)
|
||||
set_target_properties(
|
||||
${target}
|
||||
PROPERTIES INSTALL_RPATH @executable_path/../Frameworks
|
||||
BUILD_WITH_INSTALL_RPATH TRUE
|
||||
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:simulate>
|
||||
)
|
||||
endmacro()
|
||||
|
||||
embed_in_bundle(basic simulate)
|
||||
embed_in_bundle(compile simulate)
|
||||
embed_in_bundle(derivative simulate)
|
||||
embed_in_bundle(record simulate)
|
||||
embed_in_bundle(testspeed simulate)
|
||||
embed_in_bundle(testxml simulate)
|
||||
|
||||
# Embed mujoco.framework inside the App bundle.
|
||||
add_custom_command(
|
||||
TARGET simulate
|
||||
POST_BUILD
|
||||
COMMAND mkdir -p $<TARGET_FILE_DIR:simulate>/../Frameworks
|
||||
COMMAND rm -rf $<TARGET_FILE_DIR:simulate>/../Frameworks/mujoco.framework
|
||||
COMMAND cp -a $<TARGET_FILE_DIR:mujoco::mujoco>/../../../mujoco.framework
|
||||
$<TARGET_FILE_DIR:simulate>/../Frameworks/
|
||||
)
|
||||
endif()
|
||||
|
||||
# Do not install if macOS Bundles are created as RPATH is managed manually there.
|
||||
@@ -225,7 +145,6 @@ if(_INSTALL_SAMPLES)
|
||||
record
|
||||
testspeed
|
||||
testxml
|
||||
simulate
|
||||
INSTALL_DIRECTORY
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}"
|
||||
LIB_DIRS
|
||||
@@ -241,7 +160,6 @@ if(_INSTALL_SAMPLES)
|
||||
record
|
||||
testspeed
|
||||
testxml
|
||||
simulate
|
||||
EXPORT ${PROJECT_NAME}
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT samples
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT samples
|
||||
|
||||
Reference in New Issue
Block a user