cmake in find-package mode fails to find vtk
CMake can be used in pkg-config mode to output libs and cflags for VTK. The VTK library is found if used in CMakeLists.txt. However, the find-package mode fails:
$ cmake --find-package -DNAME=VTK -DLANGUAGE=CXX -DCOMPILER_ID=GNU -DMODE=COMPILE
CMake Error at /work/software/x86_64/vtk/vtk-8.0.0/lib/cmake/vtk-8.0/VTKConfig.cmake:33 (message):
GCC 4.6 or later is required.
Call Stack (most recent call first):
/mnt/md127/work/software/x86_64/cmake/cmake-3.5.2/share/cmake-3.5/Modules/CMakeFindPackageMode.cmake:190 (find_package)
VTK not found.
CMake Error: Problem processing arguments. Aborting.
Inside VTKConfig.cmake
, the following code returns the error:
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
message(FATAL_ERROR "GCC 4.6 or later is required." )
endif ()
The compiler version is correct (gcc 4.8.5), but the variable CMAKE_CXX_COMPILER_VERSION
is actually not defined. When passing the additional arguments -DCMAKE_CXX_COMPILER_VERSION=4.8.5 -DCMAKE_CXX_STANDARD_COMPUTED_DEFAULT=4.8.5
, cmake returns correctly.