Unable to include header files from another package
I am trying to create a library package which also includes header files to include from another package, but the other package is not able to find them. The CMakelist.txt from the library package looks like this:
cmake_minimum_required(VERSION 3.5)
project(device_engine)
# 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_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
include_directories(
include
)
ament_export_dependencies(rosidl_default_runtime)
add_library(device_engine
src/action.cpp
src/resource.cpp
src/device_engine.cpp
src/event_log_object.cpp
src/log_handler.cpp
src/log_handler_cout.cpp
)
ament_target_dependencies(device_engine)
install(TARGETS
device_engine
DESTINATION lib/${PROJECT_NAME}
PUBLIC_HEADER DESTINATION include/${PROJECT_NAME}/
)
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION include/${PROJECT_NAME}
FILES_MATCHING PATTERN "*.h"
PATTERN ".git" EXCLUDE)
ament_package()
The header files are copied correctly to install/device_engine/include/device_engine/ but it seems that the variable ${device_engine_INCLUDE_DIRS} is empty when calling find_package(device_engine) from the other package including the header files with the following CMakelists.txt:
cmake_minimum_required(VERSION 3.5)
project(mac_gateway)
# 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_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(happtec_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(device_engine REQUIRED)
include_directories(
include
${device_engine_INCLUDE_DIRS}
)
message(STATUS "Variables: ${device_engine_INCLUDE_DIRS}")
ament_export_dependencies(rosidl_default_runtime)
add_executable(mac_gateway
src/resource_test_1.cpp
src/main.cpp
)
target_link_libraries(mac_gateway device_engine)
ament_target_dependencies(mac_gateway device_engine rclcpp std_msgs std_srvs happtec_msgs)
install(TARGETS
mac_gateway
DESTINATION lib/${PROJECT_NAME})
ament_package()
The only error I get is that when compiling this, it is unable to find the header files. find_package(device_engine) does not produce any error.
What am I missing?