Skip to content

Commit

Permalink
Allow external Eigen3 (RobotLocomotion#16700)
Browse files Browse the repository at this point in the history
Add logic (only when using the CMake wrapper) to allow the user to
select and use an external version of Eigen3.
  • Loading branch information
mwoehlke-kitware authored Mar 2, 2022
1 parent f88c6a7 commit fd54e8e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,20 @@ endmacro()

set(BAZEL_OVERRIDE_REPOS)

option(WITH_USER_EIGEN "Use user-provided Eigen3" OFF)

if(WITH_USER_EIGEN)
find_package(Eigen3 CONFIG REQUIRED)

symlink_external_repository_includes(eigen Eigen3::Eigen)
generate_external_repository_file(eigen/WORKSPACE)
generate_external_repository_file(
eigen/BUILD.bazel
eigen/BUILD.bazel.in)

override_repository(eigen)
endif()

option(WITH_USER_FMT "Use user-provided fmt" OFF)

if(WITH_USER_FMT)
Expand Down
24 changes: 24 additions & 0 deletions cmake/external/workspace/eigen/BUILD.bazel.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- python -*-

load("@drake//tools/install:install.bzl", "install")
load("@drake//tools/workspace:cmake_util.bzl", "split_cmake_list")

EIGEN_DEFINES = split_cmake_list(
"$<TARGET_PROPERTY:Eigen3::Eigen,INTERFACE_COMPILE_DEFINITIONS>",
)

cc_library(
name = "eigen",
hdrs = glob(
["include/**"],
allow_empty = False,
),
defines = EIGEN_DEFINES,
includes = ["include"],
visibility = ["//visibility:public"],
)

install(
name = "install",
visibility = ["//visibility:public"],
)

0 comments on commit fd54e8e

Please sign in to comment.