@@ -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,7 +91,7 @@ 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
@@ -111,19 +104,19 @@ endif()
111104file(READ "${PROJECT_SOURCE_DIR}/Eigen/Version" _eigen_version_header)
112105if (NOT DEFINED EIGEN_WORLD_VERSION)
113106 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 "" )
107+ set(EIGEN_WORLD_VERSION "${CMAKE_MATCH_1}")
115108endif()
116109if (NOT DEFINED EIGEN_MAJOR_VERSION)
117110 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 "" )
111+ set(EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1}")
119112endif()
120113if (NOT DEFINED EIGEN_MINOR_VERSION)
121114 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 "" )
115+ set(EIGEN_MINOR_VERSION "${CMAKE_MATCH_1}")
123116endif()
124117if (NOT DEFINED EIGEN_PATCH_VERSION)
125118 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 "" )
119+ set(EIGEN_PATCH_VERSION "${CMAKE_MATCH_1}")
127120endif()
128121if (NOT DEFINED EIGEN_PRERELEASE_VERSION)
129122 set(EIGEN_PRERELEASE_VERSION "dev")
@@ -145,18 +138,18 @@ endif()
145138if (NOT DEFINED EIGEN_BUILD_VERSION AND DEFINED EIGEN_GIT_REVNUM)
146139 string(SUBSTRING "${EIGEN_GIT_REVNUM}" 0 8 EIGEN_BUILD_VERSION)
147140else()
148- set(EIGEN_BUILD_VERSION "" CACHE STRING "" )
141+ set(EIGEN_BUILD_VERSION "")
149142endif()
150143
151144# The EIGEN_VERSION_NUMBER must be of the form <major.minor.patch>.
152145# 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 "" )
146+ set(EIGEN_VERSION_NUMBER "${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION}.${EIGEN_PATCH_VERSION}")
147+ set(EIGEN_VERSION_STRING "${EIGEN_VERSION_NUMBER}")
155148if (NOT "x${EIGEN_PRERELEASE_VERSION}" STREQUAL "x")
156- set(EIGEN_VERSION_STRING "${EIGEN_VERSION_STRING}-${EIGEN_PRERELEASE_VERSION}" CACHE STRING "" )
149+ set(EIGEN_VERSION_STRING "${EIGEN_VERSION_STRING}-${EIGEN_PRERELEASE_VERSION}")
157150endif()
158151if (NOT "x${EIGEN_BUILD_VERSION}" STREQUAL "x")
159- set(EIGEN_VERSION_STRING "${EIGEN_VERSION_STRING}+${EIGEN_BUILD_VERSION}" CACHE STRING "" )
152+ set(EIGEN_VERSION_STRING "${EIGEN_VERSION_STRING}+${EIGEN_BUILD_VERSION}")
160153endif()
161154
162155
@@ -316,29 +309,17 @@ if (EIGEN_IS_BUILDING_)
316309 set(CMAKE_INCLUDE_CURRENT_DIR OFF)
317310
318311 find_package(StandardMathLibrary)
319- find_package(AOCL QUIET)
320312 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-
328313 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.")
314+ message(FATAL_ERROR
315+ "Can't link to the standard math library. Please report to the Eigen developers, telling them about your platform.")
331316 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}")
317+ if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
318+ set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO} ${STANDARD_MATH_LIBRARY}")
319+ else()
320+ set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${STANDARD_MATH_LIBRARY}")
321+ endif()
336322 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-
342323 if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
343324 message(STATUS "Standard libraries to link to explicitly: ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}")
344325 else()
@@ -415,16 +396,13 @@ if (EIGEN_BUILD_TESTING)
415396 ei_add_cxx_compiler_flag("-Wshorten-64-to-32")
416397 ei_add_cxx_compiler_flag("-Wlogical-op")
417398 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")
420399 ei_add_cxx_compiler_flag("-Wc++11-extensions")
421400 ei_add_cxx_compiler_flag("-Wdouble-promotion")
422401 # ei_add_cxx_compiler_flag("-Wconversion")
423402 ei_add_cxx_compiler_flag("-Wshadow")
424403 ei_add_cxx_compiler_flag("-Wno-psabi")
425404 ei_add_cxx_compiler_flag("-Wno-variadic-macros")
426405 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.
428406 ei_add_cxx_compiler_flag("-fno-common")
429407 ei_add_cxx_compiler_flag("-fstrict-aliasing")
430408 ei_add_cxx_compiler_flag("-wd981") # disable ICC's "operands are evaluated in unspecified order" remark
@@ -435,17 +413,6 @@ if (EIGEN_BUILD_TESTING)
435413 ei_add_cxx_compiler_flag("-fno-check-new")
436414 endif()
437415
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-
449416
450417 if(ANDROID_NDK)
451418 ei_add_cxx_compiler_flag("-pie")
@@ -682,7 +649,7 @@ if (EIGEN_BUILD_TESTING)
682649 endif()
683650
684651 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")
652+ set(EIGEN_CUDA_COMPUTE_ARCH 30 CACHE STRING "The CUDA compute architecture(s) to target when compiling CUDA code")
686653
687654 option(EIGEN_TEST_SYCL "Add Sycl support." OFF)
688655 if(EIGEN_TEST_SYCL)
@@ -772,6 +739,15 @@ if(EIGEN_BUILD_DOC)
772739 add_subdirectory(doc EXCLUDE_FROM_ALL)
773740endif()
774741
742+ # TODO: consider also replacing EIGEN_BUILD_BTL by a custom target "make btl"?
743+ if(EIGEN_BUILD_BTL)
744+ add_subdirectory(bench/btl EXCLUDE_FROM_ALL)
745+ endif()
746+
747+ if(NOT WIN32 AND EIGEN_BUILD_SPBENCH)
748+ add_subdirectory(bench/spbench EXCLUDE_FROM_ALL)
749+ endif()
750+
775751if (EIGEN_BUILD_DEMOS)
776752 add_subdirectory(demos EXCLUDE_FROM_ALL)
777753endif()
@@ -827,7 +803,6 @@ endif()
827803message(STATUS "")
828804message(STATUS "Configured Eigen ${EIGEN_VERSION_STRING}")
829805message(STATUS "")
830-
831806#]] # ITK -STOP DISABLE UPSTREAM EIGEN LOGIC
832807
833808###############################################################################
@@ -849,33 +824,15 @@ include(GNUInstallDirs)
849824set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR} " )
850825set (CMAKEPACKAGE_INSTALL_DIR "${CMAKE_INSTALL_DATADIR} " )
851826
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 ()
827+ # automatically parse the version number
828+ file (READ "${PROJECT_SOURCE_DIR} /Eigen/src/Core/util/Macros.h" _eigen_version_header )
864829string (REGEX MATCH "define[ \t ]+EIGEN_WORLD_VERSION[ \t ]+([0-9]+)" _eigen_world_version_match "${_eigen_version_header} " )
865830set (EIGEN_WORLD_VERSION "${CMAKE_MATCH_1} " )
866831string (REGEX MATCH "define[ \t ]+EIGEN_MAJOR_VERSION[ \t ]+([0-9]+)" _eigen_major_version_match "${_eigen_version_header} " )
867832set (EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1} " )
868833string (REGEX MATCH "define[ \t ]+EIGEN_MINOR_VERSION[ \t ]+([0-9]+)" _eigen_minor_version_match "${_eigen_version_header} " )
869834set (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 ()
835+ set (EIGEN_VERSION_NUMBER ${EIGEN_WORLD_VERSION} .${EIGEN_MAJOR_VERSION} .${EIGEN_MINOR_VERSION} )
879836
880837include (CMakePackageConfigHelpers )
881838
@@ -935,7 +892,7 @@ install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
935892# Install files (used for both eigen_external and eigen_internal)
936893install (
937894 DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR} /Eigen/"
938- DESTINATION "${INCLUDE_INSTALL_DIR } /itkeigen/Eigen"
895+ DESTINATION "${ITK3P_INSTALL_INCLUDE_DIR } /itkeigen/Eigen"
939896 PATTERN "*.txt" EXCLUDE)
940897
941898######################### eigen_internal #####################################
@@ -949,7 +906,6 @@ add_library (ITKInternalEigen3::Eigen ALIAS eigen_internal)
949906# This would wrongly enforce EIGEN_MPL2_ONLY to other libraries using Eigen.
950907# We wrap this definition in ITK_USE_EIGEN_MPL2_ONLY, and only enabling it internally in the dashboards and CI,
951908# 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.)
953909
954910if (ITK_USE_EIGEN_MPL2_ONLY)
955911 target_compile_definitions (eigen_internal INTERFACE "EIGEN_MPL2_ONLY" )
@@ -959,40 +915,10 @@ endif()
959915# #include <itkeigen/Eigen/x>
960916# INSTALL: headers require pre-prend itkeigen/Eigen/X.
961917target_include_directories (eigen_internal SYSTEM INTERFACE
962- $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR} /.. >
963- $<INSTALL_INTERFACE :${INCLUDE_INSTALL_DIR} >
918+ $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR} >
919+ " $<INSTALL_INTERFACE :$< INSTALL_PREFIX >/ ${ITK3P_INSTALL_INCLUDE_DIR} / itkeigen >;"
964920 )
965921
966922# Export as title case Eigen
967- set_target_properties (eigen_internal PROPERTIES EXPORT_NAME Eigen )
968- install (TARGETS eigen_internal EXPORT ITKInternalEigen3Targets)
923+ install (TARGETS eigen_internal EXPORT ${ITK3P_INSTALL_EXPORT_NAME} )
969924
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