mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-02 11:15:12 +08:00
Reorganize CMake and minimize configuration for non-top-level builds.
This commit is contained in:
parent
c1d637433e
commit
9700fc847a
638
CMakeLists.txt
638
CMakeLists.txt
@ -1,12 +1,18 @@
|
|||||||
# cmake_minimum_require must be the first command of the file
|
|
||||||
cmake_minimum_required(VERSION 3.10.0)
|
cmake_minimum_required(VERSION 3.10.0)
|
||||||
|
|
||||||
|
#==============================================================================
|
||||||
|
# CMake Policy issues.
|
||||||
|
#==============================================================================
|
||||||
|
# Allow overriding options in a parent project via `set` before including Eigen.
|
||||||
|
if (POLICY CMP0077)
|
||||||
|
cmake_policy (SET CMP0077 NEW)
|
||||||
|
endif (POLICY CMP0077)
|
||||||
|
|
||||||
# NOTE Remove setting the policy once the minimum required CMake version is
|
# NOTE Remove setting the policy once the minimum required CMake version is
|
||||||
# increased to at least 3.15. Retain enabling the export to package registry.
|
# increased to at least 3.15. Retain enabling the export to package registry.
|
||||||
if (POLICY CMP0090)
|
if (POLICY CMP0090)
|
||||||
# The export command does not populate package registry by default
|
# The export command does not populate package registry by default
|
||||||
cmake_policy (SET CMP0090 NEW)
|
cmake_policy (SET CMP0090 NEW)
|
||||||
|
|
||||||
# Unless otherwise specified, always export to package registry to ensure
|
# Unless otherwise specified, always export to package registry to ensure
|
||||||
# backwards compatibility.
|
# backwards compatibility.
|
||||||
if (NOT DEFINED CMAKE_EXPORT_PACKAGE_REGISTRY)
|
if (NOT DEFINED CMAKE_EXPORT_PACKAGE_REGISTRY)
|
||||||
@ -23,48 +29,73 @@ if (POLICY CMP0146)
|
|||||||
cmake_policy(SET CMP0146 OLD)
|
cmake_policy(SET CMP0146 OLD)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
#==============================================================================
|
||||||
|
# CMake Project.
|
||||||
|
#==============================================================================
|
||||||
|
|
||||||
project(Eigen3)
|
project(Eigen3)
|
||||||
|
|
||||||
# Remove this block after bumping CMake to v3.21.0
|
# Remove this block after bumping CMake to v3.21.0
|
||||||
# PROJECT_IS_TOP_LEVEL is defined then by default
|
# PROJECT_IS_TOP_LEVEL is defined then by default
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.21.0)
|
if(CMAKE_VERSION VERSION_LESS 3.21.0)
|
||||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
set(PROJECT_IS_TOP_LEVEL TRUE)
|
set(PROJECT_IS_TOP_LEVEL ON)
|
||||||
else()
|
else()
|
||||||
set(PROJECT_IS_TOP_LEVEL FALSE)
|
set(PROJECT_IS_TOP_LEVEL OFF)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PROJECT_IS_TOP_LEVEL)
|
#==============================================================================
|
||||||
set(CMAKE_CXX_STANDARD 14 CACHE STRING "Default C++ standard")
|
# Build ON/OFF Settings.
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Require C++ standard")
|
#==============================================================================
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Allow C++ extensions")
|
# Determine if we should build tests.
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
cmake_dependent_option(BUILD_TESTING "Enable creation of tests." ON "PROJECT_IS_TOP_LEVEL" OFF)
|
||||||
|
option(EIGEN_BUILD_TESTING "Enable creation of Eigen tests." ${BUILD_TESTING})
|
||||||
|
option(EIGEN_LEAVE_TEST_IN_ALL_TARGET "Leaves tests in the all target, needed by ctest for automatic building." OFF)
|
||||||
|
|
||||||
|
# Determine if we should build BLAS/LAPACK implementations.
|
||||||
|
option(EIGEN_BUILD_BLAS "Toggles the building of the Eigen Blas library" ${PROJECT_IS_TOP_LEVEL})
|
||||||
|
option(EIGEN_BUILD_LAPACK "Toggles the building of the included Eigen LAPACK library" ${PROJECT_IS_TOP_LEVEL})
|
||||||
|
if (EIGEN_BUILD_BLAS OR EIGEN_BUILD_LAPACK)
|
||||||
|
# BLAS and LAPACK currently need a fortran compiler.
|
||||||
|
include(CMakeDetermineFortranCompiler)
|
||||||
|
if (NOT CMAKE_Fortran_COMPILER)
|
||||||
|
set(EIGEN_BUILD_BLAS OFF)
|
||||||
|
set(EIGEN_BUILD_LAPACK OFF)
|
||||||
|
else()
|
||||||
|
# Determine if we should build shared libraries for BLAS/LAPACK on this platform.
|
||||||
|
get_cmake_property(EIGEN_BUILD_SHARED_LIBS TARGET_SUPPORTS_SHARED_LIBS)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# guard against in-source builds
|
option(EIGEN_BUILD_BTL "Build benchmark suite" OFF)
|
||||||
|
option(EIGEN_BUILD_SPBENCH "Build sparse benchmark suite" OFF)
|
||||||
|
# Avoid building docs if included from another project.
|
||||||
|
# Building documentation requires creating and running executables on the host
|
||||||
|
# platform. We shouldn't do this if cross-compiling.
|
||||||
|
if (PROJECT_IS_TOP_LEVEL AND NOT CMAKE_CROSSCOMPILING)
|
||||||
|
set(EIGEN_BUILD_DOC_DEFAULT ON)
|
||||||
|
endif()
|
||||||
|
option(EIGEN_BUILD_DOC "Enable creation of Eigen documentation" ${EIGEN_BUILD_DOC_DEFAULT})
|
||||||
|
|
||||||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
option(EIGEN_BUILD_DEMOS "Toggles the building of the Eigen demos" ${PROJECT_IS_TOP_LEVEL})
|
||||||
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
|
|
||||||
|
# Disable pkgconfig only for native Windows builds
|
||||||
|
if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
||||||
|
option(EIGEN_BUILD_PKGCONFIG "Build pkg-config .pc file for Eigen" ${PROJECT_IS_TOP_LEVEL})
|
||||||
|
endif()
|
||||||
|
option(EIGEN_BUILD_CMAKE_PACKAGE "Enables the creation of EigenConfig.cmake and related files" ${PROJECT_IS_TOP_LEVEL})
|
||||||
|
|
||||||
|
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)
|
||||||
|
set(EIGEN_IS_BUILDING_ ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#==============================================================================
|
||||||
|
# Version Info.
|
||||||
|
#==============================================================================
|
||||||
|
|
||||||
# Alias Eigen_*_DIR to Eigen3_*_DIR:
|
# Automatically parse the version number from header files.
|
||||||
|
|
||||||
set(Eigen_SOURCE_DIR ${Eigen3_SOURCE_DIR})
|
|
||||||
set(Eigen_BINARY_DIR ${Eigen3_BINARY_DIR})
|
|
||||||
|
|
||||||
# guard against bad build-type strings
|
|
||||||
|
|
||||||
if (NOT CMAKE_BUILD_TYPE)
|
|
||||||
set(CMAKE_BUILD_TYPE "Release")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
# retrieve version information #
|
|
||||||
#############################################################################
|
|
||||||
|
|
||||||
# automatically parse the version number
|
|
||||||
file(READ "${PROJECT_SOURCE_DIR}/Eigen/src/Core/util/Macros.h" _eigen_version_header)
|
file(READ "${PROJECT_SOURCE_DIR}/Eigen/src/Core/util/Macros.h" _eigen_version_header)
|
||||||
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen_world_version_match "${_eigen_version_header}")
|
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen_world_version_match "${_eigen_version_header}")
|
||||||
set(EIGEN_WORLD_VERSION "${CMAKE_MATCH_1}")
|
set(EIGEN_WORLD_VERSION "${CMAKE_MATCH_1}")
|
||||||
@ -74,13 +105,12 @@ string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen_minor_
|
|||||||
set(EIGEN_MINOR_VERSION "${CMAKE_MATCH_1}")
|
set(EIGEN_MINOR_VERSION "${CMAKE_MATCH_1}")
|
||||||
set(EIGEN_VERSION_NUMBER ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})
|
set(EIGEN_VERSION_NUMBER ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})
|
||||||
|
|
||||||
# if we are not in a git clone
|
# If we are in a git repo, extract a changeset.
|
||||||
if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
|
if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
|
||||||
# if the git program is absent or this will leave the EIGEN_GIT_REVNUM string empty,
|
# if the git program is absent or this will leave the EIGEN_GIT_REVNUM string empty,
|
||||||
# but won't stop CMake.
|
# but won't stop CMake.
|
||||||
execute_process(COMMAND git ls-remote --refs -q ${CMAKE_SOURCE_DIR} HEAD OUTPUT_VARIABLE EIGEN_GIT_OUTPUT)
|
execute_process(COMMAND git ls-remote --refs -q ${CMAKE_SOURCE_DIR} HEAD OUTPUT_VARIABLE EIGEN_GIT_OUTPUT)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# extract the git rev number from the git output...
|
# extract the git rev number from the git output...
|
||||||
if(EIGEN_GIT_OUTPUT)
|
if(EIGEN_GIT_OUTPUT)
|
||||||
string(REGEX MATCH "^([0-9;a-f]+).*" EIGEN_GIT_CHANGESET_MATCH "${EIGEN_GIT_OUTPUT}")
|
string(REGEX MATCH "^([0-9;a-f]+).*" EIGEN_GIT_CHANGESET_MATCH "${EIGEN_GIT_OUTPUT}")
|
||||||
@ -93,22 +123,198 @@ else()
|
|||||||
set(EIGEN_VERSION "${EIGEN_VERSION_NUMBER}")
|
set(EIGEN_VERSION "${EIGEN_VERSION_NUMBER}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
#==============================================================================
|
||||||
|
# Eigen Library.
|
||||||
|
#==============================================================================
|
||||||
|
|
||||||
|
set ( EIGEN_VERSION_STRING ${EIGEN_VERSION_NUMBER} )
|
||||||
|
set ( EIGEN_VERSION_MAJOR ${EIGEN_WORLD_VERSION} )
|
||||||
|
set ( EIGEN_VERSION_MINOR ${EIGEN_MAJOR_VERSION} )
|
||||||
|
set ( EIGEN_VERSION_PATCH ${EIGEN_MINOR_VERSION} )
|
||||||
|
|
||||||
|
# Imported target support
|
||||||
|
add_library (eigen INTERFACE)
|
||||||
|
add_library (Eigen3::Eigen ALIAS eigen)
|
||||||
|
target_include_directories (eigen INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
|
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
|
||||||
|
)
|
||||||
|
|
||||||
|
# Export as title case Eigen
|
||||||
|
set_target_properties (eigen PROPERTIES EXPORT_NAME Eigen)
|
||||||
|
|
||||||
|
# Alias Eigen_*_DIR to Eigen3_*_DIR:
|
||||||
|
set(Eigen_SOURCE_DIR ${Eigen3_SOURCE_DIR})
|
||||||
|
set(Eigen_BINARY_DIR ${Eigen3_BINARY_DIR})
|
||||||
|
|
||||||
|
#==============================================================================
|
||||||
|
# Install Configuration.
|
||||||
|
#==============================================================================
|
||||||
|
|
||||||
|
# Unconditionally allow install of targets to support nested dependency
|
||||||
|
# installations.
|
||||||
|
#
|
||||||
|
# Note: projects that depend on Eigen should _probably_ exclude installing
|
||||||
|
# Eigen by default (e.g. by using EXCLUDE_FROM_ALL when using
|
||||||
|
# FetchContent_Declare or add_subdirectory) to avoid overwriting a previous
|
||||||
|
# installation.
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
include(CMakeDependentOption)
|
# Backward compatibility support for EIGEN_INCLUDE_INSTALL_DIR
|
||||||
|
if(EIGEN_INCLUDE_INSTALL_DIR)
|
||||||
|
message(WARNING "EIGEN_INCLUDE_INSTALL_DIR is deprecated. Use INCLUDE_INSTALL_DIR instead.")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
if(EIGEN_INCLUDE_INSTALL_DIR AND NOT INCLUDE_INSTALL_DIR)
|
||||||
|
set(INCLUDE_INSTALL_DIR ${EIGEN_INCLUDE_INSTALL_DIR}
|
||||||
|
CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where Eigen header files are installed")
|
||||||
|
else()
|
||||||
|
set(INCLUDE_INSTALL_DIR
|
||||||
|
"${CMAKE_INSTALL_INCLUDEDIR}/eigen3"
|
||||||
|
CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where Eigen header files are installed"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
set(CMAKEPACKAGE_INSTALL_DIR
|
||||||
|
"${CMAKE_INSTALL_DATADIR}/eigen3/cmake"
|
||||||
|
CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where Eigen3Config.cmake is installed"
|
||||||
|
)
|
||||||
|
set(PKGCONFIG_INSTALL_DIR
|
||||||
|
"${CMAKE_INSTALL_DATADIR}/pkgconfig"
|
||||||
|
CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where eigen3.pc is installed"
|
||||||
|
)
|
||||||
|
|
||||||
macro(ei_add_cxx_compiler_flag FLAG)
|
foreach(var INCLUDE_INSTALL_DIR CMAKEPACKAGE_INSTALL_DIR PKGCONFIG_INSTALL_DIR)
|
||||||
string(REGEX REPLACE "-" "" SFLAG1 ${FLAG})
|
# If an absolute path is specified, make it relative to "{CMAKE_INSTALL_PREFIX}".
|
||||||
string(REGEX REPLACE "\\+" "p" SFLAG ${SFLAG1})
|
if(IS_ABSOLUTE "${${var}}")
|
||||||
check_cxx_compiler_flag(${FLAG} COMPILER_SUPPORT_${SFLAG})
|
file(RELATIVE_PATH "${var}" "${CMAKE_INSTALL_PREFIX}" "${${var}}")
|
||||||
if(COMPILER_SUPPORT_${SFLAG})
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
|
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endforeach()
|
||||||
|
|
||||||
function(ei_maybe_separate_arguments variable mode args)
|
install(FILES
|
||||||
|
signature_of_eigen3_matrix_library
|
||||||
|
DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel
|
||||||
|
)
|
||||||
|
|
||||||
|
if(EIGEN_BUILD_PKGCONFIG)
|
||||||
|
configure_file(eigen3.pc.in eigen3.pc @ONLY)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eigen3.pc
|
||||||
|
DESTINATION ${PKGCONFIG_INSTALL_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(DIRECTORY Eigen DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
|
||||||
|
|
||||||
|
install(TARGETS eigen EXPORT Eigen3Targets)
|
||||||
|
|
||||||
|
if(EIGEN_BUILD_CMAKE_PACKAGE)
|
||||||
|
include (CMakePackageConfigHelpers)
|
||||||
|
configure_package_config_file (
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Eigen3Config.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
|
||||||
|
INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}
|
||||||
|
NO_SET_AND_CHECK_MACRO # Eigen does not provide legacy style defines
|
||||||
|
NO_CHECK_REQUIRED_COMPONENTS_MACRO # Eigen does not provide components
|
||||||
|
)
|
||||||
|
|
||||||
|
# NOTE Remove the first code path once the minimum required CMake version is
|
||||||
|
# bumped to 3.14 or above.
|
||||||
|
if (CMAKE_VERSION VERSION_LESS 3.14)
|
||||||
|
# Remove CMAKE_SIZEOF_VOID_P from Eigen3ConfigVersion.cmake since Eigen does
|
||||||
|
# not depend on architecture specific settings or libraries. More
|
||||||
|
# specifically, an Eigen3Config.cmake generated from a 64 bit target can be
|
||||||
|
# used for 32 bit targets as well (and vice versa).
|
||||||
|
set (_Eigen3_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
|
||||||
|
unset (CMAKE_SIZEOF_VOID_P)
|
||||||
|
write_basic_package_version_file (Eigen3ConfigVersion.cmake
|
||||||
|
VERSION ${EIGEN_VERSION_NUMBER}
|
||||||
|
COMPATIBILITY SameMajorVersion)
|
||||||
|
set (CMAKE_SIZEOF_VOID_P ${_Eigen3_CMAKE_SIZEOF_VOID_P})
|
||||||
|
else (CMAKE_VERSION VERSION_LESS 3.14)
|
||||||
|
write_basic_package_version_file (Eigen3ConfigVersion.cmake
|
||||||
|
VERSION ${EIGEN_VERSION_NUMBER}
|
||||||
|
COMPATIBILITY SameMajorVersion
|
||||||
|
ARCH_INDEPENDENT)
|
||||||
|
endif (CMAKE_VERSION VERSION_LESS 3.14)
|
||||||
|
|
||||||
|
# The Eigen target will be located in the Eigen3 namespace. Other CMake
|
||||||
|
# targets can refer to it using Eigen3::Eigen.
|
||||||
|
export (TARGETS eigen NAMESPACE Eigen3:: FILE Eigen3Targets.cmake)
|
||||||
|
# Export Eigen3 package to CMake registry such that it can be easily found by
|
||||||
|
# CMake even if it has not been installed to a standard directory.
|
||||||
|
export (PACKAGE Eigen3)
|
||||||
|
|
||||||
|
install (EXPORT Eigen3Targets NAMESPACE Eigen3:: DESTINATION ${CMAKEPACKAGE_INSTALL_DIR})
|
||||||
|
|
||||||
|
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/Eigen3ConfigVersion.cmake
|
||||||
|
DESTINATION ${CMAKEPACKAGE_INSTALL_DIR})
|
||||||
|
|
||||||
|
# Add uninstall target
|
||||||
|
if(NOT TARGET uninstall)
|
||||||
|
add_custom_target ( uninstall
|
||||||
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/EigenUninstall.cmake)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#==============================================================================
|
||||||
|
# General Build Configuration.
|
||||||
|
#==============================================================================
|
||||||
|
|
||||||
|
# Avoid setting the standard in a parent if unset.
|
||||||
|
if(PROJECT_IS_TOP_LEVEL)
|
||||||
|
set(CMAKE_CXX_STANDARD 14 CACHE STRING "Default C++ standard")
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Require C++ standard")
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "Allow C++ extensions")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Guard against in-source builds
|
||||||
|
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||||
|
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Guard against bad build-type strings
|
||||||
|
if (PROJECT_IS_TOP_LEVEL AND NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE "Release")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Only try to figure out how to link the math library if we are building something.
|
||||||
|
# Otherwise, let the parent project deal with dependencies.
|
||||||
|
if (EIGEN_IS_BUILDING_)
|
||||||
|
# Use Eigen's cmake files.
|
||||||
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR OFF)
|
||||||
|
|
||||||
|
find_package(StandardMathLibrary)
|
||||||
|
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "")
|
||||||
|
if(NOT STANDARD_MATH_LIBRARY_FOUND)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Can't link to the standard math library. Please report to the Eigen developers, telling them about your platform.")
|
||||||
|
else()
|
||||||
|
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
||||||
|
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO} ${STANDARD_MATH_LIBRARY}")
|
||||||
|
else()
|
||||||
|
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${STANDARD_MATH_LIBRARY}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
||||||
|
message(STATUS "Standard libraries to link to explicitly: ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}")
|
||||||
|
else()
|
||||||
|
message(STATUS "Standard libraries to link to explicitly: none")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Default tests/examples/libraries to row-major.
|
||||||
|
option(EIGEN_DEFAULT_TO_ROW_MAJOR "Use row-major as default matrix storage order" OFF)
|
||||||
|
if(EIGEN_DEFAULT_TO_ROW_MAJOR)
|
||||||
|
add_definitions("-DEIGEN_DEFAULT_TO_ROW_MAJOR")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#==============================================================================
|
||||||
|
# Test Configuration.
|
||||||
|
#==============================================================================
|
||||||
|
|
||||||
|
if (EIGEN_BUILD_TESTING)
|
||||||
|
function(ei_maybe_separate_arguments variable mode args)
|
||||||
# Use separate_arguments if the input is a single string containing a space.
|
# Use separate_arguments if the input is a single string containing a space.
|
||||||
# Otherwise, if it is already a list or doesn't have a space, just propagate
|
# Otherwise, if it is already a list or doesn't have a space, just propagate
|
||||||
# the original value. This is to better support multi-argument lists.
|
# the original value. This is to better support multi-argument lists.
|
||||||
@ -120,67 +326,29 @@ function(ei_maybe_separate_arguments variable mode args)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
set(${variable} ${args} PARENT_SCOPE)
|
set(${variable} ${args} PARENT_SCOPE)
|
||||||
endfunction(ei_maybe_separate_arguments)
|
endfunction(ei_maybe_separate_arguments)
|
||||||
|
|
||||||
# Determine if we should build shared libraries on this platform.
|
include(CheckCXXCompilerFlag)
|
||||||
get_cmake_property(EIGEN_BUILD_SHARED_LIBS TARGET_SUPPORTS_SHARED_LIBS)
|
macro(ei_add_cxx_compiler_flag FLAG)
|
||||||
|
string(REGEX REPLACE "-" "" SFLAG1 ${FLAG})
|
||||||
#############################################################################
|
string(REGEX REPLACE "\\+" "p" SFLAG ${SFLAG1})
|
||||||
# find how to link to the standard libraries #
|
check_cxx_compiler_flag(${FLAG} COMPILER_SUPPORT_${SFLAG})
|
||||||
#############################################################################
|
if(COMPILER_SUPPORT_${SFLAG})
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
|
||||||
find_package(StandardMathLibrary)
|
|
||||||
|
|
||||||
|
|
||||||
set(EIGEN_TEST_CUSTOM_LINKER_FLAGS "" CACHE STRING "Additional linker flags when linking unit tests.")
|
|
||||||
set(EIGEN_TEST_CUSTOM_CXX_FLAGS "" CACHE STRING "Additional compiler flags when compiling unit tests.")
|
|
||||||
|
|
||||||
# Convert space-separated arguments into CMake lists for downstream consumption.
|
|
||||||
ei_maybe_separate_arguments(EIGEN_TEST_CUSTOM_LINKER_FLAGS NATIVE_COMMAND "${EIGEN_TEST_CUSTOM_LINKER_FLAGS}")
|
|
||||||
ei_maybe_separate_arguments(EIGEN_TEST_CUSTOM_CXX_FLAGS NATIVE_COMMAND "${EIGEN_TEST_CUSTOM_CXX_FLAGS}")
|
|
||||||
|
|
||||||
|
|
||||||
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "")
|
|
||||||
|
|
||||||
if(NOT STANDARD_MATH_LIBRARY_FOUND)
|
|
||||||
|
|
||||||
message(FATAL_ERROR
|
|
||||||
"Can't link to the standard math library. Please report to the Eigen developers, telling them about your platform.")
|
|
||||||
|
|
||||||
else()
|
|
||||||
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
|
||||||
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO} ${STANDARD_MATH_LIBRARY}")
|
|
||||||
else()
|
|
||||||
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${STANDARD_MATH_LIBRARY}")
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endmacro()
|
||||||
|
|
||||||
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
set(EIGEN_TEST_CUSTOM_LINKER_FLAGS "" CACHE STRING "Additional linker flags when linking unit tests.")
|
||||||
message(STATUS "Standard libraries to link to explicitly: ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}")
|
set(EIGEN_TEST_CUSTOM_CXX_FLAGS "" CACHE STRING "Additional compiler flags when compiling unit tests.")
|
||||||
else()
|
# Convert space-separated arguments into CMake lists for downstream consumption.
|
||||||
message(STATUS "Standard libraries to link to explicitly: none")
|
ei_maybe_separate_arguments(EIGEN_TEST_CUSTOM_LINKER_FLAGS NATIVE_COMMAND "${EIGEN_TEST_CUSTOM_LINKER_FLAGS}")
|
||||||
endif()
|
ei_maybe_separate_arguments(EIGEN_TEST_CUSTOM_CXX_FLAGS NATIVE_COMMAND "${EIGEN_TEST_CUSTOM_CXX_FLAGS}")
|
||||||
|
|
||||||
option(EIGEN_BUILD_BTL "Build benchmark suite" OFF)
|
option(EIGEN_SPLIT_LARGE_TESTS "Split large tests into smaller executables" ON)
|
||||||
option(EIGEN_BUILD_SPBENCH "Build sparse benchmark suite" OFF)
|
set(EIGEN_TEST_MAX_SIZE "320" CACHE STRING "Maximal matrix/vector size, default is 320")
|
||||||
|
|
||||||
# Disable pkgconfig only for native Windows builds
|
# Flags for tests.
|
||||||
if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
if(NOT MSVC)
|
||||||
option(EIGEN_BUILD_PKGCONFIG "Build pkg-config .pc file for Eigen" ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR OFF)
|
|
||||||
|
|
||||||
option(EIGEN_SPLIT_LARGE_TESTS "Split large tests into smaller executables" ON)
|
|
||||||
|
|
||||||
option(EIGEN_DEFAULT_TO_ROW_MAJOR "Use row-major as default matrix storage order" OFF)
|
|
||||||
if(EIGEN_DEFAULT_TO_ROW_MAJOR)
|
|
||||||
add_definitions("-DEIGEN_DEFAULT_TO_ROW_MAJOR")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(EIGEN_TEST_MAX_SIZE "320" CACHE STRING "Maximal matrix/vector size, default is 320")
|
|
||||||
|
|
||||||
if(NOT MSVC)
|
|
||||||
# We assume that other compilers are partly compatible with GNUCC
|
# We assume that other compilers are partly compatible with GNUCC
|
||||||
|
|
||||||
# clang outputs some warnings for unknown flags that are not caught by check_cxx_compiler_flag
|
# clang outputs some warnings for unknown flags that are not caught by check_cxx_compiler_flag
|
||||||
@ -192,8 +360,7 @@ if(NOT MSVC)
|
|||||||
ei_add_cxx_compiler_flag("-pedantic")
|
ei_add_cxx_compiler_flag("-pedantic")
|
||||||
ei_add_cxx_compiler_flag("-Wall")
|
ei_add_cxx_compiler_flag("-Wall")
|
||||||
ei_add_cxx_compiler_flag("-Wextra")
|
ei_add_cxx_compiler_flag("-Wextra")
|
||||||
#ei_add_cxx_compiler_flag("-Weverything") # clang
|
# ei_add_cxx_compiler_flag("-Weverything") # clang
|
||||||
|
|
||||||
ei_add_cxx_compiler_flag("-Wundef")
|
ei_add_cxx_compiler_flag("-Wundef")
|
||||||
ei_add_cxx_compiler_flag("-Wcast-align")
|
ei_add_cxx_compiler_flag("-Wcast-align")
|
||||||
ei_add_cxx_compiler_flag("-Wchar-subscripts")
|
ei_add_cxx_compiler_flag("-Wchar-subscripts")
|
||||||
@ -207,14 +374,11 @@ if(NOT MSVC)
|
|||||||
ei_add_cxx_compiler_flag("-Wenum-conversion")
|
ei_add_cxx_compiler_flag("-Wenum-conversion")
|
||||||
ei_add_cxx_compiler_flag("-Wc++11-extensions")
|
ei_add_cxx_compiler_flag("-Wc++11-extensions")
|
||||||
ei_add_cxx_compiler_flag("-Wdouble-promotion")
|
ei_add_cxx_compiler_flag("-Wdouble-promotion")
|
||||||
# ei_add_cxx_compiler_flag("-Wconversion")
|
# ei_add_cxx_compiler_flag("-Wconversion")
|
||||||
|
|
||||||
ei_add_cxx_compiler_flag("-Wshadow")
|
ei_add_cxx_compiler_flag("-Wshadow")
|
||||||
|
|
||||||
ei_add_cxx_compiler_flag("-Wno-psabi")
|
ei_add_cxx_compiler_flag("-Wno-psabi")
|
||||||
ei_add_cxx_compiler_flag("-Wno-variadic-macros")
|
ei_add_cxx_compiler_flag("-Wno-variadic-macros")
|
||||||
ei_add_cxx_compiler_flag("-Wno-long-long")
|
ei_add_cxx_compiler_flag("-Wno-long-long")
|
||||||
|
|
||||||
ei_add_cxx_compiler_flag("-fno-check-new")
|
ei_add_cxx_compiler_flag("-fno-check-new")
|
||||||
ei_add_cxx_compiler_flag("-fno-common")
|
ei_add_cxx_compiler_flag("-fno-common")
|
||||||
ei_add_cxx_compiler_flag("-fstrict-aliasing")
|
ei_add_cxx_compiler_flag("-fstrict-aliasing")
|
||||||
@ -356,8 +520,7 @@ if(NOT MSVC)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
# C4127 - conditional expression is constant
|
# C4127 - conditional expression is constant
|
||||||
# C4714 - marked as __forceinline not inlined (I failed to deactivate it selectively)
|
# C4714 - marked as __forceinline not inlined (I failed to deactivate it selectively)
|
||||||
# We can disable this warning in the unit tests since it is clear that it occurs
|
# We can disable this warning in the unit tests since it is clear that it occurs
|
||||||
@ -408,13 +571,13 @@ else()
|
|||||||
message(STATUS "Enabling AVX512 in tests/examples")
|
message(STATUS "Enabling AVX512 in tests/examples")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif(NOT MSVC)
|
||||||
|
|
||||||
option(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION "Disable explicit vectorization in tests/examples" OFF)
|
option(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION "Disable explicit vectorization in tests/examples" OFF)
|
||||||
option(EIGEN_TEST_X87 "Force using X87 instructions. Implies no vectorization." OFF)
|
option(EIGEN_TEST_X87 "Force using X87 instructions. Implies no vectorization." OFF)
|
||||||
option(EIGEN_TEST_32BIT "Force generating 32bit code." OFF)
|
option(EIGEN_TEST_32BIT "Force generating 32bit code." OFF)
|
||||||
|
|
||||||
if(EIGEN_TEST_X87)
|
if(EIGEN_TEST_X87)
|
||||||
set(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION ON)
|
set(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION ON)
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=387")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=387")
|
||||||
@ -422,100 +585,39 @@ if(EIGEN_TEST_X87)
|
|||||||
else()
|
else()
|
||||||
message(STATUS "EIGEN_TEST_X87 ignored on your compiler")
|
message(STATUS "EIGEN_TEST_X87 ignored on your compiler")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(EIGEN_TEST_32BIT)
|
if(EIGEN_TEST_32BIT)
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
||||||
message(STATUS "Forcing generation of 32-bit code in tests/examples")
|
message(STATUS "Forcing generation of 32-bit code in tests/examples")
|
||||||
else()
|
else()
|
||||||
message(STATUS "EIGEN_TEST_32BIT ignored on your compiler")
|
message(STATUS "EIGEN_TEST_32BIT ignored on your compiler")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION)
|
if(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION)
|
||||||
add_definitions(-DEIGEN_DONT_VECTORIZE=1)
|
add_definitions(-DEIGEN_DONT_VECTORIZE=1)
|
||||||
message(STATUS "Disabling vectorization in tests/examples")
|
message(STATUS "Disabling vectorization in tests/examples")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT "Disable explicit alignment (hence vectorization) in tests/examples" OFF)
|
option(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT "Disable explicit alignment (hence vectorization) in tests/examples" OFF)
|
||||||
if(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT)
|
if(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT)
|
||||||
add_definitions(-DEIGEN_DONT_ALIGN=1)
|
add_definitions(-DEIGEN_DONT_ALIGN=1)
|
||||||
message(STATUS "Disabling alignment in tests/examples")
|
message(STATUS "Disabling alignment in tests/examples")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(EIGEN_TEST_NO_EXCEPTIONS "Disables C++ exceptions" OFF)
|
option(EIGEN_TEST_NO_EXCEPTIONS "Disables C++ exceptions" OFF)
|
||||||
if(EIGEN_TEST_NO_EXCEPTIONS)
|
if(EIGEN_TEST_NO_EXCEPTIONS)
|
||||||
ei_add_cxx_compiler_flag("-fno-exceptions")
|
ei_add_cxx_compiler_flag("-fno-exceptions")
|
||||||
message(STATUS "Disabling exceptions in tests/examples")
|
message(STATUS "Disabling exceptions in tests/examples")
|
||||||
endif()
|
|
||||||
|
|
||||||
set(EIGEN_CUDA_CXX_FLAGS "" CACHE STRING "Additional flags to pass to the cuda compiler.")
|
|
||||||
set(EIGEN_CUDA_COMPUTE_ARCH 30 CACHE STRING "The CUDA compute architecture(s) to target when compiling CUDA code")
|
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
|
|
||||||
# Backward compatibility support for EIGEN_INCLUDE_INSTALL_DIR
|
|
||||||
if(EIGEN_INCLUDE_INSTALL_DIR)
|
|
||||||
message(WARNING "EIGEN_INCLUDE_INSTALL_DIR is deprecated. Use INCLUDE_INSTALL_DIR instead.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(EIGEN_INCLUDE_INSTALL_DIR AND NOT INCLUDE_INSTALL_DIR)
|
|
||||||
set(INCLUDE_INSTALL_DIR ${EIGEN_INCLUDE_INSTALL_DIR}
|
|
||||||
CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where Eigen header files are installed")
|
|
||||||
else()
|
|
||||||
set(INCLUDE_INSTALL_DIR
|
|
||||||
"${CMAKE_INSTALL_INCLUDEDIR}/eigen3"
|
|
||||||
CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where Eigen header files are installed"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
set(CMAKEPACKAGE_INSTALL_DIR
|
|
||||||
"${CMAKE_INSTALL_DATADIR}/eigen3/cmake"
|
|
||||||
CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where Eigen3Config.cmake is installed"
|
|
||||||
)
|
|
||||||
set(PKGCONFIG_INSTALL_DIR
|
|
||||||
"${CMAKE_INSTALL_DATADIR}/pkgconfig"
|
|
||||||
CACHE PATH "The directory relative to CMAKE_INSTALL_PREFIX where eigen3.pc is installed"
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach(var INCLUDE_INSTALL_DIR CMAKEPACKAGE_INSTALL_DIR PKGCONFIG_INSTALL_DIR)
|
|
||||||
# If an absolute path is specified, make it relative to "{CMAKE_INSTALL_PREFIX}".
|
|
||||||
if(IS_ABSOLUTE "${${var}}")
|
|
||||||
file(RELATIVE_PATH "${var}" "${CMAKE_INSTALL_PREFIX}" "${${var}}")
|
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
|
||||||
|
|
||||||
install(FILES
|
set(EIGEN_CUDA_CXX_FLAGS "" CACHE STRING "Additional flags to pass to the cuda compiler.")
|
||||||
signature_of_eigen3_matrix_library
|
set(EIGEN_CUDA_COMPUTE_ARCH 30 CACHE STRING "The CUDA compute architecture(s) to target when compiling CUDA code")
|
||||||
DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel
|
|
||||||
)
|
|
||||||
|
|
||||||
if(EIGEN_BUILD_PKGCONFIG)
|
option(EIGEN_TEST_SYCL "Add Sycl support." OFF)
|
||||||
configure_file(eigen3.pc.in eigen3.pc @ONLY)
|
if(EIGEN_TEST_SYCL)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eigen3.pc
|
|
||||||
DESTINATION ${PKGCONFIG_INSTALL_DIR}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(DIRECTORY Eigen DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
|
|
||||||
|
|
||||||
|
|
||||||
# Avoid building docs if included from another project.
|
|
||||||
# Building documentation requires creating and running executables on the host
|
|
||||||
# platform. We shouldn't do this if cross-compiling.
|
|
||||||
if (${PROJECT_IS_TOP_LEVEL} AND NOT ${CMAKE_CROSSCOMPILING})
|
|
||||||
set(EIGEN_BUILD_DOC_DEFAULT ON)
|
|
||||||
else()
|
|
||||||
set(EIGEN_BUILD_DOC_DEFAULT OFF)
|
|
||||||
endif()
|
|
||||||
option(EIGEN_BUILD_DOC "Enable creation of Eigen documentation" ${EIGEN_BUILD_DOC_DEFAULT})
|
|
||||||
if(EIGEN_BUILD_DOC)
|
|
||||||
add_subdirectory(doc EXCLUDE_FROM_ALL)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# add SYCL
|
|
||||||
option(EIGEN_TEST_SYCL "Add Sycl support." OFF)
|
|
||||||
if(EIGEN_TEST_SYCL)
|
|
||||||
option(EIGEN_SYCL_DPCPP "Use the DPCPP Sycl implementation (DPCPP is default SYCL-Compiler)." ON)
|
option(EIGEN_SYCL_DPCPP "Use the DPCPP Sycl implementation (DPCPP is default SYCL-Compiler)." ON)
|
||||||
option(EIGEN_SYCL_TRISYCL "Use the triSYCL Sycl implementation." OFF)
|
option(EIGEN_SYCL_TRISYCL "Use the triSYCL Sycl implementation." OFF)
|
||||||
option(EIGEN_SYCL_ComputeCpp "Use the ComputeCPP Sycl implementation." OFF)
|
option(EIGEN_SYCL_ComputeCpp "Use the ComputeCPP Sycl implementation." OFF)
|
||||||
@ -565,75 +667,65 @@ if(EIGEN_TEST_SYCL)
|
|||||||
add_definitions(-DEIGEN_DONT_VECTORIZE=1)
|
add_definitions(-DEIGEN_DONT_VECTORIZE=1)
|
||||||
add_definitions(-DEIGEN_DONT_VECTORIZE_SYCL=1)
|
add_definitions(-DEIGEN_DONT_VECTORIZE_SYCL=1)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_dependent_option(BUILD_TESTING "Enable creation of tests." ON "PROJECT_IS_TOP_LEVEL" OFF)
|
|
||||||
option(EIGEN_BUILD_TESTING "Enable creation of Eigen tests." ${BUILD_TESTING})
|
|
||||||
if(EIGEN_BUILD_TESTING)
|
|
||||||
include(EigenConfigureTesting)
|
include(EigenConfigureTesting)
|
||||||
|
|
||||||
if(EIGEN_LEAVE_TEST_IN_ALL_TARGET)
|
if(EIGEN_LEAVE_TEST_IN_ALL_TARGET)
|
||||||
add_subdirectory(test) # can't do EXCLUDE_FROM_ALL here, breaks CTest
|
# CTest automatic test building relies on the "all" target.
|
||||||
|
add_subdirectory(test)
|
||||||
|
add_subdirectory(failtest)
|
||||||
else()
|
else()
|
||||||
add_subdirectory(test EXCLUDE_FROM_ALL)
|
add_subdirectory(test EXCLUDE_FROM_ALL)
|
||||||
|
add_subdirectory(failtest EXCLUDE_FROM_ALL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(failtest)
|
ei_testing_print_summary()
|
||||||
endif()
|
|
||||||
|
|
||||||
include(CMakeDetermineFortranCompiler)
|
if (EIGEN_SPLIT_TESTSUITE)
|
||||||
option(EIGEN_BUILD_BLAS "Toggles the building of the Eigen Blas library" ${CMAKE_Fortran_COMPILER})
|
ei_split_testsuite("${EIGEN_SPLIT_TESTSUITE}")
|
||||||
option(EIGEN_BUILD_LAPACK "Toggles the building of the included Eigen LAPACK library" ${CMAKE_Fortran_COMPILER})
|
endif()
|
||||||
if(EIGEN_LEAVE_TEST_IN_ALL_TARGET)
|
endif(EIGEN_BUILD_TESTING)
|
||||||
add_subdirectory(blas)
|
|
||||||
add_subdirectory(lapack)
|
|
||||||
else()
|
|
||||||
add_subdirectory(blas EXCLUDE_FROM_ALL)
|
|
||||||
add_subdirectory(lapack EXCLUDE_FROM_ALL)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
#==============================================================================
|
||||||
|
# Other Build Configurations.
|
||||||
|
#==============================================================================
|
||||||
add_subdirectory(unsupported)
|
add_subdirectory(unsupported)
|
||||||
|
|
||||||
add_subdirectory(demos EXCLUDE_FROM_ALL)
|
if(EIGEN_BUILD_BLAS)
|
||||||
|
add_subdirectory(blas)
|
||||||
|
endif()
|
||||||
|
|
||||||
# must be after test and unsupported, for configuring buildtests.in
|
if (EIGEN_BUILD_LAPACK)
|
||||||
add_subdirectory(scripts EXCLUDE_FROM_ALL)
|
add_subdirectory(lapack)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(EIGEN_BUILD_DOC)
|
||||||
|
add_subdirectory(doc EXCLUDE_FROM_ALL)
|
||||||
|
endif()
|
||||||
|
|
||||||
# TODO: consider also replacing EIGEN_BUILD_BTL by a custom target "make btl"?
|
# TODO: consider also replacing EIGEN_BUILD_BTL by a custom target "make btl"?
|
||||||
if(EIGEN_BUILD_BTL)
|
if(EIGEN_BUILD_BTL)
|
||||||
add_subdirectory(bench/btl EXCLUDE_FROM_ALL)
|
add_subdirectory(bench/btl EXCLUDE_FROM_ALL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(CLANG_FORMAT 9 EXACT)
|
|
||||||
if(CLANG_FORMAT_FOUND)
|
|
||||||
set(FORMAT_SOURCES)
|
|
||||||
list(APPEND FORMAT_SUBDIRS blas bench demos "doc" Eigen include lapack scripts share unsupported test failtest)
|
|
||||||
foreach(DIR ${FORMAT_SUBDIRS})
|
|
||||||
set(ABS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${DIR})
|
|
||||||
file(GLOB_RECURSE ${DIR}_SOURCES ${ABS_DIR}/*.cc ${ABS_DIR}/*.h ${ABS_DIR}/*.cpp ${ABS_DIR}/*.hpp ${ABS_DIR}/*.c)
|
|
||||||
list(APPEND FORMAT_SOURCES ${${DIR}_SOURCES})
|
|
||||||
endforeach()
|
|
||||||
file(GLOB FORMAT_SOURCES_WITHOUTENDING LIST_DIRECTORIES false ${CMAKE_CURRENT_SOURCE_DIR}/Eigen/* ${CMAKE_CURRENT_SOURCE_DIR}/Eigen/CXX11/* ${CMAKE_CURRENT_SOURCE_DIR}/unsupported/Eigen/* ${CMAKE_CURRENT_SOURCE_DIR}/unsupported/Eigen/CXX11/*)
|
|
||||||
list(FILTER FORMAT_SOURCES_WITHOUTENDING EXCLUDE REGEX ".*.txt$")
|
|
||||||
list (APPEND FORMAT_SOURCES ${FORMAT_SOURCES_WITHOUTENDING})
|
|
||||||
add_custom_target(format
|
|
||||||
COMMAND ${CLANG_FORMAT_EXECUTABLE} -i -style=file ${FORMAT_SOURCES}
|
|
||||||
DEPENDS ${FORMAT_SOURCES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT WIN32 AND EIGEN_BUILD_SPBENCH)
|
if(NOT WIN32 AND EIGEN_BUILD_SPBENCH)
|
||||||
add_subdirectory(bench/spbench EXCLUDE_FROM_ALL)
|
add_subdirectory(bench/spbench EXCLUDE_FROM_ALL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
configure_file(scripts/cdashtesting.cmake.in cdashtesting.cmake @ONLY)
|
if (EIGEN_BUILD_DEMOS)
|
||||||
|
add_subdirectory(demos EXCLUDE_FROM_ALL)
|
||||||
if(EIGEN_BUILD_TESTING)
|
|
||||||
ei_testing_print_summary()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "")
|
if (PROJECT_IS_TOP_LEVEL)
|
||||||
message(STATUS "Configured Eigen ${EIGEN_VERSION_NUMBER}")
|
# must be after test and unsupported, for configuring buildtests.in
|
||||||
message(STATUS "")
|
add_subdirectory(scripts EXCLUDE_FROM_ALL)
|
||||||
|
configure_file(scripts/cdashtesting.cmake.in cdashtesting.cmake @ONLY)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#==============================================================================
|
||||||
|
# Summary.
|
||||||
|
#==============================================================================
|
||||||
|
|
||||||
if(PROJECT_IS_TOP_LEVEL)
|
if(PROJECT_IS_TOP_LEVEL)
|
||||||
string(TOLOWER "${CMAKE_GENERATOR}" cmake_generator_tolower)
|
string(TOLOWER "${CMAKE_GENERATOR}" cmake_generator_tolower)
|
||||||
@ -654,90 +746,24 @@ if(PROJECT_IS_TOP_LEVEL)
|
|||||||
message(STATUS " | cmake . -DCMAKE_INSTALL_PREFIX=yourprefix")
|
message(STATUS " | cmake . -DCMAKE_INSTALL_PREFIX=yourprefix")
|
||||||
message(STATUS " | Or:")
|
message(STATUS " | Or:")
|
||||||
message(STATUS " | cmake . -DINCLUDE_INSTALL_DIR=yourdir")
|
message(STATUS " | cmake . -DINCLUDE_INSTALL_DIR=yourdir")
|
||||||
|
message(STATUS "uninstall| Remove files installed by the install target")
|
||||||
|
if (EIGEN_BUILD_DOC)
|
||||||
message(STATUS "doc | Generate the API documentation, requires Doxygen & LaTeX")
|
message(STATUS "doc | Generate the API documentation, requires Doxygen & LaTeX")
|
||||||
|
endif()
|
||||||
if(EIGEN_BUILD_TESTING)
|
if(EIGEN_BUILD_TESTING)
|
||||||
message(STATUS "check | Build and run the unit-tests. Read this page:")
|
message(STATUS "check | Build and run the unit-tests. Read this page:")
|
||||||
message(STATUS " | http://eigen.tuxfamily.org/index.php?title=Tests")
|
message(STATUS " | http://eigen.tuxfamily.org/index.php?title=Tests")
|
||||||
endif()
|
endif()
|
||||||
if(CLANG_FORMAT_FOUND)
|
if (EIGEN_BUILD_BLAS)
|
||||||
message(STATUS "format | Formats the source code according to .clang-format file")
|
|
||||||
endif()
|
|
||||||
message(STATUS "blas | Build BLAS library (not the same thing as Eigen)")
|
message(STATUS "blas | Build BLAS library (not the same thing as Eigen)")
|
||||||
message(STATUS "uninstall| Remove files installed by the install target")
|
endif()
|
||||||
|
if (EIGEN_BUILD_LAPACK)
|
||||||
|
message(STATUS "lapack | Build LAPACK subset library (not the same thing as Eigen)")
|
||||||
|
endif()
|
||||||
message(STATUS "---------+--------------------------------------------------------------")
|
message(STATUS "---------+--------------------------------------------------------------")
|
||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set ( EIGEN_VERSION_STRING ${EIGEN_VERSION_NUMBER} )
|
message(STATUS "")
|
||||||
set ( EIGEN_VERSION_MAJOR ${EIGEN_WORLD_VERSION} )
|
message(STATUS "Configured Eigen ${EIGEN_VERSION_NUMBER}")
|
||||||
set ( EIGEN_VERSION_MINOR ${EIGEN_MAJOR_VERSION} )
|
message(STATUS "")
|
||||||
set ( EIGEN_VERSION_PATCH ${EIGEN_MINOR_VERSION} )
|
|
||||||
|
|
||||||
include (CMakePackageConfigHelpers)
|
|
||||||
|
|
||||||
# Imported target support
|
|
||||||
add_library (eigen INTERFACE)
|
|
||||||
add_library (Eigen3::Eigen ALIAS eigen)
|
|
||||||
target_include_directories (eigen INTERFACE
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
|
||||||
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
|
|
||||||
)
|
|
||||||
|
|
||||||
# Export as title case Eigen
|
|
||||||
set_target_properties (eigen PROPERTIES EXPORT_NAME Eigen)
|
|
||||||
|
|
||||||
install (TARGETS eigen EXPORT Eigen3Targets)
|
|
||||||
|
|
||||||
option(EIGEN_BUILD_CMAKE_PACKAGE "Enables the creation of EigenConfig.cmake and related files" ON)
|
|
||||||
if(EIGEN_BUILD_CMAKE_PACKAGE)
|
|
||||||
configure_package_config_file (
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Eigen3Config.cmake.in
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
|
|
||||||
INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}
|
|
||||||
NO_SET_AND_CHECK_MACRO # Eigen does not provide legacy style defines
|
|
||||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO # Eigen does not provide components
|
|
||||||
)
|
|
||||||
|
|
||||||
# NOTE Remove the first code path once the minimum required CMake version is
|
|
||||||
# bumped to 3.14 or above.
|
|
||||||
if (CMAKE_VERSION VERSION_LESS 3.14)
|
|
||||||
# Remove CMAKE_SIZEOF_VOID_P from Eigen3ConfigVersion.cmake since Eigen does
|
|
||||||
# not depend on architecture specific settings or libraries. More
|
|
||||||
# specifically, an Eigen3Config.cmake generated from a 64 bit target can be
|
|
||||||
# used for 32 bit targets as well (and vice versa).
|
|
||||||
set (_Eigen3_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
|
|
||||||
unset (CMAKE_SIZEOF_VOID_P)
|
|
||||||
write_basic_package_version_file (Eigen3ConfigVersion.cmake
|
|
||||||
VERSION ${EIGEN_VERSION_NUMBER}
|
|
||||||
COMPATIBILITY SameMajorVersion)
|
|
||||||
set (CMAKE_SIZEOF_VOID_P ${_Eigen3_CMAKE_SIZEOF_VOID_P})
|
|
||||||
else (CMAKE_VERSION VERSION_LESS 3.14)
|
|
||||||
write_basic_package_version_file (Eigen3ConfigVersion.cmake
|
|
||||||
VERSION ${EIGEN_VERSION_NUMBER}
|
|
||||||
COMPATIBILITY SameMajorVersion
|
|
||||||
ARCH_INDEPENDENT)
|
|
||||||
endif (CMAKE_VERSION VERSION_LESS 3.14)
|
|
||||||
|
|
||||||
# The Eigen target will be located in the Eigen3 namespace. Other CMake
|
|
||||||
# targets can refer to it using Eigen3::Eigen.
|
|
||||||
export (TARGETS eigen NAMESPACE Eigen3:: FILE Eigen3Targets.cmake)
|
|
||||||
# Export Eigen3 package to CMake registry such that it can be easily found by
|
|
||||||
# CMake even if it has not been installed to a standard directory.
|
|
||||||
export (PACKAGE Eigen3)
|
|
||||||
|
|
||||||
install (EXPORT Eigen3Targets NAMESPACE Eigen3:: DESTINATION ${CMAKEPACKAGE_INSTALL_DIR})
|
|
||||||
|
|
||||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/Eigen3Config.cmake
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/Eigen3ConfigVersion.cmake
|
|
||||||
DESTINATION ${CMAKEPACKAGE_INSTALL_DIR})
|
|
||||||
|
|
||||||
# Add uninstall target
|
|
||||||
if(NOT TARGET uninstall)
|
|
||||||
add_custom_target ( uninstall
|
|
||||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/EigenUninstall.cmake)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (EIGEN_SPLIT_TESTSUITE)
|
|
||||||
ei_split_testsuite("${EIGEN_SPLIT_TESTSUITE}")
|
|
||||||
endif()
|
|
||||||
|
@ -91,6 +91,7 @@ macro(ei_add_test_internal testname testname_with_suffix)
|
|||||||
if(EIGEN_TEST_CUSTOM_LINKER_FLAGS)
|
if(EIGEN_TEST_CUSTOM_LINKER_FLAGS)
|
||||||
target_link_libraries(${targetname} ${EIGEN_TEST_CUSTOM_LINKER_FLAGS})
|
target_link_libraries(${targetname} ${EIGEN_TEST_CUSTOM_LINKER_FLAGS})
|
||||||
endif()
|
endif()
|
||||||
|
target_link_libraries(${targetname} Eigen3::Eigen)
|
||||||
|
|
||||||
if(${ARGC} GREATER 3)
|
if(${ARGC} GREATER 3)
|
||||||
set(libs_to_link ${ARGV3})
|
set(libs_to_link ${ARGV3})
|
||||||
|
@ -110,6 +110,7 @@ foreach(target IN LISTS EIGEN_LAPACK_TARGETS)
|
|||||||
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
||||||
target_link_libraries(${target} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
|
target_link_libraries(${target} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
|
||||||
endif()
|
endif()
|
||||||
|
target_link_libraries(${target} Eigen3::Eigen)
|
||||||
add_dependencies(lapack ${target})
|
add_dependencies(lapack ${target})
|
||||||
install(TARGETS ${target}
|
install(TARGETS ${target}
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
|
@ -4,7 +4,7 @@ if(EIGEN_BUILD_DOC)
|
|||||||
endif()
|
endif()
|
||||||
if(EIGEN_BUILD_TESTING)
|
if(EIGEN_BUILD_TESTING)
|
||||||
if(EIGEN_LEAVE_TEST_IN_ALL_TARGET)
|
if(EIGEN_LEAVE_TEST_IN_ALL_TARGET)
|
||||||
add_subdirectory(test) # can't do EXCLUDE_FROM_ALL here, breaks CTest
|
add_subdirectory(test) # CTest automatic test building relies on the "all" target.
|
||||||
else()
|
else()
|
||||||
add_subdirectory(test EXCLUDE_FROM_ALL)
|
add_subdirectory(test EXCLUDE_FROM_ALL)
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user