FindOpenSSL does not find lib64 libraries in custom prefix on Ubuntu
When user wants to build against custom openssl-3.0 (or openssl git master) installation and set -DOPENSSL_ROOT_DIR=
pointing to the custom openssl installation root (prefix), on x86_64 platform — FindOpenSSL
unable to detect this installation correctly (and finds system libraries instead), because it considers only lib
dir in find_library
, but not lib64
. (That's how I understood it).
Tested on cmake 3.20.2 (built from git) on Ubuntu 18.04.
For example, person builds gost-engine while previously installed openssl-3 into /opt/openssl-gost
.
root@bionic:/opt/openssl/gost-engines/build# rm CMakeCache.txt; strace -f -o a cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/opt/openssl-gost -DOPENSSL_ENGINES_DIR=/opt/openssl-gost/lib64/engines-3 -DOPENSSL_LIBRARIES=/opt/openssl-gost/lib64 ..
...
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found suitable version "3.1.0", minimum required is "3.0")
-- Found OpenSSL application: /opt/openssl-gost/bin/openssl
This is incorrect library. strace
shows it considers only lib
and not lib64
:
root@bionic:/opt/openssl/gost-engines/build# grep /opt/openssl-gost/lib a
27574 stat("/opt/openssl-gost/lib", 0x7ffe0d828770) = -1 ENOENT (No such file or directory)
27574 openat(AT_FDCWD, "/opt/openssl-gost/lib", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
27574 stat("/opt/openssl-gost/lib", 0x7ffe0d828770) = -1 ENOENT (No such file or directory)
27574 stat("/opt/openssl-gost/lib", 0x7ffe0d828770) = -1 ENOENT (No such file or directory)
27574 stat("/opt/openssl-gost/lib", 0x7ffe0d828770) = -1 ENOENT (No such file or directory)
Even if I pass -DFIND_LIBRARY_USE_LIB64_PATHS=1
it does not start to look into lib64
.
Passing -DCMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX=64
helps to find correct library:
root@bionic:/opt/openssl/gost-engines/build# rm CMakeCache.txt; strace -f -o a cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/opt/openssl-gost -DOPENSSL_ENGINES_DIR=/opt/openssl-gost/lib64/engines-3 -DOPENSSL_LIBRARIES=/opt/openssl-gost/lib64 -DCMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX=64 ..
...
-- Found OpenSSL: /opt/openssl-gost/lib64/libcrypto.so (found suitable version "3.1.0", minimum required is "3.0")
-- Found OpenSSL application: /opt/openssl-gost/bin/openssl
...