-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
111 lines (87 loc) · 2.88 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
cmake_minimum_required(VERSION 2.8)
include(parse_arguments.cmake)
set(GENCPP_EXE /home/morten/gencpp/scripts/genmsg_cpp.py)
set(TOP /home/morten/genmsg/test/files)
macro(show VAR)
message(STATUS ">>>> ${VAR} ${${VAR}}")
endmacro()
macro(generate PKG)
parse_arguments(PKG "MESSAGES;DEPENDENCIES" "" ${ARGN})
message("PKG: ${PKG} MSGS: ${PKG_MESSAGES} DEPNDS: ${PKG_DEPENDENCIES}")
set(ALL_OUTPUTS "")
foreach(MSGPATH ${PKG_MESSAGES})
get_filename_component(SHORTNAME ${MSGPATH} NAME_WE)
configure_file(${TOP}/${PKG}/msg/${MSGPATH}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${MSGPATH}.stamp
)
set(GENERATED_NAME ${PKG}/${SHORTNAME}.h)
list(APPEND GENERATED_ALL ${GENERATED_NAME})
set(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PKG}/${SHORTNAME}.h)
message(STATUS "Output=${OUTPUT}")
set(IFLAGS "")
set(DEP_TARGETS "")
foreach(dep ${PKG_DEPENDENCIES})
set(IFLAGS -I${dep}:${TOP}/${dep}/msg ${IFLAGS})
list(APPEND DEP_TARGETS ${dep}_gencpp)
endforeach()
set(INPUT_FULLPATH ${TOP}/${PKG}/msg/${MSGPATH})
set(THESEDEPS "")
execute_process(COMMAND
${GENCPP_EXE} ${INPUT_FULLPATH} -d ${IFLAGS}
OUTPUT_VARIABLE THESEDEPS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
separate_arguments(THESEDEPS UNIX_COMMAND ${THESEDEPS})
show(THESEDEPS)
add_custom_command(OUTPUT ${OUTPUT}
DEPENDS ${INPUT_FULLPATH} ${THESEDEPS} ${GENCPP_EXE}
COMMAND ${GENCPP_EXE} ${INPUT_FULLPATH}
-p ${PKG}
-o ${CMAKE_CURRENT_BINARY_DIR}/${PKG}
${IFLAGS}
COMMENT "Generating C++ code from ${PKG}/${SHORTNAME}"
)
list(APPEND ALL_OUTPUTS ${OUTPUT})
endforeach()
show(ALL_OUTPUTS)
add_custom_target(${PKG}_gencpp
DEPENDS ${ALL_OUTPUTS}
)
show(DEP_TARGETS)
if(DEP_TARGETS)
add_dependencies(${PKG}_gencpp ${DEP_TARGETS})
endif(DEP_TARGETS)
endmacro()
add_custom_target(touch
COMMAND touch ${TOP}/*/msg/*.msg
COMMENT TOUCHY TOUCHY
)
generate(std_msgs
MESSAGES Header.msg
)
generate(geometry_msgs
MESSAGES Quaternion.msg Vector3.msg Point.msg
DEPENDENCIES std_msgs
)
generate(sensor_msgs
MESSAGES Imu.msg LaserScan.msg
DEPENDENCIES geometry_msgs std_msgs
)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(
/opt/ros/electric/stacks/ros_comm/utilities/cpp_common/include/
/opt/ros/electric/stacks/ros_comm/utilities/rostime/include/
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_serialization/include/
/opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp_traits/include/)
add_executable(main main.cpp)
add_dependencies(main sensor_msgs_gencpp)
# use this to provoke removal of generated headers
set_directory_properties(PROPERTIES
CLEAN_NO_CUSTOM FALSE
)
#set_source_files_properties(
# std_msgs/Header.h
# geometry_msgs/Vector3.h
# geometry_msgs/Quaternion.h
# PROPERTIES
# GENERATED TRUE)