c++ - FindLibXml2 的 CMake find_package

标签 c++ cmake libxml2 clion

我正在尝试创建一个 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)

不确定使用哪一个

最佳答案

您不应该拥有 FindFindLibXml2 ;做:

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/

相关文章:

c++ - 使用 LD_PRELOAD 重定向 system() 函数调用

c++ - 如何定义二维 vector 哪些行是已知的c++

c++ - 寻找类中的隐式沟通

c++ - log4cplus 属性文件更改未在运行时读取

c++ - 带有 Boost 的 CMake 1.62.0 : "No Boost libraries were found"

c++ - 哪个 C++ XSLT 处理器?

c - 为什么 libxml2 在 C/C++ 代码中到处都使用 "BAD_CAST"?

c++ - 将 CMake 与模板一起使用

运行 make CentOS 时出现 OpenCV 错误

Python 错误信息 "Incompatible library version"libxml 和 etree.so