FindOpenSSL: fails to find 3rd-party openssl
Hello, I have a 3rd-party non-standard openssl lib that I need to build with my software (RHEL 7.3). The structure of openssl is:
openssl
includes
lib
linux
release
I set the following environment variables
OPENSSL_ROOT_DIR=openssl
OPENSSL_INCLUDE_DIR=openssl/include
OPENSSL_LIBRARIES=openssl/Linux/release64/
I failed with the following error:
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES) (found
version "1.0.0")
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
cmake/FindOpenSSL.cmake:339 (find_package_handle_standard_args)
cmake/FindFeature.cmake:16 (find_package)
CMakeLists.txt:853 (find_feature)
After a small investigation I found that the code:
FIND_LIBRARY(OPENSSL_SSL_LIBRARY
NAMES
ssl
ssleay32
"ssleay32${MSVC_RUNTIME_SUFFIX}"
HINTS
${_OPENSSL_LIBDIR}
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
)
failed to find the openssl lib because of _OPENSSL_ROOT_HINTS_AND_PATHS doesn't point to the folder with lib (openssl/lib/linux/release)
This is because of code:
SET(_OPENSSL_ROOT_HINTS
$ENV{OPENSSL_ROOT_DIR}
${OPENSSL_ROOT_DIR}
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
)
_OPENSSL_ROOT_HINTS point to the OPENSSL_ROOT_DIR, not to the OPENSSL_LIBRARIES! Why it supposed to binary library files are located in the OPENSSL_ROOT_DIR? Whey'll be located at OPENSSL_LIBRARIES. From my point of view the OPENSSL_LIBRARIES shopuld be included to the _OPENSSL_ROOT_HINTS
Edited by Brad King