1# 2# Copyright 2020 The TensorFlow Authors. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# https://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16if(TARGET eigen OR eigen_POPULATED) 17 return() 18endif() 19 20include(OverridableFetchContent) 21 22OverridableFetchContent_Declare( 23 eigen 24 GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git 25 # Sync with tensorflow/third_party/eigen3/workspace.bzl 26 GIT_TAG 34780d8bd13d0af0cf17a22789ef286e8512594d 27 # It's not currently (cmake 3.17) possible to shallow clone with a GIT TAG 28 # as cmake attempts to git checkout the commit hash after the clone 29 # which doesn't work as it's a shallow clone hence a different commit hash. 30 # https://gitlab.kitware.com/cmake/cmake/-/issues/17770 31 # GIT_SHALLOW TRUE 32 GIT_PROGRESS TRUE 33 PREFIX "${CMAKE_BINARY_DIR}" 34 SOURCE_DIR "${CMAKE_BINARY_DIR}/eigen" 35 LICENSE_FILE "COPYING.MPL2" 36) 37OverridableFetchContent_GetProperties(eigen) 38if(NOT eigen_POPULATED) 39 OverridableFetchContent_Populate(eigen) 40endif() 41 42# Patch Eigen to disable Fortran compiler check for BLAS and LAPACK tests. 43if(NOT EIGEN_DISABLED_FORTRAN_COMPILER_CHECK) 44 file(WRITE "${eigen_SOURCE_DIR}/cmake/language_support.cmake" " 45 function(workaround_9220 language language_works) 46 set(\${language_works} OFF PARENT_SCOPE) 47 endfunction()" 48 ) 49endif() 50# Patch Eigen to disable benchmark suite. 51if(NOT EIGEN_BUILD_BTL) 52 file(WRITE "${eigen_SOURCE_DIR}/bench/spbench/CMakeLists.txt" "") 53endif() 54 55# Patch Eigen to disable doc generation, as it builds C++ standalone apps with 56# the host toolchain which breaks cross compiled builds. 57if(NOT EIGEN_GENERATE_DOCS) 58 file(WRITE "${eigen_SOURCE_DIR}/doc/CMakeLists.txt" "") 59 file(WRITE "${eigen_SOURCE_DIR}/unsupported/doc/CMakeLists.txt" "") 60endif() 61 62set(EIGEN_DISABLED_FORTRAN_COMPILER_CHECK ON CACHE BOOL "Disabled Fortran") 63 64set(EIGEN_LEAVE_TEST_IN_ALL_TARGET OFF CACHE BOOL 65 "Remove tests from all target." 66) 67set(BUILD_TESTING OFF CACHE BOOL "Disable tests.") 68set(EIGEN_TEST_CXX11 OFF CACHE BOOL "Disable tests of C++11 features.") 69set(EIGEN_BUILD_BTL OFF CACHE BOOL "Disable benchmark suite.") 70set(EIGEN_BUILD_PKGCONFIG OFF CACHE BOOL "Disable pkg-config.") 71set(EIGEN_SPLIT_LARGE_TESTS OFF CACHE BOOL "Disable test splitting.") 72set(EIGEN_DEFAULT_TO_ROW_MAJOR OFF CACHE BOOL 73 "Disable row-major matrix storage" 74) 75set(EIGEN_TEST_NOQT ON CACHE BOOL "Disable Qt support in tests.") 76set(EIGEN_TEST_SSE2 OFF CACHE BOOL "Disable SSE2 test.") 77set(EIGEN_TEST_SSE3 OFF CACHE BOOL "Disable SSE3 test.") 78set(EIGEN_TEST_SSSE3 OFF CACHE BOOL "Disable SSSE3 test.") 79set(EIGEN_TEST_SSE4_1 OFF CACHE BOOL "Disable SSE4.1 test.") 80set(EIGEN_TEST_SSE4_2 OFF CACHE BOOL "Disable SSE4.2 test.") 81set(EIGEN_TEST_AVX OFF CACHE BOOL "Disable AVX test.") 82set(EIGEN_TEST_FMA OFF CACHE BOOL "Disable FMA test.") 83set(EIGEN_TEST_AVX512 OFF CACHE BOOL "Disable AVX512 test.") 84set(EIGEN_TEST_F16C OFF CACHE BOOL "Disable F16C test.") 85set(EIGEN_TEST_ALTIVEC OFF CACHE BOOL "Disable AltiVec test.") 86set(EIGEN_TEST_VSX OFF CACHE BOOL "Disable VSX test.") 87set(EIGEN_TEST_MSA OFF CACHE BOOL "Disable MSA test.") 88set(EIGEN_TEST_NEON OFF CACHE BOOL "Disable NEON test.") 89set(EIGEN_TEST_NEON64 OFF CACHE BOOL "Disable NEON64 test.") 90set(EIGEN_TEST_Z13 OFF CACHE BOOL "Disable Z13 test.") 91set(EIGEN_TEST_Z14 OFF CACHE BOOL "Disable Z14 test.") 92set(EIGEN_TEST_OPENMP OFF CACHE BOOL "Disable OpenMP test.") 93set(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION OFF CACHE BOOL "Disable vectorization") 94set(EIGEN_TEST_X87 OFF CACHE BOOL "Disable X87 instructions test") 95set(EIGEN_TEST_32BIT OFF CACHE BOOL "Disable 32-bit instructions test") 96set(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT OFF CACHE BOOL "Disable alignment test") 97set(EIGEN_TEST_NO_EXCEPTIONS OFF CACHE BOOL "Disable exceptions test") 98set(EIGEN_TEST_SYCL OFF CACHE BOOL "Disable Sycl test") 99set(EIGEN_SYCL_TRISYCL OFF CACHE BOOL "Disable triSYCL test") 100# Make sure only MPL2.0 or more permissively licensed code is included. 101add_compile_definitions(EIGEN_MPL2_ONLY) 102add_subdirectory("${eigen_SOURCE_DIR}" "${eigen_BINARY_DIR}") 103