Skip to content

Commit

Permalink
Merge pull request #71 from Ryanf55/fix-export-libraries
Browse files Browse the repository at this point in the history
Export the right library names
  • Loading branch information
jonbinney authored Mar 2, 2024
2 parents f0ab9fc + f0d96cb commit 4d812c5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ target_link_libraries(realtime_circular_buffer
Boost::boost
)

# filter_base is an INTERFACE library because it only has header files.
# It is not compiled, but sets up the following properties for consumers
# to link to a target.
# For more info, see the CMake Wiki on INTERFACE targets.
# https://cmake.org/cmake/help/latest/command/add_library.html#interface-libraries
add_library(filter_base
INTERFACE
include/filters/filter_base.h
Expand Down Expand Up @@ -204,9 +209,8 @@ endif()
# Install
##############################################################################

# Export old-style CMake variables
# Export old-style CMake variables for includes
ament_export_include_directories("include/${PROJECT_NAME}")
ament_export_libraries(${PROJECT_NAME})

# Export modern CMake targets
ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Filters

## Usage with ament_cmake

Here is recommended approach on how to link `filters` to your project, using the `filters::realtime_circular_buffer` target.

```cmake
find_package(filters CONFIG REQUIRED)
add_library(my_library)
# Other library stuff here
target_link_libraries(my_library PUBLIC filters::realtime_circular_buffer)
```

For more information on using ament_cmake,
see the [ament_cmake](https://docs.ros.org/en/rolling/How-To-Guides/Ament-CMake-Documentation.html)
tutorial.

Filters creates all of the following CMake targets, including:
* filters::realtime_circular_buffer
* filters::filter_chain
* filters::mean
* filters::params
* filters::increment
* filters::median
* filters::transfer_function

It is recommended to only link to the libraries needed.
Linking to `filters::filter_base` pulls in all necessary libraries and include directories for targets with classes that extend `FilterBase`. This is useful if you are writing your own filter.

0 comments on commit 4d812c5

Please sign in to comment.