CMake Warning Policy CMP0146
Summary
When loading Eigen in a project using CMake 3.28.1 a CMake warning is generated because the policy CMP0146 for working with the CUDA module is not set. This does not seem to hinder the execution, and is rather a cosmetic issue, but it is still irritating if a warning is thrown. This seems to have been introduced in CMake 3.28.1. From the documentation:
CMake version 3.28.1 warns when the policy is not set and uses ``OLD`` behavior.
Use the ``cmake_policy()`` command to set it to ``OLD`` or ``NEW``
explicitly.
Setting the policy using cmake_policy(SET CMP0146 NEW) did not resolve the issue for me.
Environment
- Operating System : macOS
- Architecture : arm64-apple-darwin23.2.0
- Eigen Version : 3.4.0
- Compiler Version : Apple clang version 15.0.0 (clang-1500.1.0.2.5)
- Compile Flags : -std=c++03 -pedantic -Wall -Wextra -Wundef -Wcast-align -Wchar-subscripts -Wnon-virtual-dtor -Wunused-local-typedefs -Wpointer-arith -Wwrite-strings -Wformat-security -Wshorten-64-to-32 -Wenum-conversion -Wc++11-extensions -Wdouble-promotion -Wshadow -Wno-psabi -Wno-variadic-macros -Wno-long-long -fno-check-new -fno-common -fstrict-aliasing -Qunused-arguments -ansi
- Vector Extension : ?
Minimal Example
# Make sure the CMake FetchContent module is loaded
include(FetchContent)
########################################################################
# Pull in the Eigen3 module
FetchContent_Declare(Eigen3
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 3.4.0 #Note: Best practice to use specific git-hash or tagged version
)
FetchContent_MakeAvailable(Eigen3)
# Link Eigen to a target
target_link_libraries(macOSMain Eigen3::Eigen)
Steps to reproduce
- Make sure CMake is on 3.28.1
- Pull in Eigen and run CMake
What is the current bug behavior?
A warning is generated
What is the expected correct behavior?
No warning is generated
Relevant logs
-- Performing Test COMPILER_SUPPORT_std=cpp03
-- Performing Test COMPILER_SUPPORT_std=cpp03 - Success
-- Standard libraries to link to explicitly: none
-- Found unsuitable Qt version "6.2.4" from /Users/pg/Programming/Qt/6.2.4/macos/bin/qmake
-- Looking for sgemm_
-- Looking for sgemm_ - found
-- Could NOT find CHOLMOD (missing: CHOLMOD_INCLUDES CHOLMOD_LIBRARIES)
-- Could NOT find UMFPACK (missing: UMFPACK_INCLUDES UMFPACK_LIBRARIES)
-- Could NOT find KLU (missing: KLU_INCLUDES KLU_LIBRARIES)
-- Could NOT find SuperLU (missing: SUPERLU_INCLUDES SUPERLU_LIBRARIES SUPERLU_VERSION_OK) (Required is at least version "4.0")
-- 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.
-- Could NOT find SPQR (missing: SPQR_INCLUDES SPQR_LIBRARIES)
-- Found unsuitable Qt version "6.2.4" from /Users/pg/Programming/Qt/6.2.4/macos/bin/qmake
-- Could NOT find GoogleHash (missing: GOOGLEHASH_INCLUDES GOOGLEHASH_COMPILE)
-- Could NOT find Adolc (missing: ADOLC_INCLUDES ADOLC_LIBRARIES)
-- Could NOT find MPFR (missing: MPFR_INCLUDES MPFR_LIBRARIES MPFR_VERSION_OK) (Required is at least version "1.0.0")
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
CMake Warning (dev) at cmake-build-debug-macos/_deps/eigen3-src/unsupported/test/CMakeLists.txt:293 (find_package):
Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake
--help-policy CMP0146" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.This warning is for project developers. Use -Wno-dev to suppress it.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 "6.2.4" from /Users/pg/Programming/Qt/6.2.4/macos/bin/qmake
-- Qt4 not found, so disabling the mandelbrot and opengl demos
-- Could NOT find CHOLMOD (missing: CHOLMOD_INCLUDES CHOLMOD_LIBRARIES)
-- Could NOT find UMFPACK (missing: UMFPACK_INCLUDES UMFPACK_LIBRARIES)
-- Could NOT find KLU (missing: KLU_INCLUDES KLU_LIBRARIES)
-- Could NOT find SuperLU (missing: SUPERLU_INCLUDES SUPERLU_LIBRARIES SUPERLU_VERSION_OK) (Required is at least version "4.0")
-- 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.
-- ************************************************************
-- *** Eigen's unit tests configuration summary ***
-- ************************************************************
--
-- Build type: Debug
-- Build site: pg-macbookpro-182.local
-- Build string: darwin-23.2.0-clang++-15.0.0-sse2-64bit
-- Enabled backends: Boost.Multiprecision,
-- Disabled backends: CHOLMOD, UMFPACK, KLU, SuperLU, PaStiX, METIS, SPQR, Qt4 support, GoogleHash, Adolc, MPFR C++, fftw, OpenGL,
-- Default order: Column-major
-- Maximal matrix/vector size: 320
-- SSE2: Using architecture defaults
-- SSE3: Using architecture defaults
-- SSSE3: Using architecture defaults
-- SSE4.1: Using architecture defaults
-- SSE4.2: Using architecture defaults
-- AVX: Using architecture defaults
-- AVX2: Using architecture defaults
-- FMA: Using architecture defaults
-- AVX512: Using architecture defaults
-- AVX512DQ: Using architecture defaults
-- Altivec: Using architecture defaults
-- VSX: Using architecture defaults
-- MIPS MSA: Using architecture defaults
-- ARM NEON: Using architecture defaults
-- ARMv8 NEON: Using architecture defaults
-- S390X ZVECTOR: Using architecture defaults
-- C++11: OFF
-- SYCL: OFF
-- CUDA: OFF
-- HIP: OFF
--
CXX: /Library/Developer/CommandLineTools/usr/bin/c++
CXX_FLAGS: -std=c++03 -pedantic -Wall -Wextra -Wundef -Wcast-align -Wchar-subscripts -Wnon-virtual-dtor -Wunused-local-typedefs -Wpointer-arith -Wwrite-strings -Wformat-security -Wshorten-64-to-32 -Wenum-conversion -Wc++11-extensions -Wdouble-promotion -Wshadow -Wno-psabi -Wno-variadic-macros -Wno-long-long -fno-check-new -fno-common -fstrict-aliasing -Qunused-arguments -ansi
Sparse lib flags:-- ************************************************************
--
-- Configured Eigen 3.4.0
--
-- Available targets (use: cmake --build . --target TARGET):
-- ---------+--------------------------------------------------------------
-- Target | Description
-- ---------+--------------------------------------------------------------
-- install | Install Eigen. Headers will be installed to:
-- | <CMAKE_INSTALL_PREFIX>/<INCLUDE_INSTALL_DIR>
-- | Using the following values:
-- | CMAKE_INSTALL_PREFIX: /usr/local
-- | INCLUDE_INSTALL_DIR: include/eigen3
-- | Change the install location of Eigen headers using:
-- | cmake . -DCMAKE_INSTALL_PREFIX=yourprefix
-- | Or:
-- | cmake . -DINCLUDE_INSTALL_DIR=yourdir
-- doc | Generate the API documentation, requires Doxygen & LaTeX
-- check | Build and run the unit-tests. Read this page:
-- | http://eigen.tuxfamily.org/index.php?title=Tests
-- blas | Build BLAS library (not the same thing as Eigen)
-- uninstall| Remove files installed by the install target
-- ---------+--------------------------------------------------------------
Warning Messages
CMake Warning (dev) at cmake-build-debug-macos/_deps/eigen3-src/unsupported/test/CMakeLists.txt:293 (find_package):
Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake
--help-policy CMP0146" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
This is my first time using Eigen, I hope I did not miss anything.
Edited by Patrick Glöckner