ITK:找不到 ITKConfig.cmake
ITK: Cannot find ITKConfig.cmake
我一直在尝试在一台新 PC 上设置 ITK,当我在一个项目上使用 运行 CMake 时遇到了 运行 问题。
我下载了 ITK 4.8.2,将其解压缩,使用 CMake 配置并像往常一样生成。但是,这次 CMake 发出以下错误:
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!
CMakeLists.txt 文件非常棒,只是想确保 cmake/ITK 设置正确:
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})
我添加了 CMAKE_PREFIX_PATH
和 ITK_DIR
作为附加条目,后者指向 ITK 文件夹的位置。但是问题依旧。
至于它说找不到的文件,一个存在于我设置 cmake 来构建二进制文件的文件夹中。在我的例子中,两个目录中有两个文件:
--E:\ITK\InsightToolkit-4.8.2-build\ITKConfig.cmake
--E:\ITK\InsightToolkit-4.8.2-build\CMakeFiles\ITKConfig.cmake
我找到了成功构建测试项目(以及我目前正在处理的另一个项目)的方法。我在构建项目时指定了 ITK 构建文件夹的位置作为参数:
cmake -DITK_DIR=E:/ITK/Insight-Toolkit-4.8.2 CMakeLists.txt
我仍然不确定为什么我以前从来没有这样做过,为什么 ITK_DIR 变量在我在 cmake GUI 中配置 ITK 后不存在,但这确实允许我构建项目。
CMake 3.0 中删除了文件 FindITK.cmake。
FindITK
This module no longer exists.
This module existed in versions of CMake prior to 3.1, but became only
a thin wrapper around find_package(ITK NO_MODULE)
to provide
compatibility for projects using long-outdated conventions. Now
find_package(ITK)
will search for ITKConfig.cmake
directly.
来源:https://cmake.org/cmake/help/v3.4/module/FindITK.html
因此 CMake 寻找 ITKConfig.cmake
,它必须安装到默认位置,或者您必须将 ITKConfig.cmake
的路径添加到 CMAKE_PREFIX_PATH
.
None 这些或其他口味对我有用,就好像 ITK_DIR 从未被定义过:
cmake -DITK_DIR=C:\Users\user\InsightToolkit-5.0.0_bld C:\Users\user\HelloWorldITK cmake
-DITK_DIR=C:\Users\user\InsightToolkit-5.0.0_bld C:\Users\user\HelloWorldITK cmake
-DITK_DIR=C:/Users/user/InsightToolkit-5.0.0_bld C:\Users\user\HelloWorldITK
但是,将此添加到 CMakeLists.txt 解决了问题:
SET(ITK_DIR "C:\Users\user\InsightToolkit-5.0.0_bld")
我一直在尝试在一台新 PC 上设置 ITK,当我在一个项目上使用 运行 CMake 时遇到了 运行 问题。
我下载了 ITK 4.8.2,将其解压缩,使用 CMake 配置并像往常一样生成。但是,这次 CMake 发出以下错误:
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!
CMakeLists.txt 文件非常棒,只是想确保 cmake/ITK 设置正确:
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})
我添加了 CMAKE_PREFIX_PATH
和 ITK_DIR
作为附加条目,后者指向 ITK 文件夹的位置。但是问题依旧。
至于它说找不到的文件,一个存在于我设置 cmake 来构建二进制文件的文件夹中。在我的例子中,两个目录中有两个文件:
--E:\ITK\InsightToolkit-4.8.2-build\ITKConfig.cmake
--E:\ITK\InsightToolkit-4.8.2-build\CMakeFiles\ITKConfig.cmake
我找到了成功构建测试项目(以及我目前正在处理的另一个项目)的方法。我在构建项目时指定了 ITK 构建文件夹的位置作为参数:
cmake -DITK_DIR=E:/ITK/Insight-Toolkit-4.8.2 CMakeLists.txt
我仍然不确定为什么我以前从来没有这样做过,为什么 ITK_DIR 变量在我在 cmake GUI 中配置 ITK 后不存在,但这确实允许我构建项目。
CMake 3.0 中删除了文件 FindITK.cmake。
FindITK
This module no longer exists.This module existed in versions of CMake prior to 3.1, but became only a thin wrapper around
find_package(ITK NO_MODULE)
to provide compatibility for projects using long-outdated conventions. Nowfind_package(ITK)
will search forITKConfig.cmake
directly.
来源:https://cmake.org/cmake/help/v3.4/module/FindITK.html
因此 CMake 寻找 ITKConfig.cmake
,它必须安装到默认位置,或者您必须将 ITKConfig.cmake
的路径添加到 CMAKE_PREFIX_PATH
.
None 这些或其他口味对我有用,就好像 ITK_DIR 从未被定义过:
cmake -DITK_DIR=C:\Users\user\InsightToolkit-5.0.0_bld C:\Users\user\HelloWorldITK cmake
-DITK_DIR=C:\Users\user\InsightToolkit-5.0.0_bld C:\Users\user\HelloWorldITK cmake
-DITK_DIR=C:/Users/user/InsightToolkit-5.0.0_bld C:\Users\user\HelloWorldITK
但是,将此添加到 CMakeLists.txt 解决了问题:
SET(ITK_DIR "C:\Users\user\InsightToolkit-5.0.0_bld")