An error occurred while using macro to customize the timeout time of gtest in cmake
Hi,
I used the following way to customize the timeout time of gtest in cmake, but an error occurred:
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
find_package(InferenceEngine REQUIRED)
ament_lint_auto_find_test_dependencies()
macro(custom_gtest target)
ament_add_gtest(${target} ${ARGN})
if(TARGET ${target})
target_include_directories(${target} PUBLIC
${${PROJECT_NAME}_INCLUDE_DIRS}
)
ament_target_dependencies(${target}
rclcpp
InferenceEngine)
endif()
endmacro()
macro(targets)
custom_gtest(unit_environment
"tests/unit_environment.cpp"
TIMEOUT 300)
endmacro()
call_for_each_rmw_implementation(targets)
endif()
The error log:
CMake Error at /home/intel/ros2_ws/install/ament_cmake_gtest/share/ament_cmake_gtest/cmake/ament_add_gtest_executable.cmake:50 (add_executable):
add_executable cannot create target "unit_environment" because another
target with the same name already exists. The existing target is an
executable created in source directory
"/home/intel/ros2_overlay_ws/src/ros2_openvino_toolkit/sample". See
documentation for policy CMP0002 for more details
Call Stack (most recent call first):
/home/intel/ros2_ws/install/ament_cmake_gtest/share/ament_cmake_gtest/cmake/ament_add_gtest_executable.cmake:37 (_ament_add_gtest_executable)
/home/intel/ros2_ws/install/ament_cmake_gtest/share/ament_cmake_gtest/cmake/ament_add_gtest.cmake:66 (ament_add_gtest_executable)
CMakeLists.txt:199 (ament_add_gtest)
CMakeLists.txt:211 (custom_gtest)
/home/intel/ros2_overlay_ws/build/dynamic_vino_sample/call_for_each_rmw_implementation.cmake:1 (targets)
/home/intel/ros2_ws/install/rmw_implementation_cmake/share/rmw_implementation_cmake/cmake/call_for_each_rmw_implementation.cmake:64 (include)
CMakeLists.txt:216 (call_for_each_rmw_implementation)
How can I slove this problem?
Thanks very much.