Skip to content

Commit

Permalink
Merge pull request #1544 from ghutchis/fix-eigen3
Browse files Browse the repository at this point in the history
Apply patch from Drew Parsons @debichem to fix Eigen path
  • Loading branch information
ghutchis authored Dec 22, 2023
2 parents 831d496 + a57e269 commit 3a2fbd2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
CIBW_BEFORE_ALL_LINUX: yum install -y git eigen3-devel

# Specify eigen location for windows
CIBW_ENVIRONMENT_WINDOWS: "EXTRA_CMAKE_ARGS=-DEigen3_INCLUDE_DIR:PATH=/c/eigen"
CIBW_ENVIRONMENT_WINDOWS: "EXTRA_CMAKE_ARGS=-DEIGEN3_INCLUDE_DIR:PATH=/c/eigen"

# On Mac build both x64 and arm64
CIBW_ARCHS_MACOS: "x86_64 arm64"
Expand Down
2 changes: 1 addition & 1 deletion avogadro/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ target_sources(Headers PUBLIC
utilities.h
vector.h
)
target_link_libraries(Headers INTERFACE Eigen3::Eigen3)
target_link_libraries(Headers INTERFACE Eigen3::Eigen)
install(TARGETS Headers
EXPORT "AvogadroLibsTargets"
FILE_SET HEADERS DESTINATION "${INSTALL_INCLUDE_DIR}")
Expand Down
22 changes: 11 additions & 11 deletions cmake/FindEigen3.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
find_path(Eigen3_INCLUDE_DIR
find_path(EIGEN3_INCLUDE_DIR
NAMES signature_of_eigen3_matrix_library
PATH_SUFFIXES eigen3 eigen
DOC "Eigen include directory")
mark_as_advanced(Eigen3_INCLUDE_DIR)
mark_as_advanced(EIGEN3_INCLUDE_DIR)

if (Eigen3_INCLUDE_DIR)
file(STRINGS "${Eigen3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _Eigen3_version_lines
if (EIGEN3_INCLUDE_DIR)
file(STRINGS "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _Eigen3_version_lines
REGEX "#define[ \t]+EIGEN_(WORLD|MAJOR|MINOR)_VERSION")
string(REGEX REPLACE ".*EIGEN_WORLD_VERSION *\([0-9]*\).*" "\\1" _Eigen3_version_world "${_Eigen3_version_lines}")
string(REGEX REPLACE ".*EIGEN_MAJOR_VERSION *\([0-9]*\).*" "\\1" _Eigen3_version_major "${_Eigen3_version_lines}")
Expand All @@ -19,15 +19,15 @@ endif ()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen3
REQUIRED_VARS Eigen3_INCLUDE_DIR
VERSION_VAR Eigen3_VERSION)
REQUIRED_VARS EIGEN3_INCLUDE_DIR
VERSION_VAR EIGEN3_VERSION)

if (Eigen3_FOUND)
set(Eigen3_INCLUDE_DIRS "${Eigen3_INCLUDE_DIR}")
set(Eigen3_INCLUDE_DIRS "${EIGEN3_INCLUDE_DIR}")

if (NOT TARGET Eigen3::Eigen3)
add_library(Eigen3::Eigen3 INTERFACE IMPORTED)
set_target_properties(Eigen3::Eigen3 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Eigen3_INCLUDE_DIR}")
if (NOT TARGET Eigen3::Eigen)
add_library(Eigen3::Eigen INTERFACE IMPORTED)
set_target_properties(Eigen3::Eigen PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${EIGEN3_INCLUDE_DIR}")
endif ()
endif ()
5 changes: 3 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ include_directories("${AvogadroLibs_BINARY_DIR}/avogadro/core")

# find google test
find_package(GTest REQUIRED)
find_package(Eigen3 REQUIRED)
# Add both as "system headers" to avoid warnings generated by them with
# compilers that support that notion.
include_directories(SYSTEM
${GTEST_INCLUDE_DIRS})
${GTEST_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR})

include(CheckIncludeFileCXX)
include(CheckCXXSymbolExists)
Expand Down Expand Up @@ -42,4 +44,3 @@ if(USE_OPENGL)
add_subdirectory(qtopengl)
endif()
endif()

0 comments on commit 3a2fbd2

Please sign in to comment.