CMakeLists.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. cmake_minimum_required (VERSION 3.0)
  2. ### Basic compilation settings
  3. set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
  4. add_definitions (-DNOMINMAX)
  5. include_directories (
  6. ${CMAKE_CURRENT_SOURCE_DIR}
  7. ${CMAKE_CURRENT_BINARY_DIR}
  8. )
  9. ### Compiler-specific flags
  10. if (MSVC)
  11. set (DLLEXPORT "__declspec(dllexport)")
  12. elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
  13. set (DLLEXPORT "__attribute__((visibility(\"default\")))")
  14. add_compile_options ("-fvisibility=hidden")
  15. add_link_options ("-fvisibility=hidden")
  16. endif ()
  17. ### "Libraries"
  18. add_library (https MODULE
  19. lua/main.cpp
  20. )
  21. add_library (https-common STATIC
  22. common/HTTPRequest.cpp
  23. common/HTTPSClient.cpp
  24. common/PlaintextConnection.cpp
  25. )
  26. add_library (https-curl STATIC EXCLUDE_FROM_ALL
  27. generic/CurlClient.cpp
  28. )
  29. add_library (https-openssl STATIC EXCLUDE_FROM_ALL
  30. generic/OpenSSLConnection.cpp
  31. )
  32. add_library (https-schannel STATIC EXCLUDE_FROM_ALL
  33. windows/SChannelConnection.cpp
  34. )
  35. add_library (https-nsurl STATIC EXCLUDE_FROM_ALL
  36. macos/NSURLClient.mm
  37. )
  38. ### Flags
  39. if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
  40. option (USE_CURL_BACKEND "Use the libcurl backend" ON)
  41. option (USE_OPENSSL_BACKEND "Use the openssl backend" ON)
  42. option (USE_SCHANNEL_BACKEND "Use the schannel backend (windows-only)" OFF)
  43. option (USE_NSURL_BACKEND "Use the NSUrl backend (macos-only)" OFF)
  44. option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" OFF)
  45. elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
  46. option (USE_CURL_BACKEND "Use the libcurl backend" OFF)
  47. option (USE_OPENSSL_BACKEND "Use the openssl backend" OFF)
  48. option (USE_SCHANNEL_BACKEND "Use the schannel backend (windows-only)" ON)
  49. option (USE_NSURL_BACKEND "Use the NSUrl backend (macos-only)" OFF)
  50. option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" ON)
  51. elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
  52. option (USE_CURL_BACKEND "Use the libcurl backend" OFF)
  53. option (USE_OPENSSL_BACKEND "Use the openssl backend" OFF)
  54. option (USE_SCHANNEL_BACKEND "Use the schannel backend (windows-only)" OFF)
  55. option (USE_NSURL_BACKEND "Use the NSUrl backend (macos-only)" ON)
  56. option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" OFF)
  57. endif ()
  58. option (DEBUG_SCHANNEL "Enable debug output in schannel backend" OFF)
  59. set_target_properties(https PROPERTIES PREFIX "")
  60. ### Dependencies
  61. target_link_libraries (https https-common)
  62. find_package (Lua 5.1 REQUIRED)
  63. include_directories (${LUA_INCLUDE_DIR})
  64. target_link_libraries (https ${LUA_LIBRARIES})
  65. if (USE_CURL_BACKEND)
  66. find_package (CURL REQUIRED)
  67. include_directories (${CURL_INCLUDE_DIR})
  68. target_link_libraries (https https-curl ${CURL_LIBRARIES})
  69. endif ()
  70. if (USE_OPENSSL_BACKEND)
  71. find_package (OpenSSL REQUIRED)
  72. include_directories (${OPENSSL_INCLUDE_DIR})
  73. target_link_libraries (https https-openssl ${OPENSSL_LIBRARIES})
  74. endif ()
  75. if (USE_SCHANNEL_BACKEND)
  76. target_link_libraries (https https-schannel ws2_32 secur32)
  77. endif ()
  78. if (USE_NSURL_BACKEND)
  79. target_link_libraries (https "-framework Foundation")
  80. target_link_libraries (https https-nsurl)
  81. endif ()
  82. ### Generate config.h
  83. configure_file (
  84. common/config.h.in
  85. common/config.h
  86. )