CMakeLists.txt 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #
  2. # libwebsockets - small server side websockets and web server implementation
  3. #
  4. # Copyright (C) 2010 - 2020 Andy Green <[email protected]>
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining a copy
  7. # of this software and associated documentation files (the "Software"), to
  8. # deal in the Software without restriction, including without limitation the
  9. # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  10. # sell copies of the Software, and to permit persons to whom the Software is
  11. # furnished to do so, subject to the following conditions:
  12. #
  13. # The above copyright notice and this permission notice shall be included in
  14. # all copies or substantial portions of the Software.
  15. #
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  22. # IN THE SOFTWARE.
  23. #
  24. include_directories(.)
  25. if (DEFINED LIB_LIST_AT_END)
  26. link_libraries(${LIB_LIST_AT_END})
  27. endif()
  28. if (LWS_WITH_PLUGINS AND LWS_WITH_SHARED)
  29. macro(create_plugin PLUGIN_NAME PLUGIN_INCLUDE MAIN_SRC S2 S3)
  30. set(PLUGIN_SRCS ${MAIN_SRC})
  31. if ("${S2}" STREQUAL "")
  32. else()
  33. list(APPEND PLUGIN_SRCS ${S2})
  34. endif()
  35. if ("${S3}" STREQUAL "")
  36. else()
  37. list(APPEND PLUGIN_SRCS ${S3})
  38. endif()
  39. if (WIN32)
  40. list(APPEND PLUGIN_SRCS
  41. ${WIN32_HELPERS_PATH}/getopt.c
  42. ${WIN32_HELPERS_PATH}/getopt_long.c
  43. ${WIN32_HELPERS_PATH}/gettimeofday.c
  44. )
  45. list(APPEND PLUGIN_HDR
  46. ${WIN32_HELPERS_PATH}/getopt.h
  47. ${WIN32_HELPERS_PATH}/gettimeofday.h
  48. )
  49. endif(WIN32)
  50. source_group("Headers Private" FILES ${PLUGIN_HDR})
  51. source_group("Sources" FILES ${PLUGIN_SRCS})
  52. add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SRCS} ${PLUGIN_HDR})
  53. foreach(libpath ${LWS_DEP_LIB_PATHS})
  54. target_link_directories(${TEST_NAME} ${libpath})
  55. endforeach()
  56. target_link_libraries(${PLUGIN_NAME} websockets_shared)
  57. add_dependencies(${PLUGIN_NAME} websockets_shared)
  58. target_include_directories(${PLUGIN_NAME} PRIVATE ${PLUGIN_INCLUDE} ${LWS_LIB_BUILD_INC_PATHS})
  59. # Set test app specific defines.
  60. set_property(TARGET ${PLUGIN_NAME}
  61. PROPERTY COMPILE_DEFINITIONS
  62. INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/plugins"
  63. )
  64. set(CMAKE_POSITION_INDEPENDENT_CODE ON)
  65. # SET_TARGET_PROPERTIES(${PLUGIN_NAME}
  66. # PROPERTIES COMPILE_FLAGS ${CMAKE_C_FLAGS})
  67. # set_target_properties(${PLUGIN_NAME}
  68. # PROPERTIES
  69. # OUTPUT_NAME ${PLUGIN_NAME})
  70. list(APPEND PLUGINS_LIST ${PLUGIN_NAME})
  71. endmacro()
  72. if (LWS_ROLE_WS)
  73. create_plugin(protocol_dumb_increment ""
  74. "protocol_dumb_increment.c" "" "")
  75. create_plugin(protocol_lws_mirror ""
  76. "protocol_lws_mirror.c" "" "")
  77. create_plugin(protocol_lws_status ""
  78. "protocol_lws_status.c" "" "")
  79. if (NOT WIN32)
  80. create_plugin(protocol_lws_raw_test ""
  81. "protocol_lws_raw_test.c" "" "")
  82. if (UNIX AND LWS_HAVE_PTHREAD_H)
  83. create_plugin(protocol_deaddrop ""
  84. "deaddrop/protocol_lws_deaddrop.c" "" "")
  85. endif()
  86. endif()
  87. if (LWS_WITH_SERVER_STATUS)
  88. create_plugin(protocol_lws_server_status ""
  89. "protocol_lws_server_status.c" "" "")
  90. endif()
  91. if (NOT LWS_WITHOUT_CLIENT)
  92. create_plugin(protocol_client_loopback_test ""
  93. "protocol_client_loopback_test.c" "" "")
  94. endif()
  95. endif(LWS_ROLE_WS)
  96. create_plugin(protocol_post_demo ""
  97. "protocol_post_demo.c" "" "")
  98. if (LWS_ROLE_RAW_PROXY)
  99. create_plugin(protocol_lws_raw_proxy ""
  100. "raw-proxy/protocol_lws_raw_proxy.c" "" "")
  101. endif()
  102. if (LWS_WITH_FTS)
  103. create_plugin(protocol_fulltext_demo ""
  104. "protocol_fulltext_demo.c" "" "")
  105. endif()
  106. if (LWS_WITH_SSL)
  107. create_plugin(protocol_lws_ssh_base "ssh-base/include"
  108. "ssh-base/sshd.c;ssh-base/telnet.c;ssh-base/kex-25519.c" "ssh-base/crypto/chacha.c;ssh-base/crypto/ed25519.c;ssh-base/crypto/fe25519.c;ssh-base/crypto/ge25519.c;ssh-base/crypto/poly1305.c;ssh-base/crypto/sc25519.c;ssh-base/crypto/smult_curve25519_ref.c" "")
  109. create_plugin(protocol_lws_sshd_demo "ssh-base/include" "protocol_lws_sshd_demo.c" "" "")
  110. include_directories("${PROJECT_SOURCE_DIR}/plugins/ssh-base/include")
  111. endif()
  112. if (LWS_WITH_ACME)
  113. create_plugin(protocol_lws_acme_client ""
  114. "acme-client/protocol_lws_acme_client.c" "" "")
  115. endif()
  116. endif(LWS_WITH_PLUGINS AND LWS_WITH_SHARED)
  117. # plugins
  118. if (LWS_WITH_PLUGINS)
  119. install(TARGETS ${PLUGINS_LIST}
  120. PERMISSIONS OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE OWNER_READ GROUP_READ WORLD_READ
  121. DESTINATION share/libwebsockets-test-server/plugins
  122. COMPONENT plugins)
  123. if (NOT WIN32)
  124. install(FILES deaddrop/assets/index.html;deaddrop/assets/deaddrop.js;deaddrop/assets/deaddrop.css;deaddrop/assets/drop.svg
  125. DESTINATION share/libwebsockets-test-server/deaddrop
  126. COMPONENT plugins)
  127. endif()
  128. if (LWS_WITH_SERVER_STATUS)
  129. install(FILES server-status.html;server-status.js;server-status.css;lwsws-logo.png
  130. DESTINATION share/libwebsockets-test-server/server-status
  131. COMPONENT examples)
  132. endif()
  133. endif()