@@ -41,7 +41,14 @@ add_library (https-common STATIC
4141 common/HTTPRequest.cpp
4242 common/HTTPSClient.cpp
4343 common/PlaintextConnection.cpp
44- common/LibraryLoader.cpp
44+ )
45+
46+ add_library (https-windows-libraryloader STATIC EXCLUDE_FROM_ALL
47+ windows/WindowsLibraryLoader.cpp
48+ )
49+
50+ add_library (https-unix-libraryloader STATIC EXCLUDE_FROM_ALL
51+ generic/UnixLibraryLoader.cpp
4552)
4653
4754add_library (https-curl STATIC EXCLUDE_FROM_ALL
@@ -69,6 +76,8 @@ add_library (https-wininet STATIC EXCLUDE_FROM_ALL
6976)
7077
7178### Flags
79+ set (LIBRARY_LOADER_DEFAULT "unix" )
80+
7281if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
7382 option (USE_CURL_BACKEND "Use the libcurl backend" ON )
7483 option (USE_OPENSSL_BACKEND "Use the openssl backend" ON )
@@ -93,6 +102,8 @@ elseif (WIN32)
93102
94103 option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" ON )
95104
105+ set (LIBRARY_LOADER_DEFAULT "windows" )
106+
96107 # Windows needs to link with Lua libraries
97108 target_link_libraries (https ${LUA_LIBRARIES} )
98109elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
@@ -125,6 +136,8 @@ elseif (ANDROID)
125136 target_link_libraries (https ${LUA_LIBRARIES} )
126137endif ()
127138option (DEBUG_SCHANNEL "Enable debug output in schannel backend" OFF )
139+ set (LIBRARY_LOADER ${LIBRARY_LOADER_DEFAULT} CACHE STRING "Which method to use to dynamically load libraries" )
140+ set_property (CACHE LIBRARY_LOADER PROPERTY STRINGS "unix;windows" )
128141
129142set_target_properties (https PROPERTIES PREFIX "" )
130143
@@ -176,6 +189,16 @@ if (USE_WINSOCK)
176189 set (HTTPS_USE_WINSOCK ON )
177190endif ()
178191
192+ if ("${LIBRARY_LOADER} " STREQUAL "unix" )
193+ set (HTTPS_LIBRARY_LOADER_UNIX ON )
194+ target_link_libraries (https https-unix-libraryloader )
195+ elseif ("${LIBRARY_LOADER} " STREQUAL "windows" )
196+ set (HTTPS_LIBRARY_LOADER_WINDOWS ON )
197+ target_link_libraries (https https-windows-libraryloader )
198+ else ()
199+ message (WARNING "No library loader selected, backends that depend on dynamic loading will be broken" )
200+ endif ()
201+
179202### Generate config-generated.h
180203add_compile_definitions (HTTPS_HAVE_CONFIG_GENERATED_H )
181204configure_file (
0 commit comments