Simulate: fix MacOS build (still crashes due to GLFW misusage)
This commit is contained in:
@@ -84,9 +84,14 @@ target_sources(mjsimulate PUBLIC simulate.h array_safety.h simulate.cc)
|
||||
target_include_directories(mjsimulate PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_compile_definitions(mjsimulate PUBLIC MJSIMULATE_DLL_EXPORTS)
|
||||
target_compile_options(mjsimulate PUBLIC ${MUJOCO_SIMULATE_COMPILE_OPTIONS})
|
||||
target_link_libraries(mjsimulate PUBLIC glfw uitools mujoco::mujoco) # TODO is that right
|
||||
target_link_libraries(mjsimulate PUBLIC glfw uitools mujoco::mujoco)
|
||||
target_link_options(mjsimulate PRIVATE ${MUJOCO_SIMULATE_LINK_OPTIONS})
|
||||
|
||||
if(APPLE)
|
||||
target_sources(mjsimulate PRIVATE macos_save.mm)
|
||||
target_link_libraries(mjsimulate PUBLIC "-framework Cocoa")
|
||||
endif()
|
||||
|
||||
# Build samples that require GLFW.
|
||||
|
||||
if(APPLE)
|
||||
@@ -125,11 +130,6 @@ else()
|
||||
target_link_options(simulate PRIVATE ${MUJOCO_SIMULATE_LINK_OPTIONS})
|
||||
endif()
|
||||
|
||||
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
|
||||
|
||||
+12
-13
@@ -24,6 +24,18 @@
|
||||
#include <mujoco/mjxmacro.h>
|
||||
#include "array_safety.h"
|
||||
|
||||
// When launched via an App Bundle on macOS, the working directory is the path to the App Bundle's
|
||||
// resource directory. This causes files to be saved into the bundle, which is not the desired
|
||||
// behavior. Instead, we open a save dialog box to ask the user where to put the file.
|
||||
// Since the dialog box logic needs to be written in Objective-C, we separate it into a different
|
||||
// source file.
|
||||
#ifdef __APPLE__
|
||||
std::string getSavePath(const char* filename);
|
||||
#else
|
||||
static std::string getSavePath(const char* filename) {
|
||||
return filename;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
namespace mj = ::mujoco;
|
||||
@@ -1026,19 +1038,6 @@ void uiLayout(mjuiState* state) {
|
||||
rect[3].height = rect[0].height;
|
||||
}
|
||||
|
||||
// When launched via an App Bundle on macOS, the working directory is the path to the App Bundle's
|
||||
// resource directory. This causes files to be saved into the bundle, which is not the desired
|
||||
// behavior. Instead, we open a save dialog box to ask the user where to put the file.
|
||||
// Since the dialog box logic needs to be written in Objective-C, we separate it into a different
|
||||
// source file.
|
||||
#ifdef __APPLE__
|
||||
std::string getSavePath(const char* filename);
|
||||
#else
|
||||
static std::string getSavePath(const char* filename) {
|
||||
return filename;
|
||||
}
|
||||
#endif
|
||||
|
||||
// handle UI event
|
||||
void uiEvent(mjuiState* state) {
|
||||
mj::Simulate* simulate = (mj::Simulate*)(state->userdata);
|
||||
|
||||
Reference in New Issue
Block a user