Skip to content

Commit

Permalink
link as hidden, vendor the include path
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnimmer-tri committed Sep 14, 2022
1 parent cf128b1 commit c3661c4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion perception/point_cloud.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include <vector>

#include "absl/container/flat_hash_map.h"
#include <drake_vendor/nanoflann.hpp>
#include <fmt/format.h>
#include <fmt/ostream.h>
#include <nanoflann.hpp>

#include "drake/common/drake_assert.h"
#include "drake/common/drake_throw.h"
Expand Down
4 changes: 2 additions & 2 deletions tools/workspace/nanoflann_internal/package.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ package(default_visibility = ["//visibility:public"])
cc_library(
name = "nanoflann",
hdrs = ["include/nanoflann.hpp"],
includes = ["include"],
deps = [],
include_prefix = "drake_vendor",
strip_include_prefix = "include",
linkstatic = 1,
)

Expand Down
21 changes: 21 additions & 0 deletions tools/workspace/nanoflann_internal/patches/namespace.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Add a drake_vendor namespace ala tools/workspace/vendor_cxx

This prevents link-time symbol conflicts in case code downstream of
Drake wants to use a different build of nanoflann.

--- include/nanoflann.hpp.orig
+++ include/nanoflann.hpp
@@ -70,6 +70,7 @@
#endif
#endif

+inline namespace drake_vendor __attribute__ ((visibility ("hidden"))) {
namespace nanoflann
{
/** @addtogroup nanoflann_grp nanoflann C++ library for ANN
@@ -2414,3 +2415,4 @@

/** @} */ // end of grouping
} // namespace nanoflann
+} // namespace drake_vendor
\ No newline at end of file
3 changes: 3 additions & 0 deletions tools/workspace/nanoflann_internal/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ def nanoflann_internal_repository(
commit = "v1.4.3",
sha256 = "cbcecf22bec528a8673a113ee9b0e134f91f1f96be57e913fa1f74e98e4449fa", # noqa
build_file = ":package.BUILD.bazel",
patches = [
":patches/namespace.patch",
],
mirrors = mirrors,
)

0 comments on commit c3661c4

Please sign in to comment.