CMakeLists.txt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. list(APPEND EXAMPLES
  2. hmain_test
  3. hloop_test
  4. htimer_test
  5. nc
  6. nmap
  7. tcp_echo_server
  8. tcp_chat_server
  9. tcp_proxy_server
  10. udp_echo_server
  11. udp_proxy_server
  12. )
  13. include_directories(.. ../base ../utils ../event ../evpp)
  14. add_executable(hmain_test hmain_test.cpp)
  15. target_link_libraries(hmain_test hv)
  16. add_executable(hloop_test hloop_test.c)
  17. target_link_libraries(hloop_test hv)
  18. add_executable(htimer_test htimer_test.c)
  19. target_link_libraries(htimer_test hv)
  20. add_executable(nc nc.c)
  21. target_link_libraries(nc hv)
  22. add_executable(nmap nmap.cpp)
  23. target_compile_definitions(nmap PRIVATE -DPRINT_DEBUG)
  24. target_link_libraries(nmap hv)
  25. add_executable(tcp_echo_server tcp_echo_server.c)
  26. target_link_libraries(tcp_echo_server hv)
  27. add_executable(tcp_chat_server tcp_chat_server.c)
  28. target_link_libraries(tcp_chat_server hv)
  29. add_executable(tcp_proxy_server tcp_proxy_server.c)
  30. target_link_libraries(tcp_proxy_server hv)
  31. add_executable(udp_echo_server udp_echo_server.c)
  32. target_link_libraries(udp_echo_server hv)
  33. add_executable(udp_proxy_server udp_proxy_server.c)
  34. target_link_libraries(udp_proxy_server hv)
  35. if(WITH_HTTP)
  36. include_directories(../http)
  37. if(WITH_HTTP_SERVER)
  38. include_directories(../http/server)
  39. # httpd
  40. aux_source_directory(httpd HTTPD_SRCS)
  41. add_executable(httpd ${HTTPD_SRCS})
  42. target_link_libraries(httpd hv)
  43. # http_server_test
  44. add_executable(http_server_test http_server_test.cpp)
  45. target_link_libraries(http_server_test hv)
  46. # websocket_server_test
  47. add_executable(websocket_server_test websocket_server_test.cpp)
  48. target_link_libraries(websocket_server_test hv)
  49. list(APPEND EXAMPLES httpd http_server_test websocket_server_test)
  50. endif()
  51. if(WITH_HTTP_CLIENT)
  52. include_directories(../http/client)
  53. # curl
  54. set(CURL_TARGET_NAME curl)
  55. if(WITH_CURL)
  56. set(CURL_TARGET_NAME hv_curl)
  57. endif()
  58. add_executable(${CURL_TARGET_NAME} curl.cpp)
  59. if(WITH_CURL)
  60. set_target_properties(${CURL_TARGET_NAME} PROPERTIES OUTPUT_NAME curl)
  61. endif()
  62. target_link_libraries(${CURL_TARGET_NAME} hv)
  63. # wget
  64. add_executable(wget wget.cpp)
  65. target_link_libraries(wget hv)
  66. # http_client_test
  67. add_executable(http_client_test http_client_test.cpp)
  68. target_link_libraries(http_client_test hv)
  69. # websocket_client_test
  70. add_executable(websocket_client_test websocket_client_test.cpp)
  71. target_link_libraries(websocket_client_test hv)
  72. list(APPEND EXAMPLES ${CURL_TARGET_NAME} wget http_client_test websocket_client_test)
  73. endif()
  74. if(WITH_CONSUL)
  75. include_directories(../consul)
  76. add_executable(consul_cli consul_cli.cpp)
  77. target_compile_definitions(consul_cli PRIVATE PRINT_DEBUG)
  78. target_link_libraries(consul_cli hv)
  79. list(APPEND EXAMPLES consul_cli)
  80. endif()
  81. endif()
  82. add_custom_target(examples DEPENDS ${EXAMPLES})