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?
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)