Adding environment variable to compile transport code.
Hello,
I'm writting some piece of code to extract info from gazebo simulations, making use of a topic that is being published in transport.
My issue is, using the publisher/subscriber CMakeList.txt example file, cmake is unable to find the library file to do its job. I have no clue on which directory CMAKE_PREFIX_PATH should point to, since the only transport11 file I've found is /usr/include/ignition/transport11.
My installation is ignition Fortress from binaries in Ubuntu 20.04, and I've checked with apt that libignition-transport11-dev is installed.
The error message is as follows:
Starting >>> ros_gz_pose_transport
--- stderr: ros_gz_pose_transport
CMake Error at CMakeLists.txt:20 (find_package):
By not providing "Findgz-transport11.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"gz-transport11", but CMake did not find one.
Could not find a package configuration file provided by "gz-transport11"
with any of the following names:
gz-transport11Config.cmake
gz-transport11-config.cmake
Add the installation prefix of "gz-transport11" to CMAKE_PREFIX_PATH or set
"gz-transport11_DIR" to a directory containing one of the above files. If
"gz-transport11" provides a separate development package or SDK, be sure it
has been installed.
make: * * * [Makefile:398: cmake_check_build_system] Error 1
---
Failed <<< ros_gz_pose_transport [2.06s, exited with code 2]
My CMakeLists.txt is:
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(ros_gz_pose_transport)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(ignition-cmake2 REQUIRED)
find_package(ignition-plugin1 REQUIRED COMPONENTS register)
set(IGN_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})
# Find the Gazebo Transport library
find_package(gz-transport11 QUIET REQUIRED OPTIONAL_COMPONENTS log)
set(GZ_TRANSPORT_VER ${gz-transport11_VERSION_MAJOR})
find_package(ignition-gazebo6 REQUIRED)
add_library(SampleSystem SHARED src/SampleSystem.cc)
set_property(TARGET SampleSystem PROPERTY CXX_STANDARD 17)
target_link_libraries(SampleSystem
PRIVATE ignition-plugin${IGN_PLUGIN_VER}::ignition-plugin${IGN_PLUGIN_VER}
PRIVATE ignition-gazebo6::ignition-gazebo6
gz-transport${GZ_TRANSPORT_VER}::core)
add_executable(pose_publisher_example src/pose_publisher_example.cpp)
ament_target_dependencies(pose_publisher_example rclcpp geometry_msgs)
add_executable(publish_once src/publish_once.cpp)
ament_target_dependencies(publish_once rclcpp geometry_msgs)
add_executable(hello src/hello_package.cpp)
target_include_directories(pose_publisher_example PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_features(pose_publisher_example PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17
install(TARGETS
pose_publisher_example
hello
publish_once
DESTINATION lib/${PROJECT_NAME})
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()
ament_package()
Thanks in advance, Diego