CMake configuration fails on macOS

Summary

There are several CMake issues when I try to configure eigen.

  1. I don't use sparse solvers. There should be an option to disable add_subdirectory(bench/spbench EXCLUDE_FROM_ALL). CMake attempts to find seven sparse solver packages merely for benchmark purposes.
  2. OPENMP is tested by testing whether the compiler flag -fopenmp works. Testing -fopenmp does not work for AppleClang, and it assumed OpenMP would not work. This could be improved as shown here.
  3. There are several CMake warnings due to incorrect package names passed to find_package_handle_standard_args (cf. below)
  4. The configuration fails while searching for PTSCOTCH (starting from line 48 in bench/spbench/CMakeLists.txt, find_package(PASTIX QUIET COMPONENTS METIS SCOTCH)). I'm not sure whether this is intended because lines 118-123 in FindPastix.cmake look suspicious:
    if (${component} STREQUAL "SCOTCH")
      set(PASTIX_LOOK_FOR_SCOTCH ON)
    endif()
    if (${component} STREQUAL "SCOTCH")
      set(PASTIX_LOOK_FOR_PTSCOTCH ON)
    endif()

Probably, the second statement should compare component to PTSCOTCH.

The CMake error at the end is caused by PTSCOTCH_INCLUDE_DIRS, which is to set to PTSCOTCH_INCLUDE_DIRS-NOTFOUND;/usr/local/include on my system. I assume this should be PTSCOTCH_INCLUDE_DIRS-NOTFOUND instead, and there is a break() statement missing after set(PTSCOTCH_INCLUDE_DIRS "PTSCOTCH_INCLUDE_DIRS-NOTFOUND") in line 174 of cmake/FindPTSCOTCH.cmake. Similarly, PTSCOTCH_LIBRARIES is set to PTSCOTCH_ptscotch_LIBRARY-NOTFOUND;PTSCOTCH_ptscotcherr_LIBRARY-NOTFOUND;/usr/local/lib/libscotch.a;/usr/local/lib/libscotcherr.a which evaluates to true and leads to another CMake error. PTSCOTCH_LIBRARIES should evaluate to false if at least one of the required libraries wasn't found.

Environment

  • Operating System : macOS, 10.14.6
  • Architecture : x64
  • Eigen Version : 3.3.91
  • Cmake Version: 3.20.3

Minimal Example

