Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake find_package for FindLibXml2

I'm trying to create a CMake file that will detect the location of libxml2. From what see in examples and CMake documentation the find_package simply works. I'm running CLion on Ubuntu, the libxml2 is installed using apt-get, the FindLibXml2.cmake is located under CMake's modules. However CMake returns cryptic message:

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.

Why it is trying to find this -config file? what I'm doing wrong?

CMake snippet

find_package(FindLibXml2 CONFIG REQUIRED)

I've also tried

find_package(FindLibXml2 REQUIRED)

Not sure which one to use

like image 893
kreuzerkrieg Avatar asked Jun 14 '26 13:06

kreuzerkrieg


1 Answers

You should not have the Find in FindLibXml2; do:

find_package(LibXml2 REQUIRED)

As explained in the documentation:

CMake searches for a file called Find<package>.cmake

like image 53
piwi Avatar answered Jun 16 '26 03:06

piwi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!