ithewei 4 rokov pred
rodič
commit
523c2a46ef
2 zmenil súbory, kde vykonal 26 pridanie a 20 odobranie
  1. 6 0
      CMakeLists.txt
  2. 20 20
      examples/CMakeLists.txt

+ 6 - 0
CMakeLists.txt

@@ -197,6 +197,12 @@ endif()
 file(INSTALL ${LIBHV_HEADERS} DESTINATION include/hv)
 install(FILES ${LIBHV_HEADERS} DESTINATION include/hv)
 
+if(BUILD_SHARED)
+    set(HV_LIBRARIES hv CACHE INTERNAL "link hv libraries")
+else()
+    set(HV_LIBRARIES hv_static ${LIBS} CACHE INTERNAL "link hv libraries")
+endif()
+
 if(BUILD_EXAMPLES)
     add_subdirectory(examples)
 endif()

+ 20 - 20
examples/CMakeLists.txt

@@ -13,44 +13,44 @@ list(APPEND EXAMPLES
 include_directories(.. ../base ../ssl ../event ../util)
 
 add_executable(hloop_test hloop_test.c)
-target_link_libraries(hloop_test hv)
+target_link_libraries(hloop_test ${HV_LIBRARIES})
 
 add_executable(htimer_test htimer_test.c)
-target_link_libraries(htimer_test hv)
+target_link_libraries(htimer_test ${HV_LIBRARIES})
 
 add_executable(nc nc.c)
-target_link_libraries(nc hv)
+target_link_libraries(nc ${HV_LIBRARIES})
 
 add_executable(tcp_echo_server tcp_echo_server.c)
-target_link_libraries(tcp_echo_server hv)
+target_link_libraries(tcp_echo_server ${HV_LIBRARIES})
 
 add_executable(tcp_chat_server tcp_chat_server.c)
-target_link_libraries(tcp_chat_server hv)
+target_link_libraries(tcp_chat_server ${HV_LIBRARIES})
 
 add_executable(tcp_proxy_server tcp_proxy_server.c)
-target_link_libraries(tcp_proxy_server hv)
+target_link_libraries(tcp_proxy_server ${HV_LIBRARIES})
 
 add_executable(udp_echo_server udp_echo_server.c)
-target_link_libraries(udp_echo_server hv)
+target_link_libraries(udp_echo_server ${HV_LIBRARIES})
 
 add_executable(udp_proxy_server udp_proxy_server.c)
-target_link_libraries(udp_proxy_server hv)
+target_link_libraries(udp_proxy_server ${HV_LIBRARIES})
 
 add_executable(jsonrpc_client jsonrpc/jsonrpc_client.c jsonrpc/jsonrpc.c jsonrpc/cJSON.c)
-target_link_libraries(jsonrpc_client hv)
+target_link_libraries(jsonrpc_client ${HV_LIBRARIES})
 
 add_executable(jsonrpc_server jsonrpc/jsonrpc_server.c jsonrpc/jsonrpc.c jsonrpc/cJSON.c)
-target_link_libraries(jsonrpc_server hv)
+target_link_libraries(jsonrpc_server ${HV_LIBRARIES})
 
 if(WITH_EVPP)
     include_directories(../cpputil ../evpp)
     add_executable(hmain_test hmain_test.cpp)
-    target_link_libraries(hmain_test hv)
+    target_link_libraries(hmain_test ${HV_LIBRARIES})
 
     aux_source_directory(nmap NMAP_SRCS)
     add_executable(nmap ${NMAP_SRCS})
     target_compile_definitions(nmap PRIVATE PRINT_DEBUG)
-    target_link_libraries(nmap hv)
+    target_link_libraries(nmap ${HV_LIBRARIES})
 
     list(APPEND EXAMPLES hmain_test nmap)
 if(WITH_HTTP)
@@ -60,11 +60,11 @@ if(WITH_HTTP_SERVER)
 
     # http_server_test
     add_executable(http_server_test http_server_test.cpp)
-    target_link_libraries(http_server_test hv)
+    target_link_libraries(http_server_test ${HV_LIBRARIES})
 
     # websocket_server_test
     add_executable(websocket_server_test websocket_server_test.cpp)
-    target_link_libraries(websocket_server_test hv)
+    target_link_libraries(websocket_server_test ${HV_LIBRARIES})
 
     list(APPEND EXAMPLES http_server_test websocket_server_test)
 endif()
@@ -81,25 +81,25 @@ if(WITH_HTTP_CLIENT)
     if(WITH_CURL)
         set_target_properties(${CURL_TARGET_NAME} PROPERTIES OUTPUT_NAME curl)
     endif()
-    target_link_libraries(${CURL_TARGET_NAME} hv)
+    target_link_libraries(${CURL_TARGET_NAME} ${HV_LIBRARIES})
 
     # wget
     add_executable(wget wget.cpp)
-    target_link_libraries(wget hv)
+    target_link_libraries(wget ${HV_LIBRARIES})
 
     # consul
     aux_source_directory(consul CONSUL_SRCS)
     add_executable(consul ${CONSUL_SRCS})
     target_compile_definitions(consul PRIVATE PRINT_DEBUG)
-    target_link_libraries(consul hv)
+    target_link_libraries(consul ${HV_LIBRARIES})
 
     # http_client_test
     add_executable(http_client_test http_client_test.cpp)
-    target_link_libraries(http_client_test hv)
+    target_link_libraries(http_client_test ${HV_LIBRARIES})
 
     # websocket_client_test
     add_executable(websocket_client_test websocket_client_test.cpp)
-    target_link_libraries(websocket_client_test hv)
+    target_link_libraries(websocket_client_test ${HV_LIBRARIES})
 
     list(APPEND EXAMPLES ${CURL_TARGET_NAME} wget consul http_client_test websocket_client_test)
 
@@ -107,7 +107,7 @@ if(WITH_HTTP_CLIENT)
         # httpd
         aux_source_directory(httpd HTTPD_SRCS)
         add_executable(httpd ${HTTPD_SRCS})
-        target_link_libraries(httpd hv)
+        target_link_libraries(httpd ${HV_LIBRARIES})
         list(APPEND EXAMPLES httpd)
     endif()
 endif()