Skip to content

Commit

Permalink
add static linking option to cmakelists
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerZhongAWS committed Sep 12, 2024
1 parent 1c588c7 commit 248936f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ jobs:
run: |
mkdir build
cd build
cmake -DBUILD_TESTS=OFF -DBOOST_PKG_VERSION=1.84.0 -DWIN32_WINNT=0x0601 -DBoost_USE_STATIC_LIBS=ON -DCMAKE_PREFIX_PATH="C:\Boost;C:\Program Files (x86)\Catch2;C:\Program Files (x86)\protobuf;C:\Program Files\OpenSSL" -G "Visual Studio 16 2019" -A x64 ..\
cmake -DBUILD_TESTS=OFF -DLINK_STATIC_OPENSSL=OFF -DBOOST_PKG_VERSION=1.84.0 -DWIN32_WINNT=0x0601 -DBoost_USE_STATIC_LIBS=ON -DCMAKE_PREFIX_PATH="C:\Boost;C:\Program Files (x86)\Catch2;C:\Program Files (x86)\protobuf;C:\Program Files\OpenSSL" -G "Visual Studio 16 2019" -A x64 ..\
msbuild localproxy.vcxproj -p:Configuration=Release
- name: Upload Artifact
uses: actions/upload-artifact@v3
Expand Down
23 changes: 16 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ set(AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME localproxy)
set(AWS_TUNNEL_LOCAL_PROXY_LIB_NAME lproxy)
project(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} CXX)

option(BUILD_TESTS "Build tests" ON)
option(BUILD_TESTS "Build tests" OFF)
option(LINK_STATIC_OPENSSL "Use static openssl libs" ON)
if(BUILD_TESTS)
set(AWS_TUNNEL_LOCAL_PROXY_TEST_NAME localproxytest)
project(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} CXX)
Expand Down Expand Up @@ -115,9 +116,13 @@ endif()
include_directories(${PROJECT_SOURCE_DIR}/src)

target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} ${CMAKE_THREAD_LIBS_INIT})
# target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} OpenSSL::SSL)
# target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} OpenSSL::Crypto)
### uncomment above 2 lines and remove below 2 lines to link against OpenSSL shared libs
if(LINK_STATIC_OPENSSL)
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})
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})
Expand All @@ -127,9 +132,13 @@ set_property(TARGET ${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} APPEND_STRING PROPERTY

if(BUILD_TESTS)
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${CMAKE_THREAD_LIBS_INIT})
# target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} OpenSSL::SSL)
# target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} OpenSSL::Crypto)
### uncomment above 2 lines and remove below 2 lines to link against OpenSSL shared libs
if(LINK_STATIC_OPENSSL)
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})
else()
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})
Expand Down
6 changes: 3 additions & 3 deletions src/TcpAdapterProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@ namespace aws { namespace iot { namespace securedtunneling {
string endpoint = tac.adapter_config.serviceId_to_endpoint_map[service_id];
BOOST_LOG_SEV(log, error) << (boost::format("Could not resolve endpoint %1%. Error message: %2%") % endpoint % ec.message()).str();
basic_retry_execute(log, retry_config,
[this, &tac, service_id, connection_id]()
[this, &tac, service_id]()
{
BOOST_LOG_SEV(log, trace) << "resetting stream for service id:" << service_id << ", then listen for stream start";
async_send_stream_reset(tac, service_id);
Expand All @@ -2122,7 +2122,7 @@ namespace aws { namespace iot { namespace securedtunneling {
{
BOOST_LOG_SEV(log, error) << (boost::format("Could not connect to destination %1%:%2% -- %3%") % dst_host % dst_port % ec.message()).str();
basic_retry_execute(log, retry_config,
[this, &tac, service_id, connection_id]()
[this, &tac, service_id]()
{
BOOST_LOG_SEV(log, trace) << "resetting stream for service id:" << service_id << ", then listen for stream start";
async_send_stream_reset(tac, service_id);
Expand Down Expand Up @@ -2183,7 +2183,7 @@ namespace aws { namespace iot { namespace securedtunneling {
{
BOOST_LOG_SEV(log, error) << (boost::format("Could not resolve bind address: %1% -- %2%") % tac.adapter_config.bind_address.get() % ec.message()).str();
basic_retry_execute(log, retry_config,
[this, &tac, service_id, connection_id]()
[this, &tac, service_id]()
{
BOOST_LOG_SEV(log, trace) << "resetting stream for service id:" << service_id << ", then listen for stream start";
async_send_stream_reset(tac, service_id);
Expand Down

0 comments on commit 248936f

Please sign in to comment.