I am trying to build C++ project using Cmake and it cannot find the LibXml2 libraries (I believe) I have downloaded and installed correctly. This is on a Windows 10 machine with cmake 3.7.1.
Here is the relevant portion of the cmake configuration file:
find_package(LibXml2 REQUIRED)
include_directories(${LIBXML2_INCLUDE_DIR})
set(LIBS ${LIBS} ${LIBXML2_LIBRARIES})
Here are my environment variables:
LIBXML2_INCLUDE_DIR=C:\Program Files\libxml2\include
LIBXML2_LIBRARIES=C:\Program Files\libxml2\lib
And here are the contents of the C:\Program Files\libxml2 directory:
/mnt/c/Program Files/libxml2$ tree .
.
├── bin
│ ├── libxml2.dll
│ ├── xmlcatalog.exe
│ └── xmllint.exe
├── include
│ └── libxml
│ ├── c14n.h
│ ├── catalog.h
│ ├── chvalid.h
│ ├── debugXML.h
│ ├── dict.h
│ ├── DOCBparser.h
│ ├── encoding.h
│ ├── entities.h
│ ├── globals.h
│ ├── hash.h
│ ├── HTMLparser.h
│ ├── HTMLtree.h
│ ├── list.h
│ ├── nanoftp.h
│ ├── nanohttp.h
│ ├── parser.h
│ ├── parserInternals.h
│ ├── pattern.h
│ ├── relaxng.h
│ ├── SAX2.h
│ ├── SAX.h
│ ├── schemasInternals.h
│ ├── schematron.h
│ ├── threads.h
│ ├── tree.h
│ ├── uri.h
│ ├── valid.h
│ ├── xinclude.h
│ ├── xlink.h
│ ├── xmlautomata.h
│ ├── xmlerror.h
│ ├── xmlexports.h
│ ├── xmlIO.h
│ ├── xmlmemory.h
│ ├── xmlmodule.h
│ ├── xmlreader.h
│ ├── xmlregexp.h
│ ├── xmlsave.h
│ ├── xmlschemas.h
│ ├── xmlschemastypes.h
│ ├── xmlstring.h
│ ├── xmlunicode.h
│ ├── xmlversion.h
│ ├── xmlwriter.h
│ ├── xpath.h
│ ├── xpathInternals.h
│ └── xpointer.h
├── lib
│ ├── libxml2_a_dll.lib
│ ├── libxml2_a.lib
│ └── libxml2.lib
└── readme.txt
And the cmake output I receive is:
CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message): Could NOT find LibXml2 (missing: LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) C:/Program Files/CMake/share/cmake-3.7/Modules/FindLibXml2.cmake:58 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
I've been wrestling with this one for a day or so now, can anyone give me a hint what I'm doing wrong?
When you run CMake, define the variables in via -D and use slashes as the directory delimiter (and backspaces to escape the space in directory names.
cmake .. -DLIBXML2_INCLUDE_DIR:PATH=C:/Program\ Files/libxml2/include -DLIBXML2_LIBRARIES:PATH=C:/Program\ Files/libxml2/lib