Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the ability to install libsimulate library and associated headers during installation. #2170

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions simulate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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.
Expand All @@ -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()
Expand Down
17 changes: 17 additions & 0 deletions simulate/cmake/SimulateDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this at all since we'd be vendoring other project's headers as part of the install.

If the GLFW headers are needed then you should just set USE_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()