From 605baa13d255a4a02c44f14e0e9f640dbd11b16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Sat, 8 Feb 2025 10:29:31 +0100 Subject: [PATCH 1/2] fix: OpenSSL: Need to add openssl/applink.c to Windows executables using OpenSSL #4864 --- CMakeLists.txt | 10 ++++++++-- Crypto/samples/genrsakey/CMakeLists.txt | 3 +++ Crypto/testsuite/CMakeLists.txt | 3 +++ Crypto/testsuite/src/CryptoTestSuite.cpp | 5 ----- JWT/testsuite/CMakeLists.txt | 3 +++ NetSSL_OpenSSL/samples/HTTPSTimeServer/CMakeLists.txt | 3 +++ NetSSL_OpenSSL/samples/Mail/CMakeLists.txt | 3 +++ NetSSL_OpenSSL/samples/SetSourceIP/CMakeLists.txt | 6 +++--- NetSSL_OpenSSL/samples/TwitterClient/CMakeLists.txt | 3 +++ NetSSL_OpenSSL/samples/download/CMakeLists.txt | 3 +++ NetSSL_OpenSSL/testsuite/CMakeLists.txt | 4 +++- 11 files changed, 35 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c82ae3c82..99add114b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,12 +216,18 @@ option(POCO_UNBUNDLED if(ENABLE_TESTS) include(CTest) enable_testing() - message(STATUS "Building with unittests & samples") + message(STATUS "Building with unit tests") if(ENABLE_TEST_DEPRECATED) add_compile_definitions(POCO_TEST_DEPRECATED) endif() else() - message(STATUS "Building without tests & samples") + message(STATUS "Building without unit tests") +endif() + +if(ENABLE_SAMPLES) + message(STATUS "Building with samples") +else() + message(STATUS "Building without samples") endif() if(ENABLE_FUZZING) diff --git a/Crypto/samples/genrsakey/CMakeLists.txt b/Crypto/samples/genrsakey/CMakeLists.txt index f415fbc18..1cfb3c1f0 100644 --- a/Crypto/samples/genrsakey/CMakeLists.txt +++ b/Crypto/samples/genrsakey/CMakeLists.txt @@ -1,2 +1,5 @@ add_executable(genrsakey src/genrsakey.cpp) target_link_libraries(genrsakey PUBLIC Poco::Crypto Poco::Util Poco::XML) +if(MSVC) + target_link_libraries(genrsakey PRIVATE OpenSSL::applink) +endif() diff --git a/Crypto/testsuite/CMakeLists.txt b/Crypto/testsuite/CMakeLists.txt index 1a25fd3dd..c17f8498a 100644 --- a/Crypto/testsuite/CMakeLists.txt +++ b/Crypto/testsuite/CMakeLists.txt @@ -26,6 +26,9 @@ else() set_tests_properties(Crypto PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) endif() target_link_libraries(Crypto-testrunner PUBLIC Poco::NetSSL Poco::XML CppUnit) +if(MSVC) + target_link_libraries(Crypto-testrunner PRIVATE OpenSSL::applink) +endif() if(UNIX AND NOT ANDROID) target_link_libraries(Crypto-testrunner PUBLIC pthread) endif(UNIX AND NOT ANDROID) diff --git a/Crypto/testsuite/src/CryptoTestSuite.cpp b/Crypto/testsuite/src/CryptoTestSuite.cpp index 3435b3ed5..658dd0e2e 100644 --- a/Crypto/testsuite/src/CryptoTestSuite.cpp +++ b/Crypto/testsuite/src/CryptoTestSuite.cpp @@ -9,11 +9,6 @@ #include "Poco/Platform.h" -// see https://www.openssl.org/docs/faq.html -// and https://github.com/openssl/openssl/blob/master/doc/man3/OPENSSL_Applink.pod -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(OPENSSL_REQUIRE_APPLINK) -#include "openssl/applink.c" -#endif #include "CryptoTestSuite.h" #include "CryptoTest.h" #include "RSATest.h" diff --git a/JWT/testsuite/CMakeLists.txt b/JWT/testsuite/CMakeLists.txt index b8166ed98..cdba4ba20 100644 --- a/JWT/testsuite/CMakeLists.txt +++ b/JWT/testsuite/CMakeLists.txt @@ -26,6 +26,9 @@ else() set_tests_properties(JWT PROPERTIES ENVIRONMENT POCO_BASE=${CMAKE_SOURCE_DIR}) endif() target_link_libraries(JWT-testrunner PUBLIC Poco::JWT Poco::Crypto CppUnit) +if(MSVC) + target_link_libraries(JWT-testrunner PRIVATE OpenSSL::applink) +endif() if(UNIX AND NOT ANDROID) target_link_libraries(JWT-testrunner PUBLIC pthread) endif(UNIX AND NOT ANDROID) diff --git a/NetSSL_OpenSSL/samples/HTTPSTimeServer/CMakeLists.txt b/NetSSL_OpenSSL/samples/HTTPSTimeServer/CMakeLists.txt index c90df616f..e42c03cd0 100644 --- a/NetSSL_OpenSSL/samples/HTTPSTimeServer/CMakeLists.txt +++ b/NetSSL_OpenSSL/samples/HTTPSTimeServer/CMakeLists.txt @@ -1,2 +1,5 @@ add_executable(HTTPSTimeServer src/HTTPSTimeServer.cpp) target_link_libraries(HTTPSTimeServer PUBLIC Poco::NetSSL Poco::Util Poco::XML) +if(MSVC) + target_link_libraries(HTTPSTimeServer PRIVATE OpenSSL::applink) +endif() diff --git a/NetSSL_OpenSSL/samples/Mail/CMakeLists.txt b/NetSSL_OpenSSL/samples/Mail/CMakeLists.txt index 1543875be..b37481863 100644 --- a/NetSSL_OpenSSL/samples/Mail/CMakeLists.txt +++ b/NetSSL_OpenSSL/samples/Mail/CMakeLists.txt @@ -1,2 +1,5 @@ add_executable(Mail-ssl src/Mail.cpp) target_link_libraries(Mail-ssl PUBLIC Poco::NetSSL Poco::Util Poco::XML) +if(MSVC) + target_link_libraries(Mail-ssl PRIVATE OpenSSL::applink) +endif() diff --git a/NetSSL_OpenSSL/samples/SetSourceIP/CMakeLists.txt b/NetSSL_OpenSSL/samples/SetSourceIP/CMakeLists.txt index ae0285b1c..9cafd27d9 100644 --- a/NetSSL_OpenSSL/samples/SetSourceIP/CMakeLists.txt +++ b/NetSSL_OpenSSL/samples/SetSourceIP/CMakeLists.txt @@ -1,5 +1,5 @@ add_executable(SetSourceIP src/SetSourceIP.cpp) target_link_libraries(SetSourceIP PUBLIC Poco::NetSSL Poco::Crypto Poco::Util Poco::Net Poco::XML Poco::Foundation) -# uncomment following line, might solve compiling issues -#set(CMAKE_CXX_STANDARD 11) - +if(MSVC) + target_link_libraries(SetSourceIP PRIVATE OpenSSL::applink) +endif() diff --git a/NetSSL_OpenSSL/samples/TwitterClient/CMakeLists.txt b/NetSSL_OpenSSL/samples/TwitterClient/CMakeLists.txt index 7cfc66f8b..02dd50275 100644 --- a/NetSSL_OpenSSL/samples/TwitterClient/CMakeLists.txt +++ b/NetSSL_OpenSSL/samples/TwitterClient/CMakeLists.txt @@ -3,3 +3,6 @@ add_executable(TwitterCLient src/Twitter.cpp ) target_link_libraries(TwitterCLient PUBLIC Poco::NetSSL Poco::Util Poco::JSON Poco::XML) +if(MSVC) + target_link_libraries(TwitterClient PRIVATE OpenSSL::applink) +endif() \ No newline at end of file diff --git a/NetSSL_OpenSSL/samples/download/CMakeLists.txt b/NetSSL_OpenSSL/samples/download/CMakeLists.txt index a5ce9c081..ed5fd5110 100644 --- a/NetSSL_OpenSSL/samples/download/CMakeLists.txt +++ b/NetSSL_OpenSSL/samples/download/CMakeLists.txt @@ -1,2 +1,5 @@ add_executable(download-ssl src/download.cpp) target_link_libraries(download-ssl PUBLIC Poco::NetSSL Poco::Util Poco::XML) +if(MSVC) + target_link_libraries(download-ssl PRIVATE OpenSSL::applink) +endif() \ No newline at end of file diff --git a/NetSSL_OpenSSL/testsuite/CMakeLists.txt b/NetSSL_OpenSSL/testsuite/CMakeLists.txt index f66372c20..bc6bf722b 100644 --- a/NetSSL_OpenSSL/testsuite/CMakeLists.txt +++ b/NetSSL_OpenSSL/testsuite/CMakeLists.txt @@ -35,7 +35,9 @@ else() ) endif() target_link_libraries(NetSSL-testrunner PUBLIC Poco::NetSSL Poco::Util Poco::XML CppUnit) - +if(MSVC) + target_link_libraries(NetSSL-testrunner PRIVATE OpenSSL::applink) +endif() if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ping/websocket-server.cpp) add_executable(NetSSL-server ping/websocket-server.cpp) From 1319f31e6e18438a70580c922230619c1d8e7c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Sat, 8 Feb 2025 10:45:42 +0100 Subject: [PATCH 2/2] fix(cmake): project name typo --- NetSSL_OpenSSL/samples/TwitterClient/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NetSSL_OpenSSL/samples/TwitterClient/CMakeLists.txt b/NetSSL_OpenSSL/samples/TwitterClient/CMakeLists.txt index 02dd50275..dde7c761a 100644 --- a/NetSSL_OpenSSL/samples/TwitterClient/CMakeLists.txt +++ b/NetSSL_OpenSSL/samples/TwitterClient/CMakeLists.txt @@ -1,8 +1,8 @@ -add_executable(TwitterCLient +add_executable(TwitterClient src/TweetApp.cpp src/Twitter.cpp ) -target_link_libraries(TwitterCLient PUBLIC Poco::NetSSL Poco::Util Poco::JSON Poco::XML) +target_link_libraries(TwitterClient PUBLIC Poco::NetSSL Poco::Util Poco::JSON Poco::XML) if(MSVC) target_link_libraries(TwitterClient PRIVATE OpenSSL::applink) endif() \ No newline at end of file