Skip to content

Commit

Permalink
FindOpenSSL: Trust the user's OPENSSL_ROOT_DIR
Browse files Browse the repository at this point in the history
When the user has specified the OpenSSL installation root directory,
through the variable OPENSSL_ROOT_DIR or the environment variable with
the same name, trust it, don't try to find OpenSSL anywhere else.

Fixes: #18352
  • Loading branch information
levitte committed May 19, 2023
1 parent 0383bb7 commit 5cc8a69
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions Modules/FindOpenSSL.cmake
Expand Up @@ -230,13 +230,15 @@ else()
set(_OPENSSL_FIND_PATH_SUFFIX "include")
endif()

if (MSVC)
if ((DEFINED OPENSSL_ROOT_DIR) OR (DEFINED ENV{OPENSSL_ROOT_DIR}))
set(_OPENSSL_ROOT_HINTS HINTS ${OPENSSL_ROOT_DIR} ENV OPENSSL_ROOT_DIR)
set(_OPENSSL_ROOT_PATHS NO_DEFAULT_PATH)
elseif (MSVC)
# http://www.slproweb.com/products/Win32OpenSSL.html
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
HINTS
"[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]"
ENV OPENSSL_ROOT_DIR
)

if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
Expand All @@ -255,23 +257,19 @@ if (MSVC)
endif()

set(_OPENSSL_ROOT_PATHS
PATHS
"${_programfiles}/OpenSSL"
"${_programfiles}/OpenSSL-${_arch}"
"C:/OpenSSL/"
"C:/OpenSSL-${_arch}/"
)
unset(_programfiles)
unset(_arch)
else ()
set(_OPENSSL_ROOT_HINTS
${OPENSSL_ROOT_DIR}
ENV OPENSSL_ROOT_DIR
)
endif ()

set(_OPENSSL_ROOT_HINTS_AND_PATHS
HINTS ${_OPENSSL_ROOT_HINTS}
PATHS ${_OPENSSL_ROOT_PATHS}
${_OPENSSL_ROOT_HINTS}
${_OPENSSL_ROOT_PATHS}
)

find_path(OPENSSL_INCLUDE_DIR
Expand Down

0 comments on commit 5cc8a69

Please sign in to comment.