diff --git a/avogadro/core/CMakeLists.txt b/avogadro/core/CMakeLists.txt index 04822bd55f..ec2dbcd32c 100644 --- a/avogadro/core/CMakeLists.txt +++ b/avogadro/core/CMakeLists.txt @@ -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}") diff --git a/cmake/FindEigen3.cmake b/cmake/FindEigen3.cmake index 103690ed5a..45c40ac832 100644 --- a/cmake/FindEigen3.cmake +++ b/cmake/FindEigen3.cmake @@ -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}") @@ -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 () diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c5d2c5e07c..8d4657531e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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) @@ -42,4 +44,3 @@ if(USE_OPENGL) add_subdirectory(qtopengl) endif() endif() -