From f6e4666624d701804d3593de686e68d96d99a91e Mon Sep 17 00:00:00 2001 From: vidurvij-apptronik <152456958+vidurvij-apptronik@users.noreply.github.com> Date: Wed, 23 Oct 2024 14:59:33 -0500 Subject: [PATCH 1/4] Updating simulation cmake to install headers and so file if requested using a flag. --- simulate/CMakeLists.txt | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/simulate/CMakeLists.txt b/simulate/CMakeLists.txt index 487b1b16f4..b8a3c294c4 100644 --- a/simulate/CMakeLists.txt +++ b/simulate/CMakeLists.txt @@ -41,12 +41,16 @@ if(APPLE) enable_language(OBJCXX) endif() +if(NOT DEFINED expose_headers) + +endif() option(SIMULATE_BUILD_EXECUTABLE "Build the simulate executable binary." ON) option(SIMULATE_GLFW_DYNAMIC_SYMBOLS "Whether to resolve GLFW symbols dynamically." OFF) # Check if we are building as standalone project. set(SIMULATE_STANDALONE OFF) set(_INSTALL_SIMULATE ON) +set(EXPOSE_HEADERS OFF) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set(SIMULATE_STANDALONE ON) # If standalone, do not install the samples. @@ -128,7 +132,11 @@ add_library(mujoco::libsimulate ALIAS libsimulate) target_sources( libsimulate - PUBLIC simulate.h + PUBLIC + simulate.h + platform_ui_adapter.h + glfw_adapter.h + glfw_dispatch.h PRIVATE simulate.cc array_safety.h ) target_include_directories(libsimulate PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) @@ -223,6 +231,14 @@ if(SIMULATE_BUILD_EXECUTABLE) set(_INSTALL_SIMULATE OFF) endif() + target_link_libraries(libsimulate + PUBLIC + lodepng + mujoco::platform_ui_adapter + mujoco::mujoco + PRIVATE + # Add any private dependencies here +) if(_INSTALL_SIMULATE) include(TargetAddRpath) @@ -246,9 +262,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") + + 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 +288,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() From 832229a846e10f4ce51d4f377cc8a118dd9f67ba Mon Sep 17 00:00:00 2001 From: vidurvij-apptronik <152456958+vidurvij-apptronik@users.noreply.github.com> Date: Mon, 28 Oct 2024 09:25:38 -0500 Subject: [PATCH 2/4] Update CMakeLists.txt --- simulate/CMakeLists.txt | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/simulate/CMakeLists.txt b/simulate/CMakeLists.txt index b8a3c294c4..7bd54e3695 100644 --- a/simulate/CMakeLists.txt +++ b/simulate/CMakeLists.txt @@ -137,7 +137,8 @@ target_sources( platform_ui_adapter.h glfw_adapter.h glfw_dispatch.h - PRIVATE simulate.cc array_safety.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}) @@ -231,14 +232,6 @@ if(SIMULATE_BUILD_EXECUTABLE) set(_INSTALL_SIMULATE OFF) endif() - target_link_libraries(libsimulate - PUBLIC - lodepng - mujoco::platform_ui_adapter - mujoco::mujoco - PRIVATE - # Add any private dependencies here -) if(_INSTALL_SIMULATE) include(TargetAddRpath) @@ -267,7 +260,7 @@ if(SIMULATE_BUILD_EXECUTABLE) # 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") + 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 From 9dd05d3b65eb205f36dbc9b28759aa229d38c323 Mon Sep 17 00:00:00 2001 From: vidurvij-apptronik <152456958+vidurvij-apptronik@users.noreply.github.com> Date: Mon, 28 Oct 2024 09:25:54 -0500 Subject: [PATCH 3/4] Update SimulateDependencies.cmake --- simulate/cmake/SimulateDependencies.cmake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/simulate/cmake/SimulateDependencies.cmake b/simulate/cmake/SimulateDependencies.cmake index 5141406cd9..9ba1d5e82b 100644 --- a/simulate/cmake/SimulateDependencies.cmake +++ b/simulate/cmake/SimulateDependencies.cmake @@ -102,3 +102,23 @@ if(NOT SIMULATE_STANDALONE) target_compile_options(glfw PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS}) target_link_options(glfw PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS}) endif() + + +message(STATUS "lolwaGLFW3 Source Directory: ${glfw3_SOURCE_DIR}") + +# 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() From 64d274f7f3109766795c234cb350b3d18a180f02 Mon Sep 17 00:00:00 2001 From: vidurvij-apptronik <152456958+vidurvij-apptronik@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:25:11 -0600 Subject: [PATCH 4/4] Cleanup --- simulate/CMakeLists.txt | 4 ---- simulate/cmake/SimulateDependencies.cmake | 3 --- 2 files changed, 7 deletions(-) diff --git a/simulate/CMakeLists.txt b/simulate/CMakeLists.txt index 7bd54e3695..404f929f8e 100644 --- a/simulate/CMakeLists.txt +++ b/simulate/CMakeLists.txt @@ -41,16 +41,12 @@ if(APPLE) enable_language(OBJCXX) endif() -if(NOT DEFINED expose_headers) - -endif() option(SIMULATE_BUILD_EXECUTABLE "Build the simulate executable binary." ON) option(SIMULATE_GLFW_DYNAMIC_SYMBOLS "Whether to resolve GLFW symbols dynamically." OFF) # Check if we are building as standalone project. set(SIMULATE_STANDALONE OFF) set(_INSTALL_SIMULATE ON) -set(EXPOSE_HEADERS OFF) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) set(SIMULATE_STANDALONE ON) # If standalone, do not install the samples. diff --git a/simulate/cmake/SimulateDependencies.cmake b/simulate/cmake/SimulateDependencies.cmake index 9ba1d5e82b..91981cbc2d 100644 --- a/simulate/cmake/SimulateDependencies.cmake +++ b/simulate/cmake/SimulateDependencies.cmake @@ -103,9 +103,6 @@ if(NOT SIMULATE_STANDALONE) target_link_options(glfw PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS}) endif() - -message(STATUS "lolwaGLFW3 Source Directory: ${glfw3_SOURCE_DIR}") - # Install GLFW headers if not using system GLFW if(NOT MUJOCO_SIMULATE_USE_SYSTEM_GLFW) FetchContent_GetProperties(glfw3)