wget https://gitlab.com/libeigen/eigen/-/archive/3.4-rc1/eigen-3.4-rc1.tar.gz
tar -xf eigen-3.4-rc1.tar.gz
mkdir build
cd build
cmake ../eigen-3.4-rc1
-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test EIGEN_COMPILER_SUPPORT_CPP11
-- Performing Test EIGEN_COMPILER_SUPPORT_CPP11 - Success
-- Performing Test COMPILER_SUPPORT_std=cpp03
-- Performing Test COMPILER_SUPPORT_std=cpp03 - Success
-- Performing Test standard_math_library_linked_to_automatically
-- Performing Test standard_math_library_linked_to_automatically - Success
-- Standard libraries to link to explicitly: none
-- Performing Test COMPILER_SUPPORT_WERROR
-- Performing Test COMPILER_SUPPORT_WERROR - Success
-- Performing Test COMPILER_SUPPORT_pedantic
-- Performing Test COMPILER_SUPPORT_pedantic - Success
-- Performing Test COMPILER_SUPPORT_Wall
-- Performing Test COMPILER_SUPPORT_Wall - Success
-- Performing Test COMPILER_SUPPORT_Wextra
-- Performing Test COMPILER_SUPPORT_Wextra - Success
-- Performing Test COMPILER_SUPPORT_Wundef
-- Performing Test COMPILER_SUPPORT_Wundef - Success
-- Performing Test COMPILER_SUPPORT_Wcastalign
-- Performing Test COMPILER_SUPPORT_Wcastalign - Success
-- Performing Test COMPILER_SUPPORT_Wcharsubscripts
-- Performing Test COMPILER_SUPPORT_Wcharsubscripts - Success
-- Performing Test COMPILER_SUPPORT_Wnonvirtualdtor
-- Performing Test COMPILER_SUPPORT_Wnonvirtualdtor - Success
-- Performing Test COMPILER_SUPPORT_Wunusedlocaltypedefs
-- Performing Test COMPILER_SUPPORT_Wunusedlocaltypedefs - Success
-- Performing Test COMPILER_SUPPORT_Wpointerarith
-- Performing Test COMPILER_SUPPORT_Wpointerarith - Success
-- Performing Test COMPILER_SUPPORT_Wwritestrings
-- Performing Test COMPILER_SUPPORT_Wwritestrings - Success
-- Performing Test COMPILER_SUPPORT_Wformatsecurity
-- Performing Test COMPILER_SUPPORT_Wformatsecurity - Success
-- Performing Test COMPILER_SUPPORT_Wshorten64to32
-- Performing Test COMPILER_SUPPORT_Wshorten64to32 - Success
-- Performing Test COMPILER_SUPPORT_Wlogicalop
-- Performing Test COMPILER_SUPPORT_Wlogicalop - Failed
-- Performing Test COMPILER_SUPPORT_Wenumconversion
-- Performing Test COMPILER_SUPPORT_Wenumconversion - Success
-- Performing Test COMPILER_SUPPORT_Wcpp11extensions
-- Performing Test COMPILER_SUPPORT_Wcpp11extensions - Success
-- Performing Test COMPILER_SUPPORT_Wdoublepromotion
-- Performing Test COMPILER_SUPPORT_Wdoublepromotion - Success
-- Performing Test COMPILER_SUPPORT_Wshadow
-- Performing Test COMPILER_SUPPORT_Wshadow - Success
-- Performing Test COMPILER_SUPPORT_Wnopsabi
-- Performing Test COMPILER_SUPPORT_Wnopsabi - Failed
-- Performing Test COMPILER_SUPPORT_Wnovariadicmacros
-- Performing Test COMPILER_SUPPORT_Wnovariadicmacros - Success
-- Performing Test COMPILER_SUPPORT_Wnolonglong
-- Performing Test COMPILER_SUPPORT_Wnolonglong - Success
-- Performing Test COMPILER_SUPPORT_fnochecknew
-- Performing Test COMPILER_SUPPORT_fnochecknew - Success
-- Performing Test COMPILER_SUPPORT_fnocommon
-- Performing Test COMPILER_SUPPORT_fnocommon - Success
-- Performing Test COMPILER_SUPPORT_fstrictaliasing
-- Performing Test COMPILER_SUPPORT_fstrictaliasing - Success
-- Performing Test COMPILER_SUPPORT_wd981
-- Performing Test COMPILER_SUPPORT_wd981 - Failed
-- Performing Test COMPILER_SUPPORT_wd2304
-- Performing Test COMPILER_SUPPORT_wd2304 - Failed
-- Performing Test COMPILER_SUPPORT_STRICTANSI
-- Performing Test COMPILER_SUPPORT_STRICTANSI - Failed
-- Performing Test COMPILER_SUPPORT_Qunusedarguments
-- Performing Test COMPILER_SUPPORT_Qunusedarguments - Success
-- Performing Test COMPILER_SUPPORT_ansi
-- Performing Test COMPILER_SUPPORT_ansi - Success
-- Performing Test COMPILER_SUPPORT_OPENMP
-- Performing Test COMPILER_SUPPORT_OPENMP - Failed
-- Found unsuitable Qt version "5.9.7" from /usr/local/anaconda3/bin/qmake
-- Looking for a Fortran compiler
-- Looking for a Fortran compiler - /usr/local/bin/ifort
-- The Fortran compiler identification is Intel 19.1.2.20200623
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /usr/local/bin/ifort - skipped
-- Checking whether /usr/local/bin/ifort supports Fortran 90
-- Checking whether /usr/local/bin/ifort supports Fortran 90 - yes
-- Found CHOLMOD: /usr/local/include
-- Found UMFPACK: /usr/local/include
-- Found KLU: /usr/local/include
-- Performing Test SUPERLU_HAS_GLOBAL_MEM_USAGE_T
-- Performing Test SUPERLU_HAS_GLOBAL_MEM_USAGE_T - Success
-- Performing Test SUPERLU_HAS_CLEAN_ENUMS
-- Performing Test SUPERLU_HAS_CLEAN_ENUMS - Success
-- Performing Test SUPERLU_HAS_GLOBALLU_T
-- Performing Test SUPERLU_HAS_GLOBALLU_T - Success
-- Found SuperLU: /usr/local/include (found suitable version "5.0", minimum required is "4.0")
CMake Warning (dev) at /usr/local/Cellar/cmake/3.20.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (HWLOC).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.20.3/share/cmake/Modules/FindPkgConfig.cmake:70 (find_package_handle_standard_args)
  cmake/FindHWLOC.cmake:68 (include)
  cmake/FindPASTIX.cmake:203 (find_package)
  test/CMakeLists.txt:89 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2")
-- Checking for one of the modules 'hwloc'
-- Performing Test HAVE_HWLOC_PARENT_MEMBER
-- Performing Test HAVE_HWLOC_PARENT_MEMBER - Success
-- Performing Test HAVE_HWLOC_CACHE_ATTR
-- Performing Test HAVE_HWLOC_CACHE_ATTR - Success
-- Performing Test HAVE_HWLOC_OBJ_PU
-- Performing Test HAVE_HWLOC_OBJ_PU - Success
-- Looking for hwloc_bitmap_free in hwloc
-- Looking for hwloc_bitmap_free in hwloc - not found
-- Found Threads: TRUE
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - found
CMake Warning (dev) at /usr/local/Cellar/cmake/3.20.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (BLAS) does
  not match the name of the calling package (BLASEXT).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindBLASEXT.cmake:377 (find_package_handle_standard_args)
  cmake/FindPASTIX.cmake:214 (find_package)
  test/CMakeLists.txt:89 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found BLAS: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/lib/libblas.tbd
