[LLVMdev] Adding a library to CMake deps

Óscar Fuentes ofv at wanadoo.es
Tue Sep 3 08:53:43 PDT 2013


Renato Golin <renato.golin at linaro.org> writes:

> When cross-compiling LLVM to ARM, using CMake+Ninja, I realized that
> libxml2 depends on lzma, but the dependency is not explicit on the
> build.ninja file under the "build bin/c-index-test"'s LINK_LIBRARIES (which
> is the only one that cares about it).
>
> I couldn't find the place to add -llzma into the deps, and the only mention
> of libxml2 is in config-ix.cmake:
>
> find_package(LibXml2)
> if (LIBXML2_FOUND)
>   set(CLANG_HAVE_LIBXML 1)
> endif ()
>
> Which I could do the same with lzma? Any ideas on what the problem is, and
> possibly how to fix it?

A quick and dirty fix is to change this on
clang/tools/c-index-test/CMakeLists.txt:

  target_link_libraries(c-index-test ${LIBXML2_LIBRARIES} lzma)

That affects that instance only (maybe it is the only one.) And if you
pretend to install that change, first check that XML2 always requires
lzma (to not break the build on systems where it doesn't and libzma is
absent.)

A more robust fix shall work on llvm/cmake/config-ix.cmake: when XML2 is
detected, add lzma as a dependency. This has the some caveat mentioned
on the previous paragraph.

Finally, the real fix shall be implemented on FindLibXml2.cmake, which
belongs to the CMake project. It should take care of declaring that xml2
libraries depend on lzma, but apparently it doesn't.

> PS: The work around is to edit the build.ninja file manually after CMake
> runs, but that's sub-optimal.

Not sub-optimal, but `gross' :-)




More information about the llvm-dev mailing list