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

added cmake function for installing mujoco assets #16

Open
wants to merge 1 commit 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
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ cmake_minimum_required(VERSION 3.22)
project(picknik_accessories)

find_package(ament_cmake REQUIRED)
find_package(ament_index_cpp REQUIRED)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")

include(InstallPicknikAccessories)

install(
DIRECTORY
Expand All @@ -11,6 +16,15 @@ install(
DESTINATION
share/${PROJECT_NAME}
)

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/InstallPicknikAccessories.cmake"
DESTINATION lib/cmake/picknik_accessories/Modules)

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/picknik_accessoriesConfig.cmake"
DESTINATION lib/cmake/picknik_accessories)

ament_export_dependencies(ament_cmake ament_index_cpp)

# TODO: is this lint process hanging somehow?
# if(BUILD_TESTING)
# find_package(ament_lint_auto REQUIRED)
Expand Down
24 changes: 24 additions & 0 deletions cmake/Modules/InstallPicknikAccessories.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function(install_picknik_accessories)
set(options)
set(oneValueArgs DESTINATION)
cmake_parse_arguments(INSTALL_PICKNIK "" "${oneValueArgs}" "" ${ARGN})

if(NOT INSTALL_PICKNIK_DESTINATION)
message(FATAL_ERROR "DESTINATION argument is required for install_picknik_accessories()")
endif()

# Check if PICKNIK_ACCESSORIES_SHARE_DIR is defined
if(NOT DEFINED PICKNIK_ACCESSORIES_SHARE_DIR)
message(FATAL_ERROR "PICKNIK_ACCESSORIES_SHARE_DIR is not defined.")
endif()

# Verify that the assets directory exists
if(NOT EXISTS "${PICKNIK_ACCESSORIES_SHARE_DIR}")
message(FATAL_ERROR "Source directory '${PICKNIK_ACCESSORIES_SHARE_DIR}' does not exist.")
endif()

# Install the XML files from the assets directory to the specified destination
install(DIRECTORY "${PICKNIK_ACCESSORIES_SHARE_DIR}/"
DESTINATION "${INSTALL_PICKNIK_DESTINATION}"
FILES_MATCHING PATTERN "*.xml")
endfunction()
8 changes: 8 additions & 0 deletions cmake/picknik_accessoriesConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Get the absolute path to the package prefix
get_filename_component(PICKNIK_ACCESSORIES_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)

# Define the share directory where assets are installed
set(PICKNIK_ACCESSORIES_SHARE_DIR "${PICKNIK_ACCESSORIES_PREFIX}/share/picknik_accessories/mujoco_assets")

# Include the InstallPicknikAccessories module
include("${CMAKE_CURRENT_LIST_DIR}/Modules/InstallPicknikAccessories.cmake")
3 changes: 0 additions & 3 deletions mujoco_assets/assets/Cube copy.stl

This file was deleted.