123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- cmake_minimum_required (VERSION 3.13)
- ### Basic compilation settings
- set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
- include_directories (
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
- )
- ### Compiler-specific flags
- if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
- add_compile_options ("-fvisibility=hidden")
- add_link_options ("-fvisibility=hidden")
- endif ()
- if (LOVR)
- set(LUA_LIBRARIES ${LOVR_LUA})
- else()
- ### Dependencies
- find_package (LuaJIT)
- if (LUAJIT_FOUND)
- set(LUA_INCLUDE_DIR ${LUAJIT_INCLUDE_DIR})
- set(LUA_LIBRARIES ${LUAJIT_LIBRARY})
- else ()
- find_package (Lua 5.1 REQUIRED)
- endif ()
- include_directories (${LUA_INCLUDE_DIR})
- endif ()
- ### "Libraries"
- add_library (https MODULE
- lua/main.cpp
- )
- add_library (https-common STATIC
- common/HTTPS.cpp
- common/HTTPRequest.cpp
- common/HTTPSClient.cpp
- common/PlaintextConnection.cpp
- common/LibraryLoader.cpp
- )
- add_library (https-curl STATIC EXCLUDE_FROM_ALL
- generic/CurlClient.cpp
- )
- add_library (https-openssl STATIC EXCLUDE_FROM_ALL
- generic/OpenSSLConnection.cpp
- )
- add_library (https-schannel STATIC EXCLUDE_FROM_ALL
- windows/SChannelConnection.cpp
- )
- add_library (https-nsurl STATIC EXCLUDE_FROM_ALL
- apple/NSURLClient.mm
- )
- add_library (https-android STATIC EXCLUDE_FROM_ALL
- android/AndroidClient.cpp
- )
- add_library (https-wininet STATIC EXCLUDE_FROM_ALL
- windows/WinINetClient.cpp
- )
- ### Flags
- if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
- option (USE_CURL_BACKEND "Use the libcurl backend" ON)
- option (USE_OPENSSL_BACKEND "Use the openssl backend" ON)
- option (USE_SCHANNEL_BACKEND "Use the schannel backend (windows-only)" OFF)
- option (USE_NSURL_BACKEND "Use the NSUrl backend (apple-only)" OFF)
- option (USE_ANDROID_BACKEND "Use the Android Java backend (Android-only)" OFF)
- option (USE_WININET_BACKEND "Use the WinINet backend (windows-only)" OFF)
- option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" OFF)
- elseif (WIN32)
- option (USE_CURL_BACKEND "Use the libcurl backend" OFF)
- option (USE_OPENSSL_BACKEND "Use the openssl backend" OFF)
- option (USE_SCHANNEL_BACKEND "Use the schannel backend (windows-only)" ON)
- option (USE_NSURL_BACKEND "Use the NSUrl backend (apple-only)" OFF)
- option (USE_ANDROID_BACKEND "Use the Android Java backend (Android-only)" OFF)
- if (CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
- option (USE_WININET_BACKEND "Use the WinINet backend (windows-only)" OFF)
- else ()
- option (USE_WININET_BACKEND "Use the WinINet backend (windows-only)" ON)
- endif ()
- option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" ON)
- # Windows needs to link with Lua libraries
- target_link_libraries(https ${LUA_LIBRARIES})
- elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
- option (USE_CURL_BACKEND "Use the libcurl backend" OFF)
- option (USE_OPENSSL_BACKEND "Use the openssl backend" OFF)
- option (USE_SCHANNEL_BACKEND "Use the schannel backend (windows-only)" OFF)
- option (USE_NSURL_BACKEND "Use the NSUrl backend (apple-only)" ON)
- option (USE_ANDROID_BACKEND "Use the Android Java backend (Android-only)" OFF)
- option (USE_WININET_BACKEND "Use the WinINet backend (windows-only)" OFF)
- option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" OFF)
- if (NOT IOS)
- # macOS needs -undefined dynamic_lookup
- target_link_options(https PRIVATE -undefined dynamic_lookup)
- else ()
- target_link_libraries(https ${LUA_LIBRARIES})
- endif ()
- elseif (ANDROID)
- option (USE_CURL_BACKEND "Use the libcurl backend" OFF)
- option (USE_OPENSSL_BACKEND "Use the openssl backend" OFF)
- option (USE_SCHANNEL_BACKEND "Use the schannel backend (windows-only)" OFF)
- option (USE_NSURL_BACKEND "Use the NSUrl backend (apple-only)" OFF)
- option (USE_ANDROID_BACKEND "Use the Android Java backend (Android-only)" ON)
- option (USE_WININET_BACKEND "Use the WinINet backend (windows-only)" OFF)
- option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" OFF)
- # Android needs to link with Lua libraries
- target_link_libraries(https ${LUA_LIBRARIES})
- endif ()
- option (DEBUG_SCHANNEL "Enable debug output in schannel backend" OFF)
- set_target_properties(https PROPERTIES PREFIX "")
- target_link_libraries (https https-common)
- if (USE_CURL_BACKEND)
- set(HTTPS_BACKEND_CURL ON)
- find_package (CURL REQUIRED)
- include_directories (${CURL_INCLUDE_DIRS})
- target_link_libraries (https https-curl)
- endif ()
- if (USE_OPENSSL_BACKEND)
- set(HTTPS_BACKEND_OPENSSL ON)
- find_package (OpenSSL REQUIRED)
- include_directories (${OPENSSL_INCLUDE_DIR})
- target_link_libraries (https https-openssl)
- endif ()
- if (USE_SCHANNEL_BACKEND)
- set(HTTPS_BACKEND_SCHANNEL ON)
- target_link_libraries (https https-schannel ws2_32 secur32)
- endif ()
- if (USE_NSURL_BACKEND)
- set(HTTPS_BACKEND_NSURL ON)
- set_target_properties(
- https-nsurl
- PROPERTIES
- MACOSX_BUNDLE YES
- XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
- )
- target_link_libraries (https "-framework Foundation")
- target_link_libraries (https https-nsurl)
- endif ()
- if (USE_ANDROID_BACKEND)
- set(HTTPS_BACKEND_ANDROID ON)
- target_link_libraries (https https-android)
- message(STATUS "Ensure to add the Java files to your project too!")
- endif ()
- if (USE_WININET_BACKEND)
- set(HTTPS_BACKEND_WININET ON)
- target_link_libraries (https https-wininet wininet)
- endif ()
- if (USE_WINSOCK)
- set(HTTPS_USE_WINSOCK ON)
- endif ()
- ### Generate config-generated.h
- add_compile_definitions(HTTPS_HAVE_CONFIG_GENERATED_H)
- configure_file (
- common/config-generated.h.in
- common/config-generated.h
- )
- ### Install target
- install(TARGETS https DESTINATION .)
|