-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
95 lines (83 loc) · 2.52 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
cmake_minimum_required(VERSION 3.16)
project(mujoco_ros_py)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-error -Wno-dev)
endif()
# Add the directory containing your macros
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(FindOrFetch)
FindOrFetch(
USE_SYSTEM_PACKAGE
OFF
PACKAGE_NAME
mujoco
LIBRARY_NAME
mujoco
GIT_REPO
https://github.com/google-deepmind/mujoco.git
GIT_TAG
3.1.1
TARGETS
mujoco::mujoco
mujoco::platform_ui_adapter
EXCLUDE_FROM_ALL
)
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(rosgraph_msgs REQUIRED)
find_package(rclcpp REQUIRED)
find_package(glfw3 REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
find_package(pybind11_vendor REQUIRED)
find_package(pybind11 REQUIRED)
# 1. build a static C++ library for python bindings to link against
# include python development headers
include_directories(${Python3_INCLUDE_DIRS})
# add a static library for python bindings to link against
add_library(mujoco_ros_envs STATIC
src/mujoco_ros.cpp
)
target_include_directories(mujoco_ros_envs PUBLIC
${PROJECT_SOURCE_DIR}/include
${OpenCV_INCLUDE_DIRS}
)
target_link_libraries(mujoco_ros_envs PUBLIC
mujoco::mujoco
mujoco::platform_ui_adapter
rclcpp::rclcpp
std_msgs::std_msgs__rosidl_generator_c
sensor_msgs::sensor_msgs__rosidl_typesupport_c
sensor_msgs::sensor_msgs__rosidl_typesupport_cpp
sensor_msgs::sensor_msgs__rosidl_generator_c
geometry_msgs::geometry_msgs__rosidl_generator_c
rosgraph_msgs::rosgraph_msgs__rosidl_generator_c
glfw
${OpenCV_LIBS}
)
set_target_properties(mujoco_ros_envs PROPERTIES POSITION_INDEPENDENT_CODE ON)
install(TARGETS mujoco_ros_envs
DESTINATION lib/${PROJECT_NAME}
)
# 2. build python bindings
ament_python_install_package(mujoco_ros)
# Set the build location and install location for a CPython extension
function(configure_build_install_location library_name)
install(TARGETS ${library_name} DESTINATION "${PYTHON_INSTALL_DIR}/mujoco_ros")
endfunction()
pybind11_add_module(franka_env
src/franka_env.cpp
)
target_include_directories(mujoco_ros_envs PUBLIC
${PROJECT_SOURCE_DIR}/include
)
target_link_libraries(
franka_env PRIVATE
mujoco_ros_envs
)
set_target_properties(franka_env PROPERTIES INSTALL_RPATH "${CMAKE_BINARY_DIR}/lib")
configure_build_install_location(franka_env)
ament_package()