I’ve been trying to set up ITK on a new PC and have run into a problem when I go to run CMake on a project.
I downloaded ITK 4.8.2, extracted it, configured with CMake and generated as always. However, this time CMake emitts the following error:
CMake Error at CMakeLists.txt:4 (find_package):
By not providing "FindITK.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "ITK", but
CMake did not find one.
Could not find a package configuration file provided by "ITK" with any of
the following names:
ITKConfig.cmake
itk-config.cmake
Add the installation prefix of "ITK" to CMAKE_PREFIX_PATH or set "ITK_DIR"
to a directory containing one of the above files. If "ITK" provides a
separate development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!
The CMakeLists.txt file is pretty baron, just trying to ensure cmake/ITK is set up properly:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(ITKTest)
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
add_executable(ITKTest main.cpp)
target_link_libraries(ITKTest ${ITK_LIBRARIES})
I added CMAKE_PREFIX_PATH
and ITK_DIR
as additional entries, with the latter pointing to the location of the ITK folder. But the problem persists.
As for the files it says it cannot find, one is present in the folder that I set cmake to build the binaries to. In my case there are two files in two directories:
--E:\ITK\InsightToolkit-4.8.2-build\ITKConfig.cmake
--E:\ITK\InsightToolkit-4.8.2-build\CMakeFiles\ITKConfig.cmake
ITK_DIR
toE:\\ITK\\InsightToolkit-4.8.2-build
(\` should be interpreted by CMake as single backslash). Two things looks suspicious for me: 1. running
cmake CMakeLists.txt. Normally, argument for cmake is source directory, not a script file itself. And it is better to perform out-of-source builds. 2. Having second
ITKConfig.cmake` underCMakeFiles
. Looks like same directory have been used as build and install one for ITK. – Cholecystectomy