forked from LORD-MicroStrain/microstrain_inertial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
68 lines (58 loc) · 2.12 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
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_STANDARD 14)
project(microstrain_inertial_msgs)
# Some ROS version specific defines
if(DEFINED ENV{ROS_DISTRO})
if ("$ENV{ROS_DISTRO}" STREQUAL "rolling")
set(EXTRA_DEPS service_msgs)
elseif ("$ENV{ROS_DISTRO}" STREQUAL "iron")
set(EXTRA_DEPS service_msgs)
elseif ("$ENV{ROS_DISTRO}" STREQUAL "humble")
elseif ("$ENV{ROS_DISTRO}" STREQUAL "galactic")
elseif ("$ENV{ROS_DISTRO}" STREQUAL "foxy")
else()
set(EXTRA_DEPS service_msgs)
endif()
endif()
find_package(ament_cmake REQUIRED)
find_package(rosidl_default_runtime REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
foreach (EXTRA_DEP IN LISTS EXTRA_DEPS)
find_package(${EXTRA_DEP} REQUIRED)
endforeach()
# Locate the common code and messages
set(COMMON_NAME "microstrain_inertial_msgs_common")
set(COMMON_DIR "${${PROJECT_NAME}_SOURCE_DIR}/${COMMON_NAME}")
# Make sure that the submodule has been properly initialized
if(NOT EXISTS "${COMMON_DIR}/msg")
message(STATUS "Initializing ${COMMON_DIR} submodule. This should only happen once.")
# Make sure we can find the git executable
find_package(Git)
if(NOT Git_FOUND)
message(FATAL_ERROR "Unable to initialize submodule because we could not find the git executable. Please clone this repo using 'git clone --recursive'")
endif()
# Initialize and update the submodule
execute_process(
WORKING_DIRECTORY "${${PROJECT_NAME}_SOURCE_DIR}"
COMMAND ${CMAKE_COMMAND} -E env ${GIT_EXECUTABLE} submodule update --init --recursive
)
endif()
# Generate Service Files
set(SRV_DIR "${COMMON_DIR}/srv")
file(GLOB SRV_FILES RELATIVE "${SRV_DIR}"
"${SRV_DIR}/*.srv")
list(TRANSFORM SRV_FILES PREPEND ${COMMON_DIR}:srv/)
# Generate Message Files
set(MSG_DIR "${COMMON_DIR}/msg")
file(GLOB MSG_FILES RELATIVE "${MSG_DIR}"
"${MSG_DIR}/*.msg")
list(TRANSFORM MSG_FILES PREPEND ${COMMON_DIR}:msg/)
rosidl_generate_interfaces(${PROJECT_NAME}
${MSG_FILES}
${SRV_FILES}
DEPENDENCIES std_msgs geometry_msgs ${EXTRA_DEPS}
)
ament_export_dependencies(rosidl_default_runtime)
ament_package()