[CMake] How do I specify VTK minimum version?

Victor Lamoine victor.lamoine at institutmaupertuis.fr
Tue Jul 11 09:18:11 EDT 2017


Hi,

I am using CMake to set up a VTK project. Our project requires VTK to be version 7.1 or newer.
I'm using Ubuntu 16.04 with CMake 3.5.1.

My CMakeLists.txt looks like this:

cmake_minimum_required(VERSION 2.8)
project(test_vtk_versions)

find_package(VTK 7.1 REQUIRED)
include(${VTK_USE_FILE})

add_executable(test_vtk_1 test_vtk_1)
target_link_libraries(test_vtk_1 ${VTK_LIBRARIES})

I have several versions of VTK installed on my machine:

  * VTK 6.2 from the Ubuntu repositories
  * VTK 7.1 compiled/installed from sources
  * VTK 8.0 compiled/installed from sources

$ ls /usr/local/lib/cmake/vtk* /usr/lib/cmake/vtk*
/usr/lib/cmake/vtk-6.2:
exportheader.cmake.in       UseVTK.cmake                   vtkJavaWrapping.cmake       vtkModuleMacros.cmake        VTKTargets.cmake                 vtkThirdParty.cmake     vtkWrapPython.sip.in
(... list was manually shortened ...)

/usr/local/lib/cmake/vtk-7.1:
FindTCL.cmake          VTKConfigVersion.cmake         vtkGroups.cmake             vtkModuleHeaders.cmake.in    vtkObjectFactory.h.in     vtkTclWrapping.cmake    vtkWrapPython.cmake
(... list was manually shortened ...)

/usr/local/lib/cmake/vtk-8.0:
FindTCL.cmake          VTKConfigVersion.cmake         vtkGroups.cmake             vtkModuleHeaders.cmake.in    vtkObjectFactory.h.in                          vtkTclTkMacros.cmake    vtkWrapping.cmake
(... list was manually shortened ...)

The project can be configured (Unix Makefile) and compiled, it is compiled against VTK 7.1 in this configuration.
However if I remove VTK 7.1 from the system (using sudo xargs rm < "install_manifest.txt") then I end with this this error:

CMake Error at CMakeLists.txt:4 (find_package):
  Could not find a configuration file for package "VTK" that is compatible
  with requested version "7.1".

  The following configuration files were considered but not accepted:

    /usr/local/lib/cmake/vtk-8.0/VTKConfig.cmake, version: 8.0.0
    /usr/lib/cmake/vtk-6.2/VTKConfig.cmake, version: 6.2.0

I have also tried find_package(VTK 7.1*.0* REQUIRED), without success.

Why isn't VTK 8.0.0 accepted? It is a greater version number so I expected it to be ok.
How do I specify that I want VTK 7.1 OR newer?

Thank you for your time
Bye

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170711/63bb383a/attachment-0001.html>


More information about the CMake mailing list