-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
136 lines (109 loc) · 4.05 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
cmake_minimum_required(VERSION 3.10)
project(schunk_svh_simulation)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# We need C++17
set(CMAKE_CXX_STANDARD 17)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
# GLFW
# With PkgConfig is the official way: https://www.glfw.org/docs/3.0/build.html#build_link_cmake_pkgconfig
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
# GLEW
find_package(GLEW REQUIRED)
# Mujoco comes as a pre-built library package.
# Extract this package somewhere and point CMake towards it during the build process.
if(NOT DEFINED MUJOCO_DIR)
set(MUJOCO_DIR "$ENV{HOME}/mujoco-3.2.3") # CI setting
message(WARNING "MUJOCO_DIR not specified. Using default ${MUJOCO_DIR}")
endif()
set(MUJOCO_INCLUDE_DIRS ${MUJOCO_DIR}/include)
set(MUJOCO_LIBRARIES
${MUJOCO_DIR}/lib/libmujoco.so
)
# --------------------------------------------------------------------------------
# Make sure that library relocation works for both build and install.
# See here: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
# --------------------------------------------------------------------------------
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# The RPATH to use when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif()
#--------------------------------------------------------------------------------
# Build
#--------------------------------------------------------------------------------
add_library(${PROJECT_NAME} SHARED
src/system_interface.cpp
)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
ament_target_dependencies(${PROJECT_NAME}
hardware_interface
pluginlib
rclcpp
)
target_link_libraries(${PROJECT_NAME}
mujoco_simulator
)
pluginlib_export_plugin_description_file(hardware_interface schunk_svh_simulation.xml)
#--------------------------------------------------------------------------------
add_library(mujoco_simulator SHARED
src/mujoco_simulator.cpp
)
target_include_directories(mujoco_simulator PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${MUJOCO_INCLUDE_DIRS}
${GLFW_INCLUDE_DIRS}
)
# X11 OpenGL: link with libmujoco210.so, libglew.so, libGL.so
target_link_libraries(mujoco_simulator PUBLIC
${MUJOCO_LIBRARIES}
${GLFW_LIBRARIES}
GLEW::GLEW
)
#--------------------------------------------------------------------------------
# Install
#--------------------------------------------------------------------------------
install(
DIRECTORY include/
DESTINATION include
)
install(
DIRECTORY etc launch meshes urdf
DESTINATION share/${PROJECT_NAME}
)
install(
TARGETS ${PROJECT_NAME} mujoco_simulator
DESTINATION lib
)
#--------------------------------------------------------------------------------
# Test
#--------------------------------------------------------------------------------
#if(BUILD_TESTING)
# find_package(ament_lint_auto REQUIRED)
# # the following line skips the linter which checks for copyrights
# # uncomment the line when a copyright and license is not present in all source files
# #set(ament_cmake_copyright_FOUND TRUE)
# # the following line skips cpplint (only works in a git repo)
# # uncomment the line when this package is not in a git repo
# #set(ament_cmake_cpplint_FOUND TRUE)
# ament_lint_auto_find_test_dependencies()
#endif()
ament_package()