关于c ++:FindLibXml2的CMake find_package

CMake find_package for FindLibXml2

我正在尝试创建一个将检测libxml2位置的CMake文件。 从示例和CMake文档中可以看到,find_package很简单。 我在Ubuntu上运行CLion,使用apt-get安装了libxml2,FindLibXml2.cmake位于CMake的模块下。 但是,CMake返回的是隐秘消息:

Could not find a package configuration file provided by"FindLibXml2"
with any of the following names:

1
2
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)

不确定使用哪个


您不应在FindLibXml2中包含Find; 做:

1
find_package(LibXml2 REQUIRED)

如文档中所述:

CMake searches for a file called Find.cmake