Skip to content
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

use modern interface targets if available, otherwise classic variables #235

Merged
merged 2 commits into from
Apr 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2014 Open Source Robotics Foundation, Inc.
# Copyright 2014-2020 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,13 +13,15 @@
# limitations under the License.

#
# Add the definitions, include directories and libraries of packages to a
# target.
# Add the interface targets or definitions, include directories and libraries
# of packages to a target.
#
# Each package name must have been find_package()-ed before.
# Additionally the exported variables must have a prefix with the same case
# and the suffixes must be _DEFINITIONS, _INCLUDE_DIRS, _LIBRARIES, and
# _LINK_FLAGS.
# and the suffixes must be either _INTERFACES or _DEFINITIONS, _INCLUDE_DIRS,
# _LIBRARIES, and _LINK_FLAGS.
# If _INTERFACES is not empty it will be used exclusively, otherwise the other
# variables are being used.
#
# :param target: the target name
# :type target: string
Expand Down Expand Up @@ -52,11 +54,18 @@ function(ament_target_dependencies target)
if(NOT "${${package_name}_FOUND}")
message(FATAL_ERROR "ament_target_dependencies() the passed package name '${package_name}' was not found before")
endif()
list_append_unique(definitions ${${package_name}_DEFINITIONS})
list_append_unique(include_dirs ${${package_name}_INCLUDE_DIRS})
list_append_unique(interfaces ${${package_name}_INTERFACES})
list(APPEND libraries ${${package_name}_LIBRARIES})
list_append_unique(link_flags ${${package_name}_LINK_FLAGS})
if(NOT "${${package_name}_INTERFACES}" STREQUAL "")
# if a package provides modern CMake interface targets use them
# exclusively assuming the classic CMake variables only exist for
# backward compatibility
list_append_unique(interfaces ${${package_name}_INTERFACES})
else()
# otherwise use the classic CMake variables
list_append_unique(definitions ${${package_name}_DEFINITIONS})
list_append_unique(include_dirs ${${package_name}_INCLUDE_DIRS})
list(APPEND libraries ${${package_name}_LIBRARIES})
list_append_unique(link_flags ${${package_name}_LINK_FLAGS})
endif()
endforeach()
target_compile_definitions(${target}
PUBLIC ${definitions})
Expand Down