CMakeLists.txt 3.6 KB

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