7

This is one part of my CMakeLists.txt

set (VTK_DIR "/usr/include/vtk-5.8") find_package(VTK REQUIRED) include(${VTK_USE_FILE}) IF(VTK_FOUND) message("found VTK. Version:" ${VTK_VERSION}. VTK_DIR: ${VTK_DIR}) ELSE(VTK_FOUND) MESSAGE(FATAL_ERROR "Cannot build the executable without VTK. Please set the VTK_DIR") ENDIF(VTK_FOUND) 

cmake . tells me:

found VTK. Version:6.0.0.VTK_DIR:/usr/local/lib/cmake/vtk-6.0

Giving the VTK_DIR in the command line does not help either:

cmake -DVTK_DIR:PATH=/usr/include/vtk-5.8 . 

Still cmake looks in /usr/local/lib/cmake/vtk-6.0 for VTK.

What is wrong here?

3 Answers 3

3

VTK_DIR is a cache variable, which keeps its state across CMake invocations. You can set it from the command line, or via one of the CMake GUI interfaces.

Or, if you're certain you want to force it from your CMake file itself, you can use this syntax:

SET(VTK_DIR "/usr/include/vtk-5.8" CACHE PATH "VTK directory override" FORCE) 
Sign up to request clarification or add additional context in comments.

2 Comments

Well my VTK-header are not there, where cmake expect them. Normally I should be able to precise in the command line (or the GUI-windows) the directory where cmake should look for the header-files. Your solution does not work for me. I also tried desperatly: set (VTK_INCLUDE_DIRS "/usr/include/vtk-5.8" CACHE PATH "VTK directory override" FORCE), but without success
I'm afraid the only thing remaining is to debug the FindVTK.cmake module. Add some MESSAGE() outputs so you can see what it's doing to find VTK.
1

What you need is VTK install subdirectory with VTKConfig.cmake. Alternatively, build directory might work as well.

As suggested by Peter, try:

SET(VTK_DIR "/usr/include/vtk-5.8/XXX" CACHE PATH "VTK directory override" FORCE) 

and point it to the folder where you have VTKConfig.cmake.

YOu could install cmake-qt-gui - there you can easily enter the required paths using a GUI. If it doesn't use the path you entered, it means this is not the path it wants (see above).

Comments

0

You should call find_package with the NO_MODULE option,

find_package(VTK REQUIRED NO_MODULE) 

This will force CMake to skip the find module, which hasn't been required for a number of releases. You also need to point CMake at the location of the VTKConfig.cmake file, not the C++ headers. Setting CMAKE_PREFIX_PATH to /usr/local would have CMake check /usr/local before any other path for example. If your VTKConfig.cmake is installed in the /usr prefix, then the config file is likely in /usr/lib/cmake/vtk-5.8, and the VTK_DIR should be set to that too.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.