CMakeLists.txt 3.7 KB

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