D
D
Dmitry Vyalkov2015-09-05 09:52:20
CMake
Dmitry Vyalkov, 2015-09-05 09:52:20

How to fix library search errors in cmake?

I'm trying to figure out with cmake to automate the assembly of cross-platform applications. I got to the point of using third-party libraries and ran into the following problem.
Example on github . Curl code was taken as an example, which compiles and works fine.
Compiled CMakeLists.txt for this project. And I tried to compile, I build for tests in 2 systems FreeBSD 10 and Fedora 21. And I came across a problem with finding libraries. I broke my head in 3 days of searching, but I did not solve the problem.
Trying to build on Fedora throws a library search error.

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:136 (message):
  Could NOT find LibXml2 (missing: LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:343 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake/Modules/FindLibXml2.cmake:69 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:9 (find_package)

At the same time, the FindLibXml2.cmake search plugin is in its proper place. But he doesn't find it.
Under FreeBSD 10, the same operation fails and produces a Makefile that does not work. While searching for problems, I found that the library search in the LIBXML2_INCLUDE_DIRS variable instead of the correct path ( /usr/local/include/libxml2/ ) writes the following /usr/local/include/usr/include/usr/include
And when trying to build the resulting Makefile, we get an error about inability to find header files in the specified directories. If you manually rewrite the LIBXML2_INCLUDE_DIRS value, then the generated Makefile builds the program perfectly.
After such a long and, I beg your pardon, chaotic explanation, two questions.
1. Who is to blame? (As I understand it, the search modules of the LibXml2 library for cmake are incorrect?)
2. What should I do? (how to ensure a "problem-free" assembly on different systems, because such glitches can appear on different OS and with different libraries? I can't check everything, and I just want to use cmake for this reason)?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question