diff --git a/simulate/CMakeLists.txt b/simulate/CMakeLists.txt index 487b1b16f4..404f929f8e 100644 --- a/simulate/CMakeLists.txt +++ b/simulate/CMakeLists.txt @@ -128,8 +128,13 @@ add_library(mujoco::libsimulate ALIAS libsimulate) target_sources( libsimulate - PUBLIC simulate.h - PRIVATE simulate.cc array_safety.h + PUBLIC + simulate.h + platform_ui_adapter.h + glfw_adapter.h + glfw_dispatch.h + array_safety.h + PRIVATE simulate.cc ) target_include_directories(libsimulate PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_options(libsimulate PRIVATE ${MUJOCO_SIMULATE_COMPILE_OPTIONS}) @@ -246,9 +251,21 @@ if(SIMULATE_BUILD_EXECUTABLE) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT simulate ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT simulate BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT simulate - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT simulate + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT simulate ) + # Specify public headers for libsimulate + if(SIMULATE_EXPOSE_HEADERS) + set_target_properties(libsimulate PROPERTIES PUBLIC_HEADER "simulate.h;platform_ui_adapter.h;glfw_adapter.h;glfw_dispatch.h;glfw_corevideo.h;array_safety.h") + + install( + TARGETS libsimulate + EXPORT ${PROJECT_NAME} + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT simulate + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/simulate" COMPONENT simulate + ) + endif() + if(NOT MUJOCO_SIMULATE_USE_SYSTEM_GLFW) # We downloaded GLFW. Depending if it is a static or shared LIBRARY we might # need to install it. @@ -260,7 +277,7 @@ if(SIMULATE_BUILD_EXECUTABLE) RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT simulate LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT simulate ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT simulate - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT simulate + PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT simulate ) endif() endif() diff --git a/simulate/cmake/SimulateDependencies.cmake b/simulate/cmake/SimulateDependencies.cmake index 5141406cd9..91981cbc2d 100644 --- a/simulate/cmake/SimulateDependencies.cmake +++ b/simulate/cmake/SimulateDependencies.cmake @@ -102,3 +102,20 @@ if(NOT SIMULATE_STANDALONE) target_compile_options(glfw PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS}) target_link_options(glfw PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS}) endif() + +# Install GLFW headers if not using system GLFW +if(NOT MUJOCO_SIMULATE_USE_SYSTEM_GLFW) + FetchContent_GetProperties(glfw3) + if(NOT glfw3_POPULATED) + message(FATAL_ERROR "GLFW3 not populated") + endif() + + install( + DIRECTORY ${glfw3_SOURCE_DIR}/include/GLFW + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + COMPONENT simulate + FILES_MATCHING PATTERN "*.h" + PATTERN "CMake*" EXCLUDE + PATTERN ".git*" EXCLUDE + ) +endif()