-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
218 lines (180 loc) · 9.44 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
cmake_minimum_required(VERSION 3.5.1)
project(tmr_listener VERSION 0.5.0)
#####################################################################
# Check if all plugins are built under same TMFlow version #
#####################################################################
set(${PROJECT_NAME}_TMFLOW_SUPPORT_VERSION_MAX 1.84)
if (NOT DEFINED TMR_TMFLOW_VERSION)
set(TMR_TMFLOW_VERSION ${${PROJECT_NAME}_TMFLOW_SUPPORT_VERSION_MAX} CACHE STRING "User-specified target TMFlow version" FORCE)
elseif (${TMR_TMFLOW_VERSION} VERSION_GREATER ${${PROJECT_NAME}_TMFLOW_SUPPORT_VERSION_MAX})
message(FATAL_ERROR "Target version is greater than max supported" " version ${${PROJECT_NAME}_TMFLOW_SUPPORT_VERSION_MAX}.")
endif ()
# __TMR_TMFLOW_VERSION is internally used by tmr_listener
if (NOT DEFINED __TMR_TMFLOW_VERSION)
set(__TMR_TMFLOW_VERSION ${TMR_TMFLOW_VERSION} CACHE INTERNAL "The version of TMFlow that TMR Listener is built with initially" FORCE)
else ()
if (NOT ${__TMR_TMFLOW_VERSION} VERSION_EQUAL ${TMR_TMFLOW_VERSION})
message(FATAL_ERROR "TMR Listener is built with TMFlow version ${__TMR_TMFLOW_VERSION} initially."
"To built with other version, you must call \"catkin clean tmr_listener\" and rebuild all plugins")
endif ()
endif ()
string(REPLACE "." ";" __TMR_TMRFLOW_VERSION_COMPONENT ${__TMR_TMFLOW_VERSION})
set(${PROJECT_NAME}_TMFLOW_SUPPORT_VERSION ${__TMR_TMFLOW_VERSION})
list(GET __TMR_TMRFLOW_VERSION_COMPONENT 0 ${PROJECT_NAME}_TMFLOW_SUPPORT_VERSION_MAJOR)
list(GET __TMR_TMRFLOW_VERSION_COMPONENT 1 ${PROJECT_NAME}_TMFLOW_SUPPORT_VERSION_MINOR)
configure_file(${PROJECT_SOURCE_DIR}/include/version.hpp.in ${PROJECT_SOURCE_DIR}/include/version.hpp @ONLY)
#############################################################
# Generate custom ethernet message if specified #
#############################################################
if (DEFINED TM_ETHERNET_SLAVE_XML OR EXISTS ${PROJECT_SOURCE_DIR}/msg/TMREthernet.msg)
set(TM_ETHERNET_MSG TMREthernet.msg)
if (DEFINED TM_ETHERNET_SLAVE_XML)
execute_process(COMMAND ${PROJECT_SOURCE_DIR}/scripts/parse_tm_ethernet_xml.py --xml-dir=${TM_ETHERNET_SLAVE_XML}
--msg-dir=${PROJECT_SOURCE_DIR}/msg/${TM_ETHERNET_MSG} RESULT_VARIABLE result)
endif ()
if (result)
message(FATAL_ERROR "Generating TMEthernet.msg failed: ${result}")
endif ()
add_message_files(FILES ${TM_ETHERNET_MSG})
endif ()
# INTERPROCEDURAL_OPTIMIZATION is enforced when enabled. This policy takes effect whenever the IPO property is enabled.
# The OLD behavior for this policy is to add IPO flags only for Intel compiler on Linux. The NEW behavior for this policy
# is to add IPO flags for the current compiler or produce an error if CMake does not know the flags.
if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif ()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(CCache)
include(StandardProjectSetting)
include(CatkinExtension)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (MSVC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.29)
# This is a temporary solution to suppress warnings 3rd party library in MSVC
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /external:W0")
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "/external:I ")
endif ()
find_package(catkin REQUIRED COMPONENTS roscpp message_generation pluginlib)
if (WIN32)
# This workspace did not take precedence over ros root workspace, which results in wrong googletest dll being loaded.
# And since I can't find a clean way to manipulate googletest build process (unless I embedded it into my project?),
# it is impossible for me to determine where those artifacts will be after they were built.
catkin_add_env_hooks(set_path SHELLS bat DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tool/env-hook)
endif ()
# some of the components are used by catkin internally, but I don't want to pull in all
# catkin dependencies to a target just for one or two components, plus it makes no sense.
# Therefore, these components are found explicitly.
find_package(Boost REQUIRED COMPONENTS system)
################################################
## Declare ROS messages, services and actions ##
################################################
## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
## Generate messages in the 'msg' folder
add_message_files(FILES JsonData.msg JsonDataArray.msg SubCmdDataMsg.msg)
## Generate services in the 'srv' folder
add_service_files(FILES EthernetSlaveCmd.srv)
## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )
## Generate added messages and services with any dependencies listed here
generate_messages()
################################################
## Declare ROS dynamic reconfigure parameters ##
################################################
## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed
## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )
###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(INCLUDE_DIRS include LIBRARIES tmr_listener CATKIN_DEPENDS roscpp message_runtime pluginlib # DEPENDS system_lib
)
#############
## Install ##
#############
# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# catkin_install_python(PROGRAMS
# scripts/my_python_script
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark executables for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
# install(TARGETS ${PROJECT_NAME}_node
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )
## Mark libraries for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
# install(TARGETS ${PROJECT_NAME}
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
# )
## Mark cpp header files for installation
# need to make sure this is done right, come back to this later
# install(DIRECTORY include/tmr_listener include/tmr_utility include/tmr_ext_script
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}/..)
include(StaticAnalyzers)
include(Sanitizers)
add_library(project_options INTERFACE)
enable_sanitizers(project_options)
include(CompilerWarning)
add_library(project_warnings INTERFACE)
set_project_warnings(project_warnings)
add_library(catkin_lib INTERFACE)
option(DISABLE_LOGGING "Compile out all ros console logging, this option is intended for static analyzers and sanitizers" FALSE)
target_compile_definitions(catkin_lib INTERFACE $<$<BOOL:${DISABLE_LOGGING}>:ROSCONSOLE_MIN_SEVERITY=ROSCONSOLE_SEVERITY_NONE>)
target_link_libraries(catkin_lib INTERFACE ${catkin_LIBRARIES})
target_include_directories(catkin_lib SYSTEM INTERFACE ${catkin_INCLUDE_DIRS})
target_include_directories(catkin_lib INTERFACE ${PROJECT_SOURCE_DIR}/include)
add_subdirectory(src)
option(TMR_ENABLE_TESTING "enable tm robot unit testing" OFF)
if (TMR_ENABLE_TESTING)
add_subdirectory(test)
if (ENABLE_COVERAGE)
catkin_add_gcov_report(
REPORT_NAME "coverage.xml" GCOV_EXCLUDE ".*test.*" EXCLUDE_SRC "${PROJECT_SOURCE_DIR}/src/tmr_cmd_line_option.hpp"
EXTRA_OPTIONS --xml-pretty --exclude-unreachable-branches --exclude-throw-branches)
endif ()
endif ()