Cannot find another SSL package after switching root directory
If you need to find multiple, varying SSL installations you will run into errors. Using cmake -G "Visual Studio 15 2017 Win64"
on Windows 10.
set(OPENSSL_ROOT_DIR "C:\\OpenSSL-Win64")
find_package(OpenSSL 1.1.0 REQUIRED EXACT)
# do something with the obtained information
set(OPENSSL_ROOT_DIR "C:\\OpenSSL-Win64-1.0.2")
find_package(OpenSSL 1.0.2 REQUIRED EXACT)
# to something with the obtained information
The expected behavior is that upon the second call, it will find the OpenSSL library/headers in the root directory you have specified. Instead you'll probably get something like this.
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
system variable OPENSSL_ROOT_DIR: Found unsuitable version "1.1.0j", but
required is exact version "1.0.2" (found
optimized;C:/OpenSSL-Win64/lib/VC/libcrypto64MD.lib;debug;C:/OpenSSL-Win64/lib/VC/libcrypto64MDd.lib)
This seems to be due to caching and can be resolved by calling unset(CACHE)
on a number of SSL related variables for your platform. This is rather unintuitive and highly dependent on the current implementation of the FindOpenSSL module.
Would it be reasonable to bust this cache on new calls to find_package
?