@@ -47,6 +47,7 @@ option(SIMULATE_GLFW_DYNAMIC_SYMBOLS "Whether to resolve GLFW symbols dynamicall
47
47
# Check if we are building as standalone project.
48
48
set (SIMULATE_STANDALONE OFF )
49
49
set (_INSTALL_SIMULATE ON )
50
+
50
51
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
51
52
set (SIMULATE_STANDALONE ON )
52
53
# If standalone, do not install the samples.
@@ -93,7 +94,7 @@ if(NOT TARGET lodepng)
93
94
# This is not a CMake project.
94
95
set (LODEPNG_SRCS ${lodepng_SOURCE_DIR} /lodepng.cpp)
95
96
set (LODEPNG_HEADERS ${lodepng_SOURCE_DIR} /lodepng.h)
96
- add_library (lodepng STATIC ${LODEPNG_HEADERS} ${LODEPNG_SRCS} )
97
+ add_library (lodepng OBJECT ${LODEPNG_HEADERS} ${LODEPNG_SRCS} )
97
98
target_compile_options (lodepng PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS} )
98
99
target_link_options (lodepng PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS} )
99
100
target_include_directories (lodepng PUBLIC ${lodepng_SOURCE_DIR} )
@@ -114,7 +115,7 @@ if(APPLE)
114
115
target_link_libraries (platform_ui_adapter PUBLIC "-framework CoreVideo" )
115
116
endif ()
116
117
target_include_directories (
117
- platform_ui_adapter PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
118
+ platform_ui_adapter PUBLIC $<BUILD_INTERFACE: $ {CMAKE_CURRENT_SOURCE_DIR}>
118
119
$<TARGET_PROPERTY:glfw,INTERFACE_INCLUDE_DIRECTORIES >
119
120
)
120
121
target_link_libraries (platform_ui_adapter PUBLIC mujoco::mujoco)
@@ -123,23 +124,30 @@ if(SIMULATE_GLFW_DYNAMIC_SYMBOLS)
123
124
endif ()
124
125
add_library (mujoco::platform_ui_adapter ALIAS platform_ui_adapter)
125
126
126
- add_library (libsimulate STATIC $<TARGET_OBJECTS:platform_ui_adapter>)
127
- set_target_properties (libsimulate PROPERTIES OUTPUT_NAME simulate)
128
- add_library (mujoco::libsimulate ALIAS libsimulate)
127
+ add_library (libmujoco_simulate STATIC $<TARGET_OBJECTS:platform_ui_adapter> $<TARGET_OBJECTS:lodepng>)
128
+ set_target_properties (libmujoco_simulate PROPERTIES OUTPUT_NAME simulate)
129
+ add_library (mujoco::libmujoco_simulate ALIAS libmujoco_simulate)
130
+ set_target_properties (libmujoco_simulate PROPERTIES PUBLIC_HEADER "simulate.h;platform_ui_adapter.h;glfw_adapter.h;glfw_dispatch.h;glfw_corevideo.h;array_safety.h" )
131
+
129
132
130
133
target_sources (
131
- libsimulate
132
- PUBLIC simulate.h
133
- PRIVATE simulate.cc array_safety.h
134
+ libmujoco_simulate
135
+ PRIVATE simulate.cc
134
136
)
135
- target_include_directories (libsimulate PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} )
136
- target_compile_options (libsimulate PRIVATE ${MUJOCO_SIMULATE_COMPILE_OPTIONS} )
137
- target_link_libraries (libsimulate PUBLIC lodepng mujoco::platform_ui_adapter mujoco::mujoco)
138
- target_link_options (libsimulate PRIVATE ${MUJOCO_SIMULATE_LINK_OPTIONS} )
137
+ target_include_directories (libmujoco_simulate
138
+ PUBLIC
139
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} >
140
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} /simulate>
141
+ PRIVATE
142
+ ${lodepng_SOURCE_DIR}
143
+ )
144
+ target_compile_options (libmujoco_simulate PRIVATE ${MUJOCO_SIMULATE_COMPILE_OPTIONS} )
145
+ target_link_libraries (libmujoco_simulate PUBLIC mujoco::mujoco)
146
+ target_link_options (libmujoco_simulate PRIVATE ${MUJOCO_SIMULATE_LINK_OPTIONS} )
139
147
140
148
if (APPLE )
141
- target_sources (libsimulate PRIVATE macos_gui.mm)
142
- target_link_libraries (libsimulate PUBLIC "-framework Cocoa" )
149
+ target_sources (libmujoco_simulate PRIVATE macos_gui.mm)
150
+ target_link_libraries (libmujoco_simulate PUBLIC "-framework Cocoa" )
143
151
endif ()
144
152
145
153
# Build simulate executable
@@ -167,13 +175,16 @@ if(SIMULATE_BUILD_EXECUTABLE)
167
175
168
176
target_link_libraries (
169
177
simulate
170
- libsimulate
178
+ libmujoco_simulate
171
179
mujoco::mujoco
172
180
glfw
173
181
Threads::Threads
174
- lodepng
175
182
)
176
183
184
+ if (APPLE )
185
+ target_link_libraries (simulate "-framework CoreVideo" )
186
+ endif ()
187
+
177
188
if (MUJOCO_WITH_USD)
178
189
target_link_libraries (
179
190
simulate
@@ -263,16 +274,6 @@ if(SIMULATE_BUILD_EXECUTABLE)
263
274
)
264
275
endif ()
265
276
266
- install (
267
- TARGETS simulate
268
- EXPORT ${PROJECT_NAME}
269
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR} " COMPONENT simulate
270
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR} " COMPONENT simulate
271
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR} " COMPONENT simulate
272
- BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR} " COMPONENT simulate
273
- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT simulate
274
- )
275
-
276
277
if (NOT MUJOCO_SIMULATE_USE_SYSTEM_GLFW)
277
278
# We downloaded GLFW. Depending if it is a static or shared LIBRARY we might
278
279
# need to install it.
@@ -288,5 +289,26 @@ if(SIMULATE_BUILD_EXECUTABLE)
288
289
)
289
290
endif ()
290
291
endif ()
292
+
293
+ install (
294
+ TARGETS simulate
295
+ EXPORT ${PROJECT_NAME}
296
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR} " COMPONENT simulate
297
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR} " COMPONENT simulate
298
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR} " COMPONENT simulate
299
+ BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR} " COMPONENT simulate
300
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR} " COMPONENT simulate
301
+ )
302
+
303
+ # Specify public headers for libmujoco_simulate
304
+
305
+ install (
306
+ TARGETS libmujoco_simulate
307
+ EXPORT mujoco
308
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR} " COMPONENT simulate
309
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR} " COMPONENT simulate
310
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR} " COMPONENT simulate
311
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR} /simulate" COMPONENT simulate
312
+ )
291
313
endif ()
292
314
endif ()
0 commit comments