diff --git a/cmake/modules/FindEigen3.cmake b/cmake/modules/FindEigen3.cmake index e33a2678..a85bd43a 100644 --- a/cmake/modules/FindEigen3.cmake +++ b/cmake/modules/FindEigen3.cmake @@ -114,7 +114,17 @@ else () # the script will work as usual # re:NO_CMAKE_PACKAGE_REGISTRY: eigen3 registers its *build* tree with the user package registry ... # to avoid issues with wiped build directory look for installed eigen - find_package(Eigen3 ${Eigen3_FIND_VERSION} NO_MODULE QUIET NO_CMAKE_PACKAGE_REGISTRY) + # N.B. Eigen3.4 -> Eigen5 transition made versions reported in Eigen3Config useless, will check manually below + find_package(Eigen3 NO_MODULE QUIET NO_CMAKE_PACKAGE_REGISTRY) + + # if found older version, reset and try to look for include path directly + if (EIGEN3_INCLUDE_DIR) + _eigen3_check_version() + if (NOT EIGEN3_VERSION_OK) + unset(Eigen3_CONFIG) + unset(EIGEN3_INCLUDE_DIR) + endif() + endif() if(NOT EIGEN3_INCLUDE_DIR) find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library diff --git a/export/CMakeLists.txt.export b/export/CMakeLists.txt.export index 45fb1a78..62f3f262 100644 --- a/export/CMakeLists.txt.export +++ b/export/CMakeLists.txt.export @@ -169,8 +169,14 @@ endif() find_package(Eigen3 MODULE) +set(LIBINT2_CXX_STANDARD 11) if (TARGET Eigen3::Eigen) set(LIBINT_HAS_EIGEN 1) + # Eigen 3.5+ (a.k.a. Eigen 5) requires C++14 + if (EIGEN3_VERSION VERSION_GREATER_EQUAL "3.5.0") + set(LIBINT2_CXX_STANDARD 14) + message(STATUS "Eigen ${EIGEN3_VERSION} requires C++14; setting LIBINT2_CXX_STANDARD=14") + endif() endif() if (LIBINT2_REQUIRE_CXX_API AND NOT LIBINT_HAS_EIGEN) message(FATAL_ERROR "C++ API cannot be built without Eigen3; configure (via CMake) and install Eigen3 and add the install prefix to CMAKE_PREFIX_PATH, or add -D LIBINT2_REQUIRE_CXX_API=OFF to the CMake command line if the C++ API is not required") @@ -231,7 +237,7 @@ add_library( target_compile_features( int-obj PUBLIC - "cxx_std_11" # N.B. PUBLIC to make int-{static/shared} require C++11 + "cxx_std_${LIBINT2_CXX_STANDARD}" # N.B. PUBLIC to make int-{static/shared} require C++11 (or C++14 for Eigen 5.x) ) target_compile_definitions( int-obj @@ -268,7 +274,7 @@ if (LIBINT2_REQUIRE_CXX_API_COMPILED) target_compile_features( int-cxx-obj PUBLIC - "cxx_std_11" + "cxx_std_${LIBINT2_CXX_STANDARD}" ) target_compile_definitions( int-cxx-obj @@ -336,7 +342,7 @@ if (L2_BUILD_SHARED_LIBS) target_compile_features( int-shared INTERFACE - "cxx_std_11" + "cxx_std_${LIBINT2_CXX_STANDARD}" ) target_compile_definitions( int-shared @@ -386,7 +392,7 @@ if (L2_BUILD_SHARED_LIBS) target_compile_features( int-cxx-headeronly-shared INTERFACE - "cxx_std_11" + "cxx_std_${LIBINT2_CXX_STANDARD}" ) target_compile_definitions( int-cxx-headeronly-shared @@ -467,7 +473,7 @@ if (L2_BUILD_STATIC_LIBS) target_compile_features( int-static INTERFACE - "cxx_std_11" + "cxx_std_${LIBINT2_CXX_STANDARD}" ) target_compile_definitions( int-static @@ -510,7 +516,7 @@ if (L2_BUILD_STATIC_LIBS) target_compile_features( int-cxx-headeronly-static INTERFACE - "cxx_std_11" + "cxx_std_${LIBINT2_CXX_STANDARD}" ) target_compile_definitions( int-cxx-headeronly-static