|
| 1 | +# Copyright (c) 2025-present WATonomous. All rights reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# Copyright (c) 2025-present Polymath Robotics, Inc. All rights reserved |
| 15 | +# Proprietary. Any unauthorized copying, distribution, or modification of this software is strictly prohibited. |
| 16 | +cmake_minimum_required(VERSION 3.22) |
| 17 | +project(deep_test) |
| 18 | + |
| 19 | +if(NOT CMAKE_CXX_STANDARD) |
| 20 | + set(CMAKE_CXX_STANDARD 17) |
| 21 | +endif() |
| 22 | + |
| 23 | +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 24 | + add_compile_options(-Wall -Wextra -Wpedantic) |
| 25 | + add_link_options(-Wl,-no-undefined) |
| 26 | +endif() |
| 27 | + |
| 28 | +find_package(ament_cmake REQUIRED) |
| 29 | +find_package(rclcpp REQUIRED) |
| 30 | +find_package(rclcpp_lifecycle REQUIRED) |
| 31 | + |
| 32 | +set(include_dir ${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 33 | + |
| 34 | +# deep_test library |
| 35 | +set(DEEP_TEST_LIB ${PROJECT_NAME}_lib) |
| 36 | +add_library(${DEEP_TEST_LIB} SHARED |
| 37 | + src/test_executor_fixture.cpp |
| 38 | +) |
| 39 | +target_include_directories(${DEEP_TEST_LIB} PUBLIC |
| 40 | + $<BUILD_INTERFACE:${include_dir}> |
| 41 | + $<INSTALL_INTERFACE:include> |
| 42 | +) |
| 43 | +target_link_libraries(${DEEP_TEST_LIB} |
| 44 | + PRIVATE |
| 45 | + rclcpp::rclcpp |
| 46 | + rclcpp_lifecycle::rclcpp_lifecycle |
| 47 | +) |
| 48 | + |
| 49 | +install(TARGETS |
| 50 | + ${DEEP_TEST_LIB} |
| 51 | + EXPORT ${PROJECT_NAME}Targets |
| 52 | + ARCHIVE DESTINATION lib |
| 53 | + LIBRARY DESTINATION lib |
| 54 | + RUNTIME DESTINATION bin |
| 55 | +) |
| 56 | + |
| 57 | +install(EXPORT ${PROJECT_NAME}Targets |
| 58 | + NAMESPACE ${PROJECT_NAME}:: |
| 59 | + DESTINATION share/${PROJECT_NAME}/cmake |
| 60 | +) |
| 61 | + |
| 62 | +install(DIRECTORY include/ |
| 63 | + DESTINATION include |
| 64 | +) |
| 65 | + |
| 66 | +if(BUILD_TESTING) |
| 67 | + # Include our custom test function |
| 68 | + include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/add_deep_test.cmake) |
| 69 | + |
| 70 | + # Find test dependencies |
| 71 | + find_package(std_msgs REQUIRED) |
| 72 | + find_package(std_srvs REQUIRED) |
| 73 | + |
| 74 | + # Add the basic example test |
| 75 | + add_deep_test(test_basic_example |
| 76 | + test/test_basic_example.cpp |
| 77 | + LIBRARIES |
| 78 | + ${DEEP_TEST_LIB} |
| 79 | + ${std_msgs_TARGETS} |
| 80 | + ${std_srvs_TARGETS} |
| 81 | + ) |
| 82 | + |
| 83 | + # Add ROS test with multiple library dependencies |
| 84 | + add_deep_test(test_with_ros |
| 85 | + test/test_with_ros.cpp |
| 86 | + LIBRARIES |
| 87 | + ${DEEP_TEST_LIB} |
| 88 | + ${std_msgs_TARGETS} |
| 89 | + ) |
| 90 | +endif() |
| 91 | + |
| 92 | +ament_export_targets(${PROJECT_NAME}Targets HAS_LIBRARY_TARGET) |
| 93 | +ament_package( |
| 94 | + CONFIG_EXTRAS "${PROJECT_NAME}-extras.cmake" |
| 95 | +) |
0 commit comments