CMakeLists.txt 4.7 KB

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