1
0

CMakeLists.txt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. list(APPEND EXAMPLES
  2. hloop_test
  3. htimer_test
  4. pipe_test
  5. nc
  6. tinyhttpd
  7. tinyproxyd
  8. tcp_client_test
  9. tcp_echo_server
  10. tcp_chat_server
  11. tcp_proxy_server
  12. udp_echo_server
  13. udp_proxy_server
  14. socks5_proxy_server
  15. jsonrpc_client
  16. jsonrpc_server
  17. )
  18. include_directories(.. ../base ../ssl ../event ../util)
  19. add_executable(hloop_test hloop_test.c)
  20. target_link_libraries(hloop_test ${HV_LIBRARIES})
  21. add_executable(htimer_test htimer_test.c)
  22. target_link_libraries(htimer_test ${HV_LIBRARIES})
  23. add_executable(pipe_test pipe_test.c)
  24. target_link_libraries(pipe_test ${HV_LIBRARIES})
  25. add_executable(nc nc.c)
  26. target_link_libraries(nc ${HV_LIBRARIES})
  27. add_executable(tinyhttpd tinyhttpd.c)
  28. target_link_libraries(tinyhttpd ${HV_LIBRARIES})
  29. add_executable(tinyproxyd tinyproxyd.c)
  30. target_link_libraries(tinyproxyd ${HV_LIBRARIES})
  31. add_executable(tcp_client_test tcp_client_test.c)
  32. target_link_libraries(tcp_client_test ${HV_LIBRARIES})
  33. add_executable(tcp_echo_server tcp_echo_server.c)
  34. target_link_libraries(tcp_echo_server ${HV_LIBRARIES})
  35. add_executable(tcp_chat_server tcp_chat_server.c)
  36. target_link_libraries(tcp_chat_server ${HV_LIBRARIES})
  37. add_executable(tcp_proxy_server tcp_proxy_server.c)
  38. target_link_libraries(tcp_proxy_server ${HV_LIBRARIES})
  39. add_executable(udp_echo_server udp_echo_server.c)
  40. target_link_libraries(udp_echo_server ${HV_LIBRARIES})
  41. add_executable(udp_proxy_server udp_proxy_server.c)
  42. target_link_libraries(udp_proxy_server ${HV_LIBRARIES})
  43. add_executable(socks5_proxy_server socks5_proxy_server.c)
  44. target_link_libraries(socks5_proxy_server ${HV_LIBRARIES})
  45. add_executable(jsonrpc_client jsonrpc/jsonrpc_client.c jsonrpc/cJSON.c)
  46. target_compile_definitions(jsonrpc_client PRIVATE CJSON_HIDE_SYMBOLS)
  47. target_link_libraries(jsonrpc_client ${HV_LIBRARIES})
  48. add_executable(jsonrpc_server jsonrpc/jsonrpc_server.c jsonrpc/cJSON.c)
  49. target_compile_definitions(jsonrpc_server PRIVATE CJSON_HIDE_SYMBOLS)
  50. target_link_libraries(jsonrpc_server ${HV_LIBRARIES})
  51. if(WITH_KCP)
  52. glob_headers_and_sources(KCPTUN_SMUX_FILES kcptun/smux)
  53. glob_headers_and_sources(KCPTUN_CLIENT_FILES kcptun/client)
  54. glob_headers_and_sources(KCPTUN_SERVER_FILES kcptun/server)
  55. # kcptun_client
  56. add_executable(kcptun_client ${KCPTUN_SMUX_FILES} ${KCPTUN_CLIENT_FILES})
  57. target_link_libraries(kcptun_client ${HV_LIBRARIES})
  58. # kcptun_server
  59. add_executable(kcptun_server ${KCPTUN_SMUX_FILES} ${KCPTUN_SERVER_FILES})
  60. target_link_libraries(kcptun_server ${HV_LIBRARIES})
  61. list(APPEND EXAMPLES kcptun_client kcptun_server)
  62. endif()
  63. if(WITH_EVPP)
  64. include_directories(../cpputil ../evpp)
  65. # hmain_test
  66. add_executable(hmain_test hmain_test.cpp)
  67. target_link_libraries(hmain_test ${HV_LIBRARIES})
  68. # nmap
  69. glob_headers_and_sources(NMAP_FILES nmap)
  70. add_executable(nmap ${NMAP_FILES})
  71. target_compile_definitions(nmap PRIVATE PRINT_DEBUG)
  72. target_link_libraries(nmap ${HV_LIBRARIES})
  73. list(APPEND EXAMPLES hmain_test nmap)
  74. if(WITH_HTTP)
  75. include_directories(../http)
  76. # wrk
  77. add_executable(wrk wrk.cpp)
  78. target_link_libraries(wrk ${HV_LIBRARIES})
  79. list(APPEND EXAMPLES wrk)
  80. if(WITH_HTTP_SERVER)
  81. include_directories(../http/server)
  82. # http_server_test
  83. add_executable(http_server_test http_server_test.cpp)
  84. target_link_libraries(http_server_test ${HV_LIBRARIES})
  85. # websocket_server_test
  86. add_executable(websocket_server_test websocket_server_test.cpp)
  87. target_link_libraries(websocket_server_test ${HV_LIBRARIES})
  88. list(APPEND EXAMPLES http_server_test websocket_server_test)
  89. endif()
  90. if(WITH_HTTP_CLIENT)
  91. include_directories(../http/client)
  92. # curl
  93. set(CURL_TARGET_NAME curl)
  94. if(WITH_CURL)
  95. set(CURL_TARGET_NAME hv_curl)
  96. endif()
  97. add_executable(${CURL_TARGET_NAME} curl.cpp)
  98. if(WITH_CURL)
  99. set_target_properties(${CURL_TARGET_NAME} PROPERTIES OUTPUT_NAME curl)
  100. endif()
  101. target_link_libraries(${CURL_TARGET_NAME} ${HV_LIBRARIES})
  102. # wget
  103. add_executable(wget wget.cpp)
  104. target_link_libraries(wget ${HV_LIBRARIES})
  105. # consul
  106. glob_headers_and_sources(CONSUL_FILES consul)
  107. add_executable(consul ${CONSUL_FILES})
  108. target_compile_definitions(consul PRIVATE PRINT_DEBUG)
  109. target_link_libraries(consul ${HV_LIBRARIES})
  110. # http_client_test
  111. add_executable(http_client_test http_client_test.cpp)
  112. target_link_libraries(http_client_test ${HV_LIBRARIES})
  113. # websocket_client_test
  114. add_executable(websocket_client_test websocket_client_test.cpp)
  115. target_link_libraries(websocket_client_test ${HV_LIBRARIES})
  116. list(APPEND EXAMPLES ${CURL_TARGET_NAME} wget consul http_client_test websocket_client_test)
  117. if(WITH_HTTP_SERVER)
  118. # httpd
  119. glob_headers_and_sources(HTTPD_FILES httpd)
  120. add_executable(httpd ${HTTPD_FILES})
  121. target_link_libraries(httpd ${HV_LIBRARIES})
  122. list(APPEND EXAMPLES httpd)
  123. endif()
  124. endif()
  125. endif()
  126. endif()
  127. if(WITH_MQTT)
  128. include_directories(../mqtt)
  129. add_executable(mqtt_sub mqtt/mqtt_sub.c)
  130. target_link_libraries(mqtt_sub ${HV_LIBRARIES})
  131. add_executable(mqtt_pub mqtt/mqtt_pub.c)
  132. target_link_libraries(mqtt_pub ${HV_LIBRARIES})
  133. add_executable(mqtt_client_test mqtt/mqtt_client_test.cpp)
  134. target_link_libraries(mqtt_client_test ${HV_LIBRARIES})
  135. list(APPEND EXAMPLES mqtt_sub mqtt_pub mqtt_client_test)
  136. endif()
  137. add_custom_target(examples DEPENDS ${EXAMPLES})