Advertisement
twokay

cmkelists for uwebsockets with openssl

Nov 12th, 2024 (edited)
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 1.78 KB | None | 0 0
  1. #CMakeLists.txt
  2. cmake_minimum_required(VERSION 3.28)
  3. project(entitywind_uwebsockets_test LANGUAGES C CXX)
  4. include(FetchContent)
  5. set(CMAKE_CXX_STANDARD 23)
  6.  
  7. find_package(OpenSSL REQUIRED)
  8.  
  9. if( OPENSSL_FOUND )
  10.     include_directories(${OPENSSL_INCLUDE_DIRS})
  11.     message(STATUS "Using OpenSSL ${OPENSSL_VERSION}")
  12. else()
  13.     # Error; with REQUIRED, pkg_search_module() will throw an error by it's own
  14. endif()
  15.  
  16. FetchContent_Declare(
  17.         uSockets_content
  18.         GIT_REPOSITORY https://github.com/uNetworking/uSockets
  19.         GIT_TAG v0.8.8
  20.         GIT_SHALLOW ON
  21.         GIT_SUBMODULES ""
  22. )
  23. FetchContent_MakeAvailable(uSockets_content)
  24. file(GLOB_RECURSE USOCKETS_SOURCES ${usockets_content_SOURCE_DIR}/src/*.c)
  25. add_library(uSockets SHARED ${USOCKETS_SOURCES})
  26. target_include_directories(uSockets PUBLIC ${usockets_content_SOURCE_DIR}/src ${ZLIB_INCLUDE_DIRS} )
  27. target_compile_definitions(uSockets INTERFACE LIBUS_USE_OPENSSL)
  28. target_link_libraries(uSockets ${ZLIB_LIBRARIES} ssl crypto)
  29.  
  30. FetchContent_Declare(
  31.         uWebSockets_content
  32.         GIT_REPOSITORY https://github.com/uNetworking/uWebSockets
  33.         GIT_TAG v20.70.0
  34.         GIT_SHALLOW ON
  35.         GIT_SUBMODULES ""
  36. )
  37. FetchContent_MakeAvailable(uWebSockets_content)
  38. find_package(ZLIB REQUIRED)
  39. add_library(uWebSockets INTERFACE)
  40. target_include_directories(uWebSockets INTERFACE ${uwebsockets_content_SOURCE_DIR}/src/)
  41. target_link_libraries(uWebSockets INTERFACE uSockets ${ZLIB_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
  42. target_compile_options(uWebSockets INTERFACE -Wno-deprecated-declarations)
  43.  
  44. # Client exec
  45. add_executable(client client_ws.cc)
  46. target_link_libraries(client uWebSockets)
  47.  
  48. # Server exec
  49. add_executable(server server_ws.cc)
  50. target_link_libraries(server uWebSockets  OpenSSL::SSL OpenSSL::Crypto)
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement