我正在尝试创建一个 CMake 文件来检测 libxml2 的位置。从示例和 CMake 文档中看到,find_package 可以正常工作。我在 Ubuntu 上运行 CLion,libxml2 使用 apt-get 安装,FindLibXml2.cmake 位于 CMake 的模块下。但是 CMake 返回神秘消息:
Could not find a package configuration file provided by "FindLibXml2" with any of the following names:
FindLibXml2Config.cmake findlibxml2-config.cmake
Add the installation prefix of "FindLibXml2" to CMAKE_PREFIX_PATH or set "FindLibXml2_DIR" to a directory containing one of the above files. If "FindLibXml2" provides a separate development package or SDK, be sure it has been installed.
为什么它试图找到这个-config
文件?我做错了什么?
CMake 片段
find_package(FindLibXml2 CONFIG REQUIRED)
我也尝试过
find_package(FindLibXml2 REQUIRED)
不确定使用哪一个
最佳答案
您不应该拥有 Find
在FindLibXml2
;做:
find_package(LibXml2 REQUIRED)
如 documentation 中所述:
CMake searches for a file called
Find<package>.cmake
关于c++ - FindLibXml2 的 CMake find_package,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48165179/