MicrobicTiger
MicrobicTiger

Reputation: 597

CMake could not find the VTKConfig.cmake

I'm trying to compile a program in CMake but I'm getting this error.

By not providing "FindVTK.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "VTK", but
CMake did not find one.

Could not find a package configuration file provided by "VTK" (requested
version 6.1) with any of the following names:

VTKConfig.cmake
vtk-config.cmake

I can't find the relevant files (VTKConfig.cmake or vtk-config.cmake) on the machine but do have VTKConfig.cmake.in (which also doesn't work). Does anyone know where I can download the file from, or what I might be doing wrong.

Upvotes: 11

Views: 24418

Answers (5)

Bane Sullivan
Bane Sullivan

Reputation: 241

I ran into this problem recently, and solved the issue in my case.

In CMake/vtkWheelPreparation.cmake in VTK, if the wheel build is enabled, VTK_INSTALL_SDK defaults to OFF, which usually defaults to ON. If you are setting VTK_WHEEL_BUILD, then this happens:

if(NOT DEFINED VTK_INSTALL_SDK)
  set(VTK_INSTALL_SDK OFF)
endif()

See

Explicitly setting VTK_INSTALL_SDK to ON in your config should fix this issue and provide vtk-config.cmake in the build directory.

I included this fix in my CMake configs for building VTK here (these configs closely follow what VTK publishes to PyPI): https://github.com/banesullivan/vtk-cmake

set(VTK_INSTALL_SDK ON CACHE STRING "")
set(VTK_WHEEL_BUILD ON CACHE STRING "")

Upvotes: 2

堀貴裕
堀貴裕

Reputation: 1

"FindVTK.cmake"the file of cmake is made in build directry.

please add this Path. export VTK_DIR=/path/VTK-Release-version/build

Upvotes: 0

Rishabh Agrahari
Rishabh Agrahari

Reputation: 3717

If you have successfully built VTK, you would end up with a VTK-Release-build folder containing all the build files, one of which is VTKConfig.cmake. Your program is not able to find this file. You just need to set an environment variable named VTK_DIR before running your program. You can do so by running:

export VTK_DIR=/path/to/VTK-Release-build/

Upvotes: 2

Lars Bilke
Lars Bilke

Reputation: 5229

When you have successfully built VTK you can give CMake a hint where to look for VTK with the VTK_DIR-parameter:

cmake -DVTK_DIR=/path/to/vtk/build-directory /path/to/your/source-directory

Upvotes: 5

andybauer
andybauer

Reputation: 845

It seems like you just have the VTK source code but haven't built it yet. VTKConfig.cmake.in is a template used by CMake to generate the VTKConfig.cmake file in the build and install directory. Look at http://www.vtk.org/Wiki/VTK/Building to see how to build VTK.

Upvotes: 7

Related Questions