CMakeLists.txt как включить путь

У меня есть проект с такой структурой:

CMakeLists.txt
|--topics
|-- talker.cpp
|-- task.hpp
|-- ...

talker.cpp имеет #include "task.hpp"

task.hpp имеет #include <alchemy/timer.h> это timer.h находится вне структуры моего проекта: /usr/xenomai/include/alchemy/timer.h

Из-за этого, когда я пытаюсь скомпилировать, я получил:

/.../topics/timer.hpp:15:27: fatal error: alchemy/timer.h:
file or directory not found #include <alchemy/timer.h>

Как правильно включить этот путь в CMakeLists.txt?

Мой CMakeLists.txt:

cmake_minimum_required(VERSION 3.5)
project(demo_nodes_cpp)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_library(ALCHEMY_LIB alchemy /usr/xenomai/lib)
find_library(XENOMAI_ALCHEMY xeno_alchemy /usr/xenomai/include)
find_library(TRANK_LIB trank /usr/xenomai/inbclude/trunk)

include_directories(usr/xenomai/include/)

find_package(ament_cmake REQUIRED)
find_package(example_interfaces REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rcutils)
find_package(rmw REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)

function(custom_executable subfolder target)
add_executable(${target} src/${subfolder}/${target}.cpp)
target_link_libraries(${target} "${ALCHEMY_LIB} ${XENOMAI_ALCHEMY}")
ament_target_dependencies(${target}
"example_interfaces""rclcpp""rcutils""std_msgs")
install(TARGETS ${target}
DESTINATION lib/${PROJECT_NAME})
endfunction()

# Tutorials of Publish/Subscribe with Topics
custom_executable(topics talker)
custom_executable(topics listener)
custom_executable(topics listener_best_effort)
custom_executable(topics imu_listener)
ament_target_dependencies(imu_listener
"sensor_msgs")
custom_executable(topics allocator_tutorial)
custom_executable(topics talker_serialized_message)
custom_executable(topics listener_serialized_message)

# Tutorials of Request/Response with Services
custom_executable(services add_two_ints_client)
custom_executable(services add_two_ints_client_async)
custom_executable(services add_two_ints_server)

# Tutorials of Parameters with Asynchronous and Synchronous
custom_executable(parameters list_parameters)
custom_executable(parameters list_parameters_async)
custom_executable(parameters parameter_events)
custom_executable(parameters parameter_events_async)
custom_executable(parameters parameter_node)
custom_executable(parameters set_and_get_parameters)
custom_executable(parameters set_and_get_parameters_async)

# Tutorials of Timers
custom_executable(timers one_off_timer)
custom_executable(timers reuse_timer)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()

find_package(ament_cmake_pytest REQUIRED)
find_package(rmw_implementation_cmake REQUIRED)

# Add each test case.  Multi-executable tests can be specified in
# semicolon-separated strings, like  exe1;exe2.
set(tutorial_tests
list_parameters_async
list_parameters
parameter_events_async
parameter_events
set_and_get_parameters_async
set_and_get_parameters
"talker:listener")
set(service_tutorial_tests
"add_two_ints_server:add_two_ints_client""add_two_ints_server:add_two_ints_client_async")

macro(tests)
set(tutorial_tests_to_test ${tutorial_tests})
list(APPEND tutorial_tests_to_test ${service_tutorial_tests})

foreach(tutorial_test ${tutorial_tests_to_test})
string(REPLACE ":" ";" tutorial_executables "${tutorial_test}")
set(DEMO_NODES_CPP_EXPECTED_OUTPUT "")
foreach(executable ${tutorial_executables})
list(APPEND DEMO_NODES_CPP_EXPECTED_OUTPUT     "${CMAKE_CURRENT_SOURCE_DIR}/test/${executable}")
endforeach()

set(DEMO_NODES_CPP_EXECUTABLE "")
foreach(executable ${tutorial_executables})
list(APPEND DEMO_NODES_CPP_EXECUTABLE "$<TARGET_FILE:${executable}>")
endforeach()

string(REPLACE ";" "_" exe_list_underscore "${tutorial_executables}")
configure_file(
test/test_executables_tutorial.py.in
test_${exe_list_underscore}${target_suffix}.py.configured
@ONLY
)
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_${exe_list_underscore}${target_suffix}_$<CONFIG>.py"INPUT "${CMAKE_CURRENT_BINARY_DIR}/test_${exe_list_underscore}${target_suffix}.py.configured")

ament_add_pytest_test(test_tutorial_${exe_list_underscore}${target_suffix}
"${CMAKE_CURRENT_BINARY_DIR}/test_${exe_list_underscore}${target_suffix}_$<CONFIG>.py"TIMEOUT 30
ENV
RCL_ASSERT_RMW_ID_MATCHES=${rmw_implementation}
RMW_IMPLEMENTATION=${rmw_implementation})
foreach(executable ${tutorial_executables})
set_property(
TEST test_tutorial_${exe_list_underscore}${target_suffix}
APPEND PROPERTY DEPENDS ${executable}${target_suffix})
endforeach()
endforeach()
endmacro()

call_for_each_rmw_implementation(tests)
endif()

# Install launch files.
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)

ament_package()

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]