fix example

This commit is contained in:
jiayuehua 2023-06-09 21:48:51 +08:00
parent 2699dbbf56
commit 282f8af681
4 changed files with 72 additions and 1 deletions

View File

@ -0,0 +1,61 @@
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 23b6a92..b8765dc 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -19,11 +19,11 @@ if (LIBEV)
TARGET_LINK_LIBRARIES(example-libev hiredis ev)
ENDIF()
-FIND_PATH(LIBEVENT event.h)
-if (LIBEVENT)
+find_package(Libevent CONFIG REQUIRED)
+if (1)
ADD_EXECUTABLE(example-libevent example-libevent.c)
- TARGET_LINK_LIBRARIES(example-libevent hiredis event)
-ENDIF()
+ TARGET_LINK_LIBRARIES(example-libevent hiredis libevent::core)
+endif()
FIND_PATH(LIBHV hv/hv.h)
IF (LIBHV)
@@ -31,10 +31,10 @@ IF (LIBHV)
TARGET_LINK_LIBRARIES(example-libhv hiredis hv)
ENDIF()
-FIND_PATH(LIBUV uv.h)
-IF (LIBUV)
+find_package(libuv CONFIG REQUIRED)
+IF (1)
ADD_EXECUTABLE(example-libuv example-libuv.c)
- TARGET_LINK_LIBRARIES(example-libuv hiredis uv)
+ TARGET_LINK_LIBRARIES(example-libuv hiredis $<IF:$<TARGET_EXISTS:uv_a>,uv_a,uv>)
ENDIF()
IF (APPLE)
@@ -44,12 +44,24 @@ IF (APPLE)
ENDIF()
IF (ENABLE_SSL)
+ FIND_PACKAGE(OpenSSL REQUIRED)
+ IF (WIN32)
+ FIND_PACKAGE(pthreads REQUIRED)
+ SET(THREADS_LIBS PThreads4W::PThreads4W)
+ ELSE()
+ FIND_PACKAGE(Threads)
+ SET(THREADS_LIBS ${CMAKE_THREAD_LIBS_INIT})
+ ENDIF()
ADD_EXECUTABLE(example-ssl example-ssl.c)
- TARGET_LINK_LIBRARIES(example-ssl hiredis hiredis_ssl)
+ if(WIN32)
+ TARGET_LINK_LIBRARIES(example-ssl hiredis hiredis_ssl OpenSSL::SSL OpenSSL::Crypto ${THREADS_LIBS} crypt32.lib)
+ else()
+ TARGET_LINK_LIBRARIES(example-ssl hiredis hiredis_ssl OpenSSL::SSL OpenSSL::Crypto ${THREADS_LIBS})
+ endif()
ENDIF()
ADD_EXECUTABLE(example example.c)
-TARGET_LINK_LIBRARIES(example hiredis)
+TARGET_LINK_LIBRARIES(example hiredis ${LIBEVENT_LIBRARIES})
ADD_EXECUTABLE(example-push example-push.c)
TARGET_LINK_LIBRARIES(example-push hiredis)

View File

@ -5,6 +5,7 @@ vcpkg_from_github(
SHA512 9dad012c144ed24de6aa413a3a10d19a9d0d9ece18dbc388406cd86c5b98cb66c76c586cb559c601ed13a75051d8921dc2882534cc3605513fde47d57276c3bb
HEAD_REF master
PATCHES
fix-feature-example.patch
fix-timeval.patch
fix-ssize_t.patch
support-static.patch
@ -16,6 +17,7 @@ vcpkg_from_github(
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
ssl ENABLE_SSL
example ENABLE_EXAMPLES
)
vcpkg_cmake_configure(

View File

@ -15,6 +15,14 @@
}
],
"features": {
"example": {
"description": "Build example",
"dependencies": [
"libevent",
"libuv",
"pthread"
]
},
"ssl": {
"description": "Build hiredis_ssl for SSL support",
"dependencies": [

View File

@ -1,7 +1,7 @@
{
"versions": [
{
"git-tree": "45a7cd93e7b4bdea587195679168ac78a2786496",
"git-tree": "9df637d129eac16de7fad1d206222cf093bd5cca",
"version": "1.1.0",
"port-version": 0
},