Skip to content

Commit

Permalink
Ensure that OpenSSL is linked against needed Windows libraries.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: d2928c94ebe6565e155f81db8ccc24c4c5d69a54
  • Loading branch information
levlam committed Jul 27, 2020
1 parent c1dd9ec commit ab5d353
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 13 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,13 @@ add_library(tdcore STATIC ${TDLIB_SOURCE})
target_include_directories(tdcore PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${TL_TD_AUTO_INCLUDE_DIR}>)
target_include_directories(tdcore SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(tdcore PUBLIC tdapi tdactor tdutils tdnet tddb PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES})
if (WIN32)
if (MINGW)
target_link_libraries(tdcore PRIVATE ws2_32 mswsock)
else()
target_link_libraries(tdcore PRIVATE ws2_32 Mswsock)
endif()
endif()

if (NOT CMAKE_CROSSCOMPILING)
add_dependencies(tdcore tl_generate_common)
Expand Down
7 changes: 7 additions & 0 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ endif()
#TODO: all benchmarks in one file
add_executable(bench_crypto bench_crypto.cpp)
target_link_libraries(bench_crypto PRIVATE tdutils ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES})
if (WIN32)
if (MINGW)
target_link_libraries(bench_crypto PRIVATE ws2_32 mswsock)
else()
target_link_libraries(bench_crypto PRIVATE ws2_32 Mswsock)
endif()
endif()
target_include_directories(bench_crypto SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})

add_executable(bench_actor bench_actor.cpp)
Expand Down
8 changes: 8 additions & 0 deletions sqlite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ add_library(tdsqlite STATIC ${SQLITE_SOURCE})
target_include_directories(tdsqlite PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_include_directories(tdsqlite SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(tdsqlite PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES})
if (WIN32)
if (MINGW)
target_link_libraries(tdsqlite PRIVATE ws2_32 mswsock)
else()
target_link_libraries(tdsqlite PRIVATE ws2_32 Mswsock)
endif()
endif()

target_compile_definitions(tdsqlite PRIVATE
-DSQLITE_DEFAULT_MEMSTATUS=0
-DSQLITE_OMIT_LOAD_EXTENSION
Expand Down
4 changes: 2 additions & 2 deletions tdnet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ target_link_libraries(tdnet PRIVATE ${OPENSSL_CRYPTO_LIBRARY})

if (WIN32)
if (MINGW)
target_link_libraries(tdnet PRIVATE crypt32)
target_link_libraries(tdnet PRIVATE ws2_32 mswsock crypt32)
else()
target_link_libraries(tdnet PRIVATE Crypt32)
target_link_libraries(tdnet PRIVATE ws2_32 Mswsock Crypt32)
endif()
endif()

Expand Down
24 changes: 13 additions & 11 deletions tdutils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,7 @@ set(TDUTILS_TEST_SOURCE
#RULES
#LIBRARIES
add_library(tdutils STATIC ${TDUTILS_SOURCE})
if (WIN32)
# find_library for system libraries doesn't work for UWP builds
# find_library(WS2_32_LIBRARY ws2_32)
# find_library(MSWSOCK_LIBRARY Mswsock)
# target_link_libraries(tdutils PRIVATE ${WS2_32_LIBRARY} ${MSWSOCK_LIBRARY})
if (MINGW)
target_link_libraries(tdutils PRIVATE ws2_32 mswsock normaliz psapi)
else()
target_link_libraries(tdutils PRIVATE ws2_32 Mswsock Normaliz psapi)
endif()
endif()

if (NOT CMAKE_CROSSCOMPILING AND TDUTILS_MIME_TYPE)
add_dependencies(tdutils tdmime_auto)
endif()
Expand All @@ -337,6 +327,18 @@ if (ABSL_FOUND)
target_link_libraries(tdutils SYSTEM PUBLIC absl::flat_hash_map absl::flat_hash_set absl::hash)
endif()

if (WIN32)
# find_library for system libraries doesn't work for UWP builds
# find_library(WS2_32_LIBRARY ws2_32)
# find_library(MSWSOCK_LIBRARY Mswsock)
# target_link_libraries(tdutils PRIVATE ${WS2_32_LIBRARY} ${MSWSOCK_LIBRARY})
if (MINGW)
target_link_libraries(tdutils PRIVATE ws2_32 mswsock normaliz psapi)
else()
target_link_libraries(tdutils PRIVATE ws2_32 Mswsock Normaliz psapi)
endif()
endif()

if (ANDROID)
target_link_libraries(tdutils PRIVATE log)
endif()
Expand Down

0 comments on commit ab5d353

Please sign in to comment.