find_library behaviour not as documented (tried v 2.8.12.2, 3.3.0, 3.9.0)
centos 6.5 x86_64
cmake locally built 3.3.0, 3.9.0, pre-installed 2.8.12.2
docs checked for 3.0.2 and 3.9
docs from 3.9 state
"If the FIND_LIBRARY_USE_LIB64_PATHS global property is set all search paths will be tested as normal, with 64/ appended, and with all matches of lib/ replaced with lib64/. This property is automatically set for the platforms that are known to need it if at least one of the languages supported by the project() command is enabled."
My reading of the documentation indicates is that if the conditions are met (property set, language 32-/64-bit dependent enabled (whether by default or explicit project)), lib64/ would be searched rather than lib/.
Contrary to that documentation, the 32bit library is found instead of the 64bit version of the library, even though the property is set, and c and cxx languages are enabled. (Variations with an explicit PROJECT(test64bit) command present have been tried and the results are the same.)
Similar failure has been observed in all 3 of the tried versions.
See the following
library installation info,
script content from a CMakeLists.txt file
the output from that script
showing in output of BZIP2_LIBRARIES that the 32bit library (/lib/libbz2...) is found, not the 64bit (/lib64/libbz2...) version as expected from the above description.
**LOCAL LIBRARY FILE INFORMATION**
[user1@localhost build]$ file /lib/libbz2*
/lib/libbz2.so.1: symbolic link to `libbz2.so.1.0.4'
/lib/libbz2.so.1.0.4: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped
[user1@localhost build]$ file /lib64/libbz2*
/lib64/libbz2.so.1: symbolic link to `libbz2.so.1.0.4'
/lib64/libbz2.so.1.0.4: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped
**SCRIPT CODE FROM CMakeLists.txt**
#property(test64bit)
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
message("languages: ${languages}")
get_property(uselib64paths GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
message("FIND_LIBRARY_USE_LIB64_PATHS: ${uselib64paths}")
MESSAGE("CMAKE_SIZEOF_VOID_P is ${CMAKE_SIZEOF_VOID_P}")
# Find the bzip2 library because it is required on some systems
FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2)
if(NOT BZIP2_LIBRARIES)
# Do an other trial
message("FIND_LIBRARY() failed (${BZIP2_LIBRARIES}), trying FIND_FILE() fallback")
FIND_FILE(BZIP2_LIBRARIES NAMES libbz2.so.1 PATHS /lib)
endif()
MESSAGE("BZIP2_LIBRARIES = ${BZIP2_LIBRARIES}")
**RESULTING OUTPUT** when running cmake <path> -Wno-dev
-- The CXX compiler identification is GNU 5.3.1
-- Check for working CXX compiler: /opt/rh/devtoolset-4/root/usr/bin/c++
-- Check for working CXX compiler: /opt/rh/devtoolset-4/root/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
languages: CXX
FIND_LIBRARY_USE_LIB64_PATHS: TRUE
CMAKE_SIZEOF_VOID_P is 8
FIND_LIBRARY() failed (BZIP2_LIBRARIES-NOTFOUND), trying FIND_FILE() fallback
BZIP2_LIBRARIES = /lib/libbz2.so.1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user1/kitwarework/bldfletch/Erel-devtoolset-4/dlhjunk/cmaketestdefaultfindlib64paths/build
background
Issue originally encountered working with fletch project, and its building of OpenCV when FFMPEG was also being built.
related post elsewhere...
https://stackoverflow.com/questions/36044132/why-is-cmake-finding-32-bit-libraries-instead-of-64-bit-libs-on-a-64-bit-system