Description
Describe the bug
The build fails on CentOS 7/8 with crypto_LIBRARY not found if -DBUILD_SHARED_LIBS=OFF
is passed.
Expected Behavior
The build should use the dynamic version of the OpenSSL library if the static version is not available.
Current Behavior
When defining -DBUILD_SHARED_LIBS=OFF
the build searches for a respective static version of OpenSSL which is not available in some distributions like Redhat/CentOS.
Reproduction Steps
On Redhat 7/8, checkout AWS as usual then issue
cd aws-sdk-cpp
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_ONLY=s3 ..
it should fail with
CMake Error at /usr/local/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find crypto (missing: crypto_LIBRARY)
Possible Solution
A simple solution is just to replace the use of the crypto static library with the shared one if the static is not found.
diff -Naur aws-sdk-cpp/cmake/Findcrypto.cmake aws-sdk-cpp.new/cmake/Findcrypto.cmake
--- aws-sdk-cpp/cmake/Findcrypto.cmake 2022-05-09 19:38:30.000000000 -0500
+++ aws-sdk-cpp.new/cmake/Findcrypto.cmake 2022-05-10 11:02:48.982319574 -0500
@@ -59,7 +59,11 @@
if (BUILD_SHARED_LIBS)
set(crypto_LIBRARY ${crypto_SHARED_LIBRARY})
else()
- set(crypto_LIBRARY ${crypto_STATIC_LIBRARY})
+ if (crypto_STATIC_LIBRARY)
+ set(crypto_LIBRARY ${crypto_STATIC_LIBRARY})
+ else()
+ set(crypto_LIBRARY ${crypto_SHARED_LIBRARY})
+ endif()
endif()
endif()
Additional Information/Context
I am not totally acquainted on why the reason to pick up the static openssl library version when building static but it does sound out of place to me.
AWS CPP SDK version used
1.9.253
Compiler and Version used
gcc (GCC) 9.2.1 20191120 (Red Hat 9.2.1-2)
Operating System and version
CentOS-8 from docker