[CMake] find_package() locating 32bit libs incorrectly
Paul Smith
paul at mad-scientist.net
Sun Jun 11 18:20:30 EDT 2017
Hi all.
I'm trying to build LLVM/Clang locally on my Linux system, but I'm using
a separate set of system headers and libraries. These appear in a
separate sysroot directory, like this:
/sysroot/tools/usr/lib64/...
/sysroot/tools/usr/lib/...
/sysroot/tools/usr/include/...
This is basically an extracted set of Red Hat 6 system libraries, so the
content in usr/lib are 32bit libraries and the content in usr/lib64 are
64bit libraries.
I'm building LLVM/Clang 4.0 and in the Clang CMakeLists.txt file we have
simply:
find_package(LibXml2 2.5.3 QUIET)
There are libxml2.so files in both the 64bit and 32bit lib directories
above as well as the usr/include directory.
I run cmake with -DCMAKE_PREFIX_PATH=/sysroot/tools/usr, and CMake finds
things in my sysroot. However, it uses the *32bit* libraries instead of
the 64bit ones; CMakeCache.txt says:
//Path to a file.
LIBXML2_INCLUDE_DIR:PATH=/sysroot/tools/usr/include/libxml2
//Path to a library.
LIBXML2_LIBRARIES:FILEPATH=/sysroot/tools/usr/lib/libxml2.so
The latter should be finding usr/lib64/libxml2.so instead. Because of
this incorrect behavior the link of Clang fails (because it's a 64bit
executable trying to link a 32bit library).
I'm using a slightly older CMake (3.5.2) but I'd assume find_package()
understands the standard directory structure used by Red Hat.
Is there a way to convince CMake find_package() to look in the right
directory?
More information about the CMake
mailing list