How to fix CMake 'Could not find a package configuration file provided by "VTK"' on Ubuntu

Problem:

When trying to compile your CMake project, you see an error message such as

CMake Error at cMake/FreeCAD_Helpers/SetupSalomeSMESH.cmake:29 (find_package):
  Could not find a package configuration file provided by "VTK" with any of
  the following names:

    VTKConfig.cmake
    vtk-config.cmake

  Add the installation prefix of "VTK" to CMAKE_PREFIX_PATH or set "VTK_DIR"
  to a directory containing one of the above files.  If "VTK" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:71 (SetupSalomeSMESH)

Solution

sudo apt -y install libvtk9-dev

Note that depending on the version of Ubuntu you use, you might need to use a slightly different version (9) of vtklibvtk9-dev works for Ubuntu 22.04