-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ament_export_dependencies can't export all PkgConfig projects found in CMake #504
Comments
This is the route I'd recommend. Not exactly the same as using pkg-config, but a similar example is how I'd recommend creating a
I'm unfamiliar with PkgConfig creating targets. If a package did |
Here's what I've got so far without relying on fragile variables. FindLIBAV # FindLIBAV.cmake
# This Finds libav using CMake.
# https://github.com/libav/libav
#
# Reference https://stackoverflow.com/questions/71531333/how-set-cmake-to-find-a-local-package-ffmpeg
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBAV IMPORTED_TARGET
libavdevice
libavfilter
libavformat
libavcodec
libswresample
libswscale
libavutil
) I have Find Scripts living in a separate ROS-independent library Next, a consuming library <depend>gstreamer1.0</depend>
<depend>gstreamer1.0-libav</depend>
<depend>cmake_helpers</depend> project(Foo)
find_package(av_cmake_helpers 0 CONFIG REQUIRED)
find_package(LIBAV MODULE REQUIRED) # No ability to specify versioning yet
find_package(GST MODULE REQUIRED) # No ability to specify versioning yet
target_link_libraries(FooLibrary
PUBLIC
PkgConfig::GST
PkgConfig::LIBAV)
include(GNUInstallDirs)
install(
TARGETS FooLibrary
EXPORT ${PROJECT_NAME}Export
FILE_SET HEADERS
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
ament_export_targets(${PROJECT_NAME}Export HAS_LIBRARY_TARGET)
ament_export_dependencies(
rclcpp
)
ament_package(CONFIG_EXTRAS ${PROJECT_NAME}-extras.cmake.in) And finally:
This, the scope of this request would have ament automatically handle the exports of dependencies in |
I'm refactoring a large repository to be installable with ament_cmake. It's a CMake project, and relies on library
libav
, which does not support CMake.libav
only comes with Pkgconfig support. Gstreamer is pulled in through pkgconfig also.I'm using CMake 3.28, so I have full access to the latest language features.
Current Behavior
Thus, here's how the library
foo
brings it in with CMake's built in PkgConfig support.Some details omitted for brevity.
This builds fine. But, a consuming package
bar
can't use the exported dependencies.Library
foo
has this as the INTERFACE_INCLUDE_DIRECTORIES: `INTERFACE_LINK_LIBRARIES "PkgConfig::GST;PkgConfig::LIBAV" in the export.And, in ament_cmake_export_dependencies-extras.cmake
Expected Behavior
ament_export_dependencies can support and recognize targets created with
PkgConfig
and support downstream packages with PkgConfig.Workarounds
Proposal
Amend
ament_cmake_export_dependencies-extras.cmake
to also try to find PkgConfig projects as a backup usingpkg_check_modules
. Note that the flagIMPORTED_TARGET
means that users of this will have to use that also.This will work because of the following in FooTargetExport.cmake
The text was updated successfully, but these errors were encountered: