@@ -6,8 +6,6 @@ project(Eigen3)
66# ITK doesn't compile anything here, just generates targets for the INTERFACE library.
77#[[ # ITK - START DISABLE UPSTREAM EIGEN LOGIC
88
9- cmake_minimum_required(VERSION 3.10.0)
10-
119#==============================================================================
1210# CMake Policy issues.
1311#==============================================================================
@@ -42,17 +40,10 @@ if (POLICY CMP0177)
4240 cmake_policy(SET CMP0177 NEW)
4341endif ()
4442
45- # Respect <PackageName>_ROOT variables.
46- if (POLICY CMP0074)
47- cmake_policy(SET CMP0074 NEW)
48- endif ()
49-
5043#==============================================================================
5144# CMake Project.
5245#==============================================================================
5346
54- project(Eigen3)
55-
5647# Remove this block after bumping CMake to v3.21.0
5748# PROJECT_IS_TOP_LEVEL is defined then by default
5849if(CMAKE_VERSION VERSION_LESS 3.21.0)
@@ -82,6 +73,8 @@ if (EIGEN_BUILD_BLAS OR EIGEN_BUILD_LAPACK)
8273 endif()
8374endif()
8475
76+ option(EIGEN_BUILD_BTL "Build benchmark suite" OFF)
77+ option(EIGEN_BUILD_SPBENCH "Build sparse benchmark suite" OFF)
8578# Avoid building docs if included from another project.
8679# Building documentation requires creating and running executables on the host
8780# platform. We shouldn't do this if cross-compiling.
@@ -98,10 +91,12 @@ if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
9891endif()
9992option(EIGEN_BUILD_CMAKE_PACKAGE "Enables the creation of EigenConfig.cmake and related files" ${PROJECT_IS_TOP_LEVEL})
10093
101- if (EIGEN_BUILD_TESTING OR EIGEN_BUILD_BLAS OR EIGEN_BUILD_LAPACK OR EIGEN_BUILD_DOC OR EIGEN_BUILD_DEMOS)
94+ if (EIGEN_BUILD_TESTING OR EIGEN_BUILD_BLAS OR EIGEN_BUILD_LAPACK OR EIGEN_BUILT_BTL OR EIGEN_BUILD_BTL OR EIGEN_BUILD_SPBENCH OR EIGEN_BUILD_DOC OR EIGEN_BUILD_DEMOS)
10295 set(EIGEN_IS_BUILDING_ ON)
10396endif()
10497
98+ #]] # ITK -STOP DISABLE UPSTREAM EIGEN LOGIC
99+
105100#==============================================================================
106101# Version Info.
107102#==============================================================================
@@ -111,24 +106,25 @@ endif()
111106file (READ "${PROJECT_SOURCE_DIR } /Eigen/Version" _eigen_version_header )
112107if (NOT DEFINED EIGEN_WORLD_VERSION)
113108 string (REGEX MATCH "define[ \t ]+EIGEN_WORLD_VERSION[ \t ]+([0-9]+)" _eigen_world_version_match "${_eigen_version_header} " )
114- set(EIGEN_WORLD_VERSION "${CMAKE_MATCH_1}" CACHE STRING "" )
109+ set (EIGEN_WORLD_VERSION "${CMAKE_MATCH_1} " )
115110endif ()
116111if (NOT DEFINED EIGEN_MAJOR_VERSION)
117112 string (REGEX MATCH "define[ \t ]+EIGEN_MAJOR_VERSION[ \t ]+([0-9]+)" _eigen_major_version_match "${_eigen_version_header} " )
118- set(EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1}" CACHE STRING "" )
113+ set (EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1} " )
119114endif ()
120115if (NOT DEFINED EIGEN_MINOR_VERSION)
121116 string (REGEX MATCH "define[ \t ]+EIGEN_MINOR_VERSION[ \t ]+([0-9]+)" _eigen_minor_version_match "${_eigen_version_header} " )
122- set(EIGEN_MINOR_VERSION "${CMAKE_MATCH_1}" CACHE STRING "" )
117+ set (EIGEN_MINOR_VERSION "${CMAKE_MATCH_1} " )
123118endif ()
124119if (NOT DEFINED EIGEN_PATCH_VERSION)
125120 string (REGEX MATCH "define[ \t ]+EIGEN_PATCH_VERSION[ \t ]+([0-9]+)" _eigen_patch_version_match "${_eigen_version_header} " )
126- set(EIGEN_PATCH_VERSION "${CMAKE_MATCH_1}" CACHE STRING "" )
121+ set (EIGEN_PATCH_VERSION "${CMAKE_MATCH_1} " )
127122endif ()
128123if (NOT DEFINED EIGEN_PRERELEASE_VERSION)
129124 set (EIGEN_PRERELEASE_VERSION "dev" )
130125endif ()
131126
127+ #[[ # ITK - START DISABLE UPSTREAM EIGEN LOGIC
132128# If we are in a git repo, extract a changeset.
133129if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
134130 # if the git program is absent or this will leave the EIGEN_GIT_REVNUM string empty,
@@ -145,21 +141,24 @@ endif()
145141if (NOT DEFINED EIGEN_BUILD_VERSION AND DEFINED EIGEN_GIT_REVNUM)
146142 string(SUBSTRING "${EIGEN_GIT_REVNUM}" 0 8 EIGEN_BUILD_VERSION)
147143else()
148- set(EIGEN_BUILD_VERSION "" CACHE STRING "" )
144+ set(EIGEN_BUILD_VERSION "")
149145endif()
146+ #]] # ITK -STOP DISABLE UPSTREAM EIGEN LOGIC
150147
151148# The EIGEN_VERSION_NUMBER must be of the form <major.minor.patch>.
152149# The EIGEN_VERSION_STRING can contain the preprelease/build strings.
153- set(EIGEN_VERSION_NUMBER "${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION}.${EIGEN_PATCH_VERSION}" CACHE STRING "" )
154- set(EIGEN_VERSION_STRING "${EIGEN_VERSION_NUMBER}" CACHE STRING "" )
150+ set (EIGEN_VERSION_NUMBER "${EIGEN_MAJOR_VERSION} .${EIGEN_MINOR_VERSION} .${EIGEN_PATCH_VERSION} " )
151+ set (EIGEN_VERSION_STRING "${EIGEN_VERSION_NUMBER} " )
155152if (NOT "x${EIGEN_PRERELEASE_VERSION} " STREQUAL "x" )
156- set(EIGEN_VERSION_STRING "${EIGEN_VERSION_STRING}-${EIGEN_PRERELEASE_VERSION}" CACHE STRING "" )
153+ set (EIGEN_VERSION_STRING "${EIGEN_VERSION_STRING} -${EIGEN_PRERELEASE_VERSION} " )
157154endif ()
158155if (NOT "x${EIGEN_BUILD_VERSION} " STREQUAL "x" )
159- set(EIGEN_VERSION_STRING "${EIGEN_VERSION_STRING}+${EIGEN_BUILD_VERSION}" CACHE STRING "" )
156+ set (EIGEN_VERSION_STRING "${EIGEN_VERSION_STRING} +${EIGEN_BUILD_VERSION} " )
160157endif ()
161158
162159
160+ # ITK only installs the Version file from the source directory, and does not use a generated one.
161+ #[[ # ITK - START DISABLE UPSTREAM EIGEN LOGIC
163162# Generate version file.
164163configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Version.in"
165164 "${CMAKE_CURRENT_BINARY_DIR}/include/Eigen/Version")
@@ -316,29 +315,17 @@ if (EIGEN_IS_BUILDING_)
316315 set(CMAKE_INCLUDE_CURRENT_DIR OFF)
317316
318317 find_package(StandardMathLibrary)
319- find_package(AOCL QUIET)
320318 set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "")
321- if(AOCL_FOUND)
322- list(APPEND EIGEN_STANDARD_LIBRARIES_TO_LINK_TO ${AOCL_LIBRARIES})
323- if(AOCL_INCLUDE_DIRS)
324- include_directories(${AOCL_INCLUDE_DIRS})
325- endif()
326- endif()
327-
328319 if(NOT STANDARD_MATH_LIBRARY_FOUND)
329- message(FATAL_ERROR
330- "Can't link to the standard math library. Please report to the Eigen developers, telling them about your platform.")
320+ message(FATAL_ERROR
321+ "Can't link to the standard math library. Please report to the Eigen developers, telling them about your platform.")
331322 else()
332- if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
333- set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO} ${STANDARD_MATH_LIBRARY}")
334- else()
335- set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${STANDARD_MATH_LIBRARY}")
323+ if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
324+ set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO} ${STANDARD_MATH_LIBRARY}")
325+ else()
326+ set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${STANDARD_MATH_LIBRARY}")
327+ endif()
336328 endif()
337- # Clean up any leading/trailing whitespace in the variable to avoid CMP0004 errors
338- string(STRIP "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}" EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
339- endif()
340-
341-
342329 if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
343330 message(STATUS "Standard libraries to link to explicitly: ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}")
344331 else()
@@ -415,16 +402,13 @@ if (EIGEN_BUILD_TESTING)
415402 ei_add_cxx_compiler_flag("-Wshorten-64-to-32")
416403 ei_add_cxx_compiler_flag("-Wlogical-op")
417404 ei_add_cxx_compiler_flag("-Wenum-conversion")
418- ei_add_cxx_compiler_flag("-Werror=deprecated-anon-enum-enum-conversion")
419- ei_add_cxx_compiler_flag("-Werror=deprecated-enum-enum-conversion")
420405 ei_add_cxx_compiler_flag("-Wc++11-extensions")
421406 ei_add_cxx_compiler_flag("-Wdouble-promotion")
422407 # ei_add_cxx_compiler_flag("-Wconversion")
423408 ei_add_cxx_compiler_flag("-Wshadow")
424409 ei_add_cxx_compiler_flag("-Wno-psabi")
425410 ei_add_cxx_compiler_flag("-Wno-variadic-macros")
426411 ei_add_cxx_compiler_flag("-Wno-long-long")
427- ei_add_cxx_compiler_flag("-Wno-pass-failed") # disable clang's warning for unrolling when the loop count is dynamic.
428412 ei_add_cxx_compiler_flag("-fno-common")
429413 ei_add_cxx_compiler_flag("-fstrict-aliasing")
430414 ei_add_cxx_compiler_flag("-wd981") # disable ICC's "operands are evaluated in unspecified order" remark
@@ -435,17 +419,6 @@ if (EIGEN_BUILD_TESTING)
435419 ei_add_cxx_compiler_flag("-fno-check-new")
436420 endif()
437421
438- # GCC 12+ emits false-positive -Warray-bounds, -Wmaybe-uninitialized,
439- # -Wstringop-overread, and -Wnonnull warnings at -O2/-O3 in heavily
440- # templated code with mixed static/dynamic sizes. These are well-known
441- # compiler bugs (see GCC PR 109394, 106247, 105329, 98610, among others).
442- if (CMAKE_COMPILER_IS_GNUCXX)
443- ei_add_cxx_compiler_flag("-Wno-array-bounds")
444- ei_add_cxx_compiler_flag("-Wno-maybe-uninitialized")
445- ei_add_cxx_compiler_flag("-Wno-stringop-overread")
446- ei_add_cxx_compiler_flag("-Wno-nonnull")
447- endif()
448-
449422
450423 if(ANDROID_NDK)
451424 ei_add_cxx_compiler_flag("-pie")
@@ -682,7 +655,7 @@ if (EIGEN_BUILD_TESTING)
682655 endif()
683656
684657 set(EIGEN_CUDA_CXX_FLAGS "" CACHE STRING "Additional flags to pass to the cuda compiler.")
685- set(EIGEN_CUDA_COMPUTE_ARCH 70 CACHE STRING "The CUDA compute architecture(s) to target when compiling CUDA code")
658+ set(EIGEN_CUDA_COMPUTE_ARCH 30 CACHE STRING "The CUDA compute architecture(s) to target when compiling CUDA code")
686659
687660 option(EIGEN_TEST_SYCL "Add Sycl support." OFF)
688661 if(EIGEN_TEST_SYCL)
@@ -772,6 +745,15 @@ if(EIGEN_BUILD_DOC)
772745 add_subdirectory(doc EXCLUDE_FROM_ALL)
773746endif()
774747
748+ # TODO: consider also replacing EIGEN_BUILD_BTL by a custom target "make btl"?
749+ if(EIGEN_BUILD_BTL)
750+ add_subdirectory(bench/btl EXCLUDE_FROM_ALL)
751+ endif()
752+
753+ if(NOT WIN32 AND EIGEN_BUILD_SPBENCH)
754+ add_subdirectory(bench/spbench EXCLUDE_FROM_ALL)
755+ endif()
756+
775757if (EIGEN_BUILD_DEMOS)
776758 add_subdirectory(demos EXCLUDE_FROM_ALL)
777759endif()
@@ -827,7 +809,6 @@ endif()
827809message(STATUS "")
828810message(STATUS "Configured Eigen ${EIGEN_VERSION_STRING}")
829811message(STATUS "")
830-
831812#]] # ITK -STOP DISABLE UPSTREAM EIGEN LOGIC
832813
833814###############################################################################
@@ -849,33 +830,7 @@ include(GNUInstallDirs)
849830set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR} " )
850831set (CMAKEPACKAGE_INSTALL_DIR "${CMAKE_INSTALL_DATADIR} " )
851832
852- # Automatically parse the version number.
853- # Eigen 5+ moved the version macros from Eigen/src/Core/util/Macros.h to
854- # Eigen/Version, and switched to semantic versioning. EIGEN_WORLD_VERSION
855- # is now permanently "3" (legacy "Eigen3" name); EIGEN_MAJOR_VERSION /
856- # EIGEN_MINOR_VERSION / EIGEN_PATCH_VERSION carry the real semver triple.
857- # Build EIGEN_VERSION_NUMBER as MAJOR.MINOR.PATCH so that
858- # find_package(Eigen3 X.Y.Z) and Eigen3_VERSION reflect the real version.
859- if (EXISTS "${PROJECT_SOURCE_DIR } /Eigen/Version" )
860- file (READ "${PROJECT_SOURCE_DIR } /Eigen/Version" _eigen_version_header )
861- else ()
862- file (READ "${PROJECT_SOURCE_DIR } /Eigen/src/Core/util/Macros.h" _eigen_version_header )
863- endif ()
864- string (REGEX MATCH "define[ \t ]+EIGEN_WORLD_VERSION[ \t ]+([0-9]+)" _eigen_world_version_match "${_eigen_version_header} " )
865- set (EIGEN_WORLD_VERSION "${CMAKE_MATCH_1} " )
866- string (REGEX MATCH "define[ \t ]+EIGEN_MAJOR_VERSION[ \t ]+([0-9]+)" _eigen_major_version_match "${_eigen_version_header} " )
867- set (EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1} " )
868- string (REGEX MATCH "define[ \t ]+EIGEN_MINOR_VERSION[ \t ]+([0-9]+)" _eigen_minor_version_match "${_eigen_version_header} " )
869- set (EIGEN_MINOR_VERSION "${CMAKE_MATCH_1} " )
870- string (REGEX MATCH "define[ \t ]+EIGEN_PATCH_VERSION[ \t ]+([0-9]+)" _eigen_patch_version_match "${_eigen_version_header} " )
871- set (EIGEN_PATCH_VERSION "${CMAKE_MATCH_1} " )
872- if (EIGEN_WORLD_VERSION STREQUAL "3" AND EIGEN_PATCH_VERSION)
873- # Eigen >= 5.0: WORLD frozen at 3, real version is MAJOR.MINOR.PATCH.
874- set (EIGEN_VERSION_NUMBER ${EIGEN_MAJOR_VERSION} .${EIGEN_MINOR_VERSION} .${EIGEN_PATCH_VERSION} )
875- else ()
876- # Eigen <= 3.4.x: legacy WORLD.MAJOR.MINOR layout.
877- set (EIGEN_VERSION_NUMBER ${EIGEN_WORLD_VERSION} .${EIGEN_MAJOR_VERSION} .${EIGEN_MINOR_VERSION} )
878- endif ()
833+
879834
880835include (CMakePackageConfigHelpers )
881836
@@ -935,7 +890,7 @@ install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
935890# Install files (used for both eigen_external and eigen_internal)
936891install (
937892 DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR } /Eigen/"
938- DESTINATION "${INCLUDE_INSTALL_DIR } /itkeigen/Eigen"
893+ DESTINATION "${ITK3P_INSTALL_INCLUDE_DIR } /itkeigen/Eigen"
939894 PATTERN "*.txt" EXCLUDE)
940895
941896######################### eigen_internal #####################################
@@ -949,7 +904,6 @@ add_library (ITKInternalEigen3::Eigen ALIAS eigen_internal)
949904# This would wrongly enforce EIGEN_MPL2_ONLY to other libraries using Eigen.
950905# We wrap this definition in ITK_USE_EIGEN_MPL2_ONLY, and only enabling it internally in the dashboards and CI,
951906# to avoid introducing GPL code from Eigen3 internally in ITK.
952- # (ITK_USE_EIGEN_MPL2_ONLY is declared once near line 844 of this file.)
953907
954908if (ITK_USE_EIGEN_MPL2_ONLY)
955909 target_compile_definitions (eigen_internal INTERFACE "EIGEN_MPL2_ONLY" )
@@ -959,40 +913,10 @@ endif()
959913# #include <itkeigen/Eigen/x>
960914# INSTALL: headers require pre-prend itkeigen/Eigen/X.
961915target_include_directories (eigen_internal SYSTEM INTERFACE
962- $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR } /.. >
963- $<INSTALL_INTERFACE :${INCLUDE_INSTALL_DIR} >
916+ $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR } >
917+ " $<INSTALL_INTERFACE :$< INSTALL_PREFIX >/ ${ITK3P_INSTALL_INCLUDE_DIR} / itkeigen >;"
964918 )
965919
966920# Export as title case Eigen
967- set_target_properties (eigen_internal PROPERTIES EXPORT_NAME Eigen)
968- install (TARGETS eigen_internal EXPORT ITKInternalEigen3Targets)
921+ install (TARGETS eigen_internal EXPORT ${ITK3P_INSTALL_EXPORT_NAME} )
969922
970- set (EIGEN3_TARGETS_FILE ITKInternalEigen3Targets.cmake)
971- configure_package_config_file (
972- ${CMAKE_CURRENT_SOURCE_DIR } /cmake/Eigen3Config.cmake.in
973- ${CMAKE_CURRENT_BINARY_DIR } /ITKInternalEigen3Config.cmake
974- INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}
975- NO_CHECK_REQUIRED_COMPONENTS_MACRO # Eigen does not provide components
976- )
977- # Remove CMAKE_SIZEOF_VOID_P from Eigen3ConfigVersion.cmake since Eigen does
978- # not depend on architecture specific settings or libraries. More
979- # specifically, an Eigen3Config.cmake generated from a 64 bit target can be
980- # used for 32 bit targets as well (and vice versa).
981- set (_Eigen3_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P } )
982- unset (CMAKE_SIZEOF_VOID_P )
983- write_basic_package_version_file (ITKInternalEigen3ConfigVersion.cmake
984- VERSION ${EIGEN_VERSION_NUMBER}
985- COMPATIBILITY SameMajorVersion )
986- set (CMAKE_SIZEOF_VOID_P ${_Eigen3_CMAKE_SIZEOF_VOID_P} )
987- # The Eigen target will be located in the Eigen3 namespace. Other CMake
988- # targets can refer to it using Eigen3::Eigen.
989- export (TARGETS eigen_internal NAMESPACE ITKInternalEigen3:: FILE ITKInternalEigen3Targets.cmake )
990- install (EXPORT ITKInternalEigen3Targets NAMESPACE ITKInternalEigen3:: DESTINATION ${CMAKEPACKAGE_INSTALL_DIR} )
991- # Files already installed in eigen_external
992- # install(
993- # DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Eigen/"
994- # DESTINATION "${INCLUDE_INSTALL_DIR}/itkeigen/Eigen"
995- # PATTERN "*.txt" EXCLUDE)
996- install ( FILES ${CMAKE_CURRENT_BINARY_DIR } /ITKInternalEigen3Config.cmake
997- ${CMAKE_CURRENT_BINARY_DIR } /ITKInternalEigen3ConfigVersion.cmake
998- DESTINATION ${CMAKEPACKAGE_INSTALL_DIR} )
0 commit comments