Replace USES_ROS through Catkin auto-detection. (#128)

master
Damon Kohler 2016-11-17 11:01:46 +01:00 committed by GitHub
parent ac92dd8cbf
commit 03c8e8d195
2 changed files with 13 additions and 16 deletions

View File

@ -30,7 +30,6 @@ macro(_parse_arguments ARGS)
list(APPEND OPTIONS list(APPEND OPTIONS
USES_CARTOGRAPHER USES_CARTOGRAPHER
USES_PCL USES_PCL
USES_ROS
USES_YAMLCPP USES_YAMLCPP
) )
set(ONE_VALUE_ARG ) set(ONE_VALUE_ARG )
@ -42,6 +41,14 @@ endmacro(_parse_arguments)
macro(_common_compile_stuff VISIBILITY) macro(_common_compile_stuff VISIBILITY)
set(TARGET_COMPILE_FLAGS "${TARGET_COMPILE_FLAGS} ${GOOG_CXX_FLAGS}") set(TARGET_COMPILE_FLAGS "${TARGET_COMPILE_FLAGS} ${GOOG_CXX_FLAGS}")
if(catkin_INCLUDE_DIRS)
target_include_directories("${NAME}" SYSTEM ${VISIBILITY}
"${catkin_INCLUDE_DIRS}")
target_link_libraries("${NAME}" ${catkin_LIBRARIES})
add_dependencies("${NAME}" ${catkin_EXPORTED_TARGETS}
)
endif()
if(ARG_USES_EIGEN) if(ARG_USES_EIGEN)
target_include_directories("${NAME}" SYSTEM ${VISIBILITY} target_include_directories("${NAME}" SYSTEM ${VISIBILITY}
"${EIGEN3_INCLUDE_DIR}") "${EIGEN3_INCLUDE_DIR}")
@ -79,14 +86,6 @@ macro(_common_compile_stuff VISIBILITY)
target_link_libraries("${NAME}" gflags) target_link_libraries("${NAME}" gflags)
endif() endif()
if(ARG_USES_ROS)
target_include_directories("${NAME}" SYSTEM ${VISIBILITY}
"${catkin_INCLUDE_DIRS}")
target_link_libraries("${NAME}" ${catkin_LIBRARIES})
add_dependencies("${NAME}" ${catkin_EXPORTED_TARGETS}
)
endif()
if(ARG_USES_CARTOGRAPHER) if(ARG_USES_CARTOGRAPHER)
target_include_directories("${NAME}" SYSTEM ${VISIBILITY} target_include_directories("${NAME}" SYSTEM ${VISIBILITY}
"${CARTOGRAPHER_INCLUDE_DIRS}") "${CARTOGRAPHER_INCLUDE_DIRS}")
@ -222,7 +221,7 @@ macro(_common_test_stuff)
target_link_libraries("${NAME}" ${GMOCK_LIBRARIES}) target_link_libraries("${NAME}" ${GMOCK_LIBRARIES})
endmacro() endmacro()
function(google_catkin_test NAME) function(_google_catkin_test NAME)
if(NOT "${CATKIN_ENABLE_TESTING}") if(NOT "${CATKIN_ENABLE_TESTING}")
return() return()
endif() endif()
@ -241,6 +240,10 @@ function(google_catkin_test NAME)
endfunction() endfunction()
function(google_test NAME) function(google_test NAME)
if (catkin_INCLUDE_DIRS)
_google_catkin_test(${ARGV})
return()
endif()
_parse_arguments("${ARGN}") _parse_arguments("${ARGN}")
_common_test_stuff() _common_test_stuff()
add_test(${NAME} ${NAME}) add_test(${NAME} ${NAME})

View File

@ -107,10 +107,6 @@ def ExtractUses(project_name, source):
uses.add("USES_WEBP") uses.add("USES_WEBP")
if re.match(r'^#include ["<]pcl/', line): if re.match(r'^#include ["<]pcl/', line):
uses.add("USES_PCL") uses.add("USES_PCL")
if re.match(r'^#include ["<]ros/', line):
uses.add("USES_ROS")
if re.match(r'^#include "[a-zA-Z]*_msgs/', line):
uses.add("USES_ROS")
if re.match(r'^#include ["<]yaml-cpp/', line): if re.match(r'^#include ["<]yaml-cpp/', line):
uses.add("USES_YAMLCPP") uses.add("USES_YAMLCPP")
if re.match(r'^#include ["<]cairo/', line): if re.match(r'^#include ["<]cairo/', line):
@ -248,8 +244,6 @@ def RunOnDirectory(root):
continue continue
target.depends.add(dependant.name) target.depends.add(dependant.name)
target.uses.update(ExtractUses(project_name, src)) target.uses.update(ExtractUses(project_name, src))
if target.type is "google_test" and "USES_ROS" in target.uses:
target.type = "google_catkin_test"
cmake_file = path.join(directory, "CMakeLists.txt") cmake_file = path.join(directory, "CMakeLists.txt")
parts = GetNonGoogleTargetLines(cmake_file) parts = GetNonGoogleTargetLines(cmake_file)