diff --git a/CMakeLists.txt b/CMakeLists.txt index c373746..20ae489 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,11 @@ protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROJECT_SOURCE_DIR}/resources/Mess ######################################### # OpenSSL dependency # ######################################### -set(OPENSSL_USE_STATIC_LIBS TRUE) +if(LINK_STATIC_OPENSSL) + set(OPENSSL_USE_STATIC_LIBS TRUE) +else() + set(OPENSSL_USE_STATIC_LIBS FALSE) +endif() find_package(OpenSSL REQUIRED) if(LINK_STATIC_OPENSSL) @@ -154,8 +158,6 @@ else() target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} OpenSSL::SSL) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} OpenSSL::Crypto) endif() -target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${OpenSSL_STATIC_SSL_LIBRARY}) -target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${OpenSSL_STATIC_CRYPTO_LIBRARY}) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${Boost_STATIC_LIBRARIES}) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${Protobuf_LITE_STATIC_LIBRARY}) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${CMAKE_DL_LIBS}) @@ -170,8 +172,6 @@ if(BUILD_TESTS) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} OpenSSL::SSL) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} OpenSSL::Crypto) endif() - target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${OpenSSL_STATIC_SSL_LIBRARY}) - target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${OpenSSL_STATIC_CRYPTO_LIBRARY}) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${Boost_STATIC_LIBRARIES}) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${Protobuf_LITE_STATIC_LIBRARY}) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${CMAKE_DL_LIBS}) diff --git a/README.md b/README.md index 8175ae4..543f02f 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,21 @@ Source install example: Run the ./Configure command without any arguments to check the available platform configuration options and the documentation here: https://wiki.openssl.org/index.php/Compilation_and_Installation ##### Static vs. Dynamic linking OpenSSL -In the `CMakeLists.txt`, we provide a parameter -DLINK_STATIC_OPENSSL which by default is set to ON. You may link against shared libraries on your system by setting the value to OFF. Choosing to do so is completely optional depending on your own operational requirements. This is following guidance from https://github.com/aws-samples/aws-iot-securetunneling-localproxy/pull/145. +In the `CMakeLists.txt`, we provide a parameter `-DLINK_STATIC_OPENSSL` which by default is set to ON (static linking). You may link against shared libraries on your system by setting the value to OFF: + +**Static OpenSSL (default):** +```bash +cmake ../ +make +``` + +**Dynamic OpenSSL:** +```bash +cmake ../ -DLINK_STATIC_OPENSSL=OFF +make +``` + +Choosing to use dynamic linking is completely optional depending on your own operational requirements. #### 5. Download and install Catch2 test framework