find_library returns /usr/lib rather than /usr/lib64 when /usr/lib is a symlink to /usr/lib64
This is becoming visible as Gentoo is switching away from this /usr/lib symlink layout, and migration reveals wrong paths in cmake-config files.
Here is a CMakeLists.txt
example using cmake's own FindEXPAT.cmake
:
cmake_minimum_required(VERSION 3.10)
project(foo C)
find_package(EXPAT)
get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
message(STATUS "lib64: ${uselib64}")
message(STATUS "expat lib: ${EXPAT_LIBRARIES}")
message(STATUS "64: ${CMAKE_SIZEOF_VOID_P}")
With /usr/lib as symlink:
-- Found EXPAT: /usr/lib/libexpat.so (found version "2.2.7")
-- lib64: TRUE
-- expat lib: /usr/lib/libexpat.so
-- 64: 8
With /usr/lib as a copy of /usr/lib64, just for testing:
-- Found EXPAT: /usr/lib64/libexpat.so (found version "2.2.7")
-- lib64: TRUE
-- expat lib: /usr/lib64/libexpat.so
-- 64: 8