Skip to content

Commit 1151172

Browse files
committed
Add version dependency to gencpp>=0.6.0 (plugin support)
Generation and renaming of the C++ message header causes CMake dependency issues if the message generation and the ROS transport plugin library is in the same package.
1 parent 4eed9dc commit 1151172

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

CMakeLists.txt

+6-18
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ find_package(catkin REQUIRED COMPONENTS
1010
std_msgs
1111
)
1212

13+
## Make sure we have gencpp >= 0.6.0 which does not generate C++ headers
14+
## if the package already provides one (plugin support).
15+
if(gencpp_VERSION AND gencpp_VERSION VERSION_LESS "0.6.0")
16+
message(FATAL_ERROR "${PROJECT_NAME} requires gencpp version 0.6.0 or higher.")
17+
endif()
18+
1319
## Uncomment this if the package has a setup.py. This macro ensures
1420
## modules and global scripts declared therein get installed
1521
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
@@ -49,24 +55,6 @@ catkin_package(
4955
## Build ##
5056
###########
5157

52-
## Language: cpp
53-
if(gencpp_VERSION VERSION_LESS "0.6.0" AND
54-
TARGET ${PROJECT_NAME}_generate_messages_cpp)
55-
## Overwrite generated header files in devel-space
56-
file(GLOB HEADERS
57-
"${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}/*.h"
58-
)
59-
60-
configure_file(cmake/rename_generated_header_files.cmake.in cmake/rename_generated_header_files.cmake @ONLY)
61-
add_custom_target(${PROJECT_NAME}_rename_generated_header_files
62-
DEPENDS ${HEADERS}
63-
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/rename_generated_header_files.cmake
64-
COMMENT "Moving generated C++ header files to include/${PROJECT_NAME}/generated/."
65-
)
66-
add_dependencies(${PROJECT_NAME}_rename_generated_header_files ${PROJECT_NAME}_generate_messages_cpp)
67-
add_dependencies(${PROJECT_NAME}_generate_messages ${PROJECT_NAME}_rename_generated_header_files)
68-
endif()
69-
7058
## Build ROS transport plugin library
7159
if(TARGET ${PROJECT_NAME}_generate_messages_cpp)
7260
if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "Release")

package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<build_export_depend>message_generation</build_export_depend>
1616
<exec_depend>message_runtime</exec_depend>
1717

18+
<build_depend version_gte="0.6.0">gencpp</build_depend>
1819
<depend>rtt_roscomm</depend>
1920
<depend>std_msgs</depend>
2021

0 commit comments

Comments
 (0)