FindPackageTest can fail if VTK is installed with EXPORTED config
Running the unit tests on Fedora 36 with vtk-devel-9.1.0-12.fc36.x86_64
installed from distro packaging, the FindPackageTest
unit test will fail with errors caused (indirectly) by the system's /usr/lib64/cmake/vtk/vtk-config.cmake
:
Output of ctest
test run
ctest -j6 --rerun-failed --output-on-failure
Test project /home/ferd/rpmbuild/REPOS/cmake/build
Guessing configuration NoConfig
Start 28: FindPackageTest
Start 143: CPackComponentsForAll-NUGET-default
Start 474: RunCMake.MaxRecursionDepth
1/3 Test #28: FindPackageTest .......................***Failed 0.66 sec
Internal cmake changing into directory: /home/ferd/rpmbuild/REPOS/cmake/build/Tests/FindPackageTest
Error: cmake execution failed
CMake Warning (dev) at /home/ferd/rpmbuild/REPOS/cmake/Modules/FindOpenGL.cmake:315 (message):
Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
available. Run "cmake --help-policy CMP0072" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
FindOpenGL found both a legacy GL library:
OPENGL_gl_LIBRARY: /usr/lib64/libGL.so
and GLVND libraries for OpenGL and GLX:
OPENGL_opengl_LIBRARY: /usr/lib64/libOpenGL.so
OPENGL_glx_LIBRARY: /usr/lib64/libGLX.so
OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
CMakeLists.txt:17 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at FindPackageHandleStandardArgs.cmake:1 (message):
This file
(/home/ferd/rpmbuild/REPOS/cmake/Tests/FindPackageTest/FindPackageHandleStandardArgs.cmake)
must not be included, but FindPackageHandleStandardArgs.cmake from Modules/
instead !
Call Stack (most recent call first):
/usr/lib64/cmake/vtk/FindGLEW.cmake:10 (include)
/usr/lib64/cmake/vtk/VTK-vtk-module-find-packages.cmake:303 (find_package)
/usr/lib64/cmake/vtk/vtk-config.cmake:150 (include)
CMakeLists.txt:23 (find_package)
Configuring incomplete, errors occurred!
See also "/home/ferd/rpmbuild/REPOS/cmake/build/Tests/FindPackageTest/CMakeFiles/CMakeOutput.log".
The issues are twofold:
-
Tests/FindPackageTest/CMakeLists.txt
usesfind_package(VTK QUIET)
as its test for (according to the comments) "a package that has an advanced find module". But,FindVTK.cmake
was dropped from the source tree in 2014 (commit 8838e720), and since then VTK has had no find module of any kind, or level of advancement. -
The code in VTK's
vtk-config.cmake
does acmake_policy(PUSH)
, overriding the test'scmake_policy(SET CMP0017 NEW)
and causing the Find modules included with VTK to load the wrongFindPackageHandleStandardArgs.cmake
.