-- Looking for SCOTCH_graphInit
-- Looking for SCOTCH_graphInit - found
-- Performing Test SCOTCH_Num_4
-- Performing Test SCOTCH_Num_4 - Success
-- Looking for METIS_NodeND
-- Looking for METIS_NodeND - found
-- A version of Pastix has been found but pastix_nompi.h does not exist in the include directory. Because Eigen tests require a version without MPI, we disable the Pastix backend.
-- Found SPQR: /usr/local/include
-- Found unsuitable Qt version "5.9.7" from /usr/local/anaconda3/bin/qmake
-- Performing Test COMPILER_SUPPORT_FASTMATH
-- Performing Test COMPILER_SUPPORT_FASTMATH - Success
-- Found Boost: /usr/local/lib/cmake/Boost-1.76.0/BoostConfig.cmake (found suitable version "1.76.0", minimum required is "1.53.0")
-- Could NOT find GoogleHash (missing: GOOGLEHASH_INCLUDES GOOGLEHASH_COMPILE)
-- Could NOT find Adolc (missing: ADOLC_INCLUDES ADOLC_LIBRARIES)
-- Found MPFR: /usr/local/include (Required is at least version "2.3.0")
-- Found GMP: /usr/local/include
-- Found FFTW: /usr/local/include
CUDA_TOOLKIT_ROOT_DIR not found or specified
-- Could NOT find CUDA (missing: CUDA_TOOLKIT_ROOT_DIR CUDA_NVCC_EXECUTABLE CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (Required is at least version "7.0")
-- Found unsuitable Qt version "5.9.7" from /usr/local/anaconda3/bin/qmake
-- Qt4 not found, so disabling the mandelbrot and opengl demos
CMake Warning (dev) at /usr/local/Cellar/cmake/3.20.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (HWLOC).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.20.3/share/cmake/Modules/FindPkgConfig.cmake:70 (find_package_handle_standard_args)
  cmake/FindHWLOC.cmake:68 (include)
  cmake/FindPASTIX.cmake:203 (find_package)
  bench/spbench/CMakeLists.txt:48 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /usr/local/Cellar/cmake/3.20.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (BLAS) does
  not match the name of the calling package (BLASEXT).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/FindBLASEXT.cmake:377 (find_package_handle_standard_args)
  cmake/FindPASTIX.cmake:214 (find_package)
  bench/spbench/CMakeLists.txt:48 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find BLAS (missing: BLAS_LIBRARY_DIRS)
-- Looking for SCOTCH_graphInit
-- Looking for SCOTCH_graphInit - found
-- Looking for SCOTCH_dgraphInit
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
PTSCOTCH_INCLUDE_DIRS
   used as include directory in directory /Users/rlanger/Downloads/tmp/eigen_cmake_bug/build/CMakeFiles/CMakeTmp
   used as include directory in directory /Users/rlanger/Downloads/tmp/eigen_cmake_bug/build/CMakeFiles/CMakeTmp
   used as include directory in directory /Users/rlanger/Downloads/tmp/eigen_cmake_bug/build/CMakeFiles/CMakeTmp
PTSCOTCH_ptscotch_LIBRARY
    linked by target "cmTC_a949a" in directory /Users/rlanger/Downloads/tmp/eigen_cmake_bug/build/CMakeFiles/CMakeTmp
PTSCOTCH_ptscotcherr_LIBRARY
    linked by target "cmTC_a949a" in directory /Users/rlanger/Downloads/tmp/eigen_cmake_bug/build/CMakeFiles/CMakeTmp

CMake Error in /Users/rlanger/Downloads/tmp/eigen_cmake_bug/build/CMakeFiles/CMakeTmp/CMakeLists.txt:
  Found relative path while evaluating include directories of "cmTC_a949a":

    "PTSCOTCH_INCLUDE_DIRS-NOTFOUND"



CMake Error in /Users/rlanger/Downloads/tmp/eigen_cmake_bug/build/CMakeFiles/CMakeTmp/CMakeLists.txt:
  Found relative path while evaluating include directories of "cmTC_a949a":

    "PTSCOTCH_INCLUDE_DIRS-NOTFOUND"



CMake Error at /usr/local/Cellar/cmake/3.20.3/share/cmake/Modules/CheckFunctionExists.cmake:92 (try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  cmake/FindPTSCOTCH.cmake:335 (check_function_exists)
  cmake/FindPASTIX.cmake:306 (find_package)
  bench/spbench/CMakeLists.txt:48 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Users/rlanger/Downloads/tmp/eigen_cmake_bug/build/CMakeFiles/CMakeOutput.log".
See also "/Users/rlanger/Downloads/tmp/eigen_cmake_bug/build/CMakeFiles/CMakeError.log".

What is the expected correct behavior?

The CMakeLists.txt should provide an option to disable benchmarks for sparse solvers. If bench/spbench is added, searching for optional packages should not lead to CMake errors. The CMake configuration should be warning-free.