forked from ros-industrial/abb_robot_driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
160 lines (135 loc) · 4.56 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
cmake_minimum_required(VERSION 3.9.1)
########################################################################################################################
# Metadata
########################################################################################################################
# Read the package manifest.
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/package.xml" package_xml_str)
# Extract project name.
if(NOT package_xml_str MATCHES "<name>([A-Za-z0-9_]+)</name>")
message(FATAL_ERROR "Could not parse project name from package manifest (aborting)")
else()
set(extracted_name ${CMAKE_MATCH_1})
endif()
# Extract project version.
if(NOT package_xml_str MATCHES "<version>([0-9]+.[0-9]+.[0-9]+)</version>")
message(FATAL_ERROR "Could not parse project version from package manifest (aborting)")
else()
set(extracted_version ${CMAKE_MATCH_1})
endif()
########################################################################################################################
# CMake project
########################################################################################################################
project(${extracted_name} VERSION ${extracted_version} LANGUAGES CXX)
#===========================================================
# Dependencies
#===========================================================
#-----------------------------
# ABB robot controller
# communication package
#-----------------------------
find_package(abb_egm_rws_managers REQUIRED)
#-----------------------------
# Catkin packages
#-----------------------------
find_package(catkin REQUIRED
COMPONENTS
abb_rapid_sm_addin_msgs
abb_robot_cpp_utilities
abb_robot_msgs
roscpp
sensor_msgs
)
#===========================================================
# Catkin package specific configurations
#===========================================================
catkin_package(
INCLUDE_DIRS
include
LIBRARIES
${PROJECT_NAME}
CATKIN_DEPENDS
abb_rapid_sm_addin_msgs
abb_robot_cpp_utilities
abb_robot_msgs
roscpp
sensor_msgs
DEPENDS
abb_egm_rws_managers
)
#===========================================================
# Settings
#===========================================================
if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif()
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
message(STATUS "${PROJECT_NAME}: Defaulting build type to RelWithDebInfo")
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
#===========================================================
# Build targets
#===========================================================
set(target_name ${PROJECT_NAME})
#-----------------------------
# Library target
#-----------------------------
set(
src_files
src/rws_state_publisher.cpp
)
add_library(${target_name} ${src_files})
target_include_directories(${target_name} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
"${catkin_INCLUDE_DIRS}"
)
target_link_libraries(${target_name} PUBLIC
abb_egm_rws_managers::abb_egm_rws_managers
${catkin_LIBRARIES}
)
target_compile_features(${target_name} PRIVATE cxx_std_14)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${target_name} PRIVATE /W4)
endif()
#-----------------------------
# Executable target
#-----------------------------
set(
src_files
src/main.cpp
)
add_executable(${target_name}_exe ${src_files})
target_link_libraries(${target_name}_exe PRIVATE
${target_name}
)
target_compile_features(${target_name}_exe PRIVATE cxx_std_14)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${target_name}_exe PRIVATE -Wall -Wextra -Wpedantic)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${target_name}_exe PRIVATE /W4)
endif()
set_target_properties(${target_name}_exe
PROPERTIES
OUTPUT_NAME "rws_state_publisher"
)
#===========================================================
# Install
#===========================================================
install(
TARGETS
${PROJECT_NAME}
${PROJECT_NAME}_exe
ARCHIVE DESTINATION "${CATKIN_PACKAGE_LIB_DESTINATION}"
LIBRARY DESTINATION "${CATKIN_PACKAGE_LIB_DESTINATION}"
RUNTIME DESTINATION "${CATKIN_PACKAGE_BIN_DESTINATION}"
)
install(
DIRECTORY include/${PROJECT_NAME}/
DESTINATION "${CATKIN_PACKAGE_INCLUDE_DESTINATION}"
)
install(
DIRECTORY launch
DESTINATION "${CATKIN_PACKAGE_SHARE_DESTINATION}"
)