forked from valkey-io/libvalkey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build all examples successfully with CMake
Signed-off-by: Björn Svensson <[email protected]>
- Loading branch information
Showing
2 changed files
with
89 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,89 @@ | ||
INCLUDE(FindPkgConfig) | ||
cmake_minimum_required(VERSION 3.0.0) | ||
project(examples LANGUAGES C) | ||
|
||
# Add path to enable <valkey/x.h> includes | ||
include_directories(${CMAKE_SOURCE_DIR}/include) | ||
|
||
# Check for GLib | ||
include(FindPkgConfig) | ||
pkg_check_modules(GLIB2 glib-2.0) | ||
if(GLIB2_FOUND) | ||
add_executable(example-async-glib async-glib.c) | ||
target_include_directories(example-async-glib PUBLIC ${GLIB2_INCLUDE_DIRS}) | ||
target_link_libraries(example-async-glib valkey ${GLIB2_LIBRARIES}) | ||
endif() | ||
|
||
find_path(LIBEV ev.h | ||
HINTS /usr/local /usr/opt/local | ||
ENV LIBEV_INCLUDE_DIR) | ||
if(LIBEV) | ||
add_executable(example-async-libev async-libev.c) | ||
target_link_libraries(example-async-libev valkey ev) | ||
endif() | ||
|
||
find_path(LIBEVENT event.h) | ||
if(LIBEVENT) | ||
add_executable(example-async-libevent async-libevent.c) | ||
target_link_libraries(example-async-libevent valkey event) | ||
|
||
if(ENABLE_SSL) | ||
add_executable(example-async-libevent-ssl async-libevent-ssl.c) | ||
target_link_libraries(example-async-libevent-ssl valkey valkey_ssl event) | ||
endif() | ||
endif() | ||
|
||
find_path(LIBHV hv/hv.h) | ||
if(LIBHV) | ||
add_executable(example-async-libhv async-libhv.c) | ||
target_link_libraries(example-async-libhv valkey hv) | ||
endif() | ||
|
||
find_path(LIBUV uv.h) | ||
if(LIBUV) | ||
add_executable(example-async-libuv async-libuv.c) | ||
target_link_libraries(example-async-libuv valkey uv) | ||
endif() | ||
|
||
find_path(LIBSDEVENT systemd/sd-event.h) | ||
if(LIBSDEVENT) | ||
add_executable(example-async-libsdevent async-libsdevent.c) | ||
target_link_libraries(example-async-libsdevent valkey systemd) | ||
endif() | ||
|
||
if(APPLE) | ||
find_library(CF CoreFoundation) | ||
add_executable(example-async-macosx async-macosx.c) | ||
target_link_libraries(example-async-macosx valkey ${CF}) | ||
endif() | ||
|
||
if(ENABLE_SSL) | ||
add_executable(example-blocking-ssl blocking-ssl.c) | ||
target_link_libraries(example-blocking-ssl valkey valkey_ssl) | ||
endif() | ||
|
||
add_executable(example-blocking blocking.c) | ||
target_link_libraries(example-blocking valkey) | ||
|
||
add_executable(example-blocking-push blocking-push.c) | ||
target_link_libraries(example-blocking-push valkey) | ||
|
||
if(LIBEVENT) | ||
add_executable(example-cluster-async cluster-async.c) | ||
target_link_libraries(example-cluster-async valkey event) | ||
|
||
if(ENABLE_SSL) | ||
add_executable(example-cluster-async-tls cluster-async-tls.c) | ||
target_link_libraries(example-cluster-async-tls valkey valkey_ssl event) | ||
endif() | ||
|
||
add_executable(example-cluster-clientside-caching-async cluster-clientside-caching-async.c) | ||
target_link_libraries(example-cluster-clientside-caching-async valkey event) | ||
endif() | ||
|
||
add_executable(example-cluster-simple cluster-simple.c) | ||
target_link_libraries(example-cluster-simple valkey) | ||
|
||
PKG_CHECK_MODULES(GLIB2 glib-2.0) | ||
if (GLIB2_FOUND) | ||
INCLUDE_DIRECTORIES(${GLIB2_INCLUDE_DIRS}) | ||
LINK_DIRECTORIES(${GLIB2_LIBRARY_DIRS}) | ||
ADD_EXECUTABLE(async-glib async-glib.c) | ||
TARGET_LINK_LIBRARIES(async-glib valkey ${GLIB2_LIBRARIES}) | ||
ENDIF(GLIB2_FOUND) | ||
|
||
FIND_PATH(LIBEV ev.h | ||
HINTS /usr/local /usr/opt/local | ||
ENV LIBEV_INCLUDE_DIR) | ||
|
||
if (LIBEV) | ||
# Just compile and link with libev | ||
ADD_EXECUTABLE(async-libev async-libev.c) | ||
TARGET_LINK_LIBRARIES(async-libev valkey ev) | ||
ENDIF() | ||
|
||
FIND_PATH(LIBEVENT event.h) | ||
if (LIBEVENT) | ||
ADD_EXECUTABLE(async-libevent async-libevent.c) | ||
TARGET_LINK_LIBRARIES(async-libevent valkey event) | ||
ENDIF() | ||
|
||
FIND_PATH(LIBHV hv/hv.h) | ||
IF (LIBHV) | ||
ADD_EXECUTABLE(async-libhv async-libhv.c) | ||
TARGET_LINK_LIBRARIES(async-libhv valkey hv) | ||
ENDIF() | ||
|
||
FIND_PATH(LIBUV uv.h) | ||
IF (LIBUV) | ||
ADD_EXECUTABLE(async-libuv async-libuv.c) | ||
TARGET_LINK_LIBRARIES(async-libuv valkey uv) | ||
ENDIF() | ||
|
||
FIND_PATH(LIBSDEVENT systemd/sd-event.h) | ||
IF (LIBSDEVENT) | ||
ADD_EXECUTABLE(async-libsdevent async-libsdevent.c) | ||
TARGET_LINK_LIBRARIES(async-libsdevent valkey systemd) | ||
ENDIF() | ||
|
||
IF (APPLE) | ||
FIND_LIBRARY(CF CoreFoundation) | ||
ADD_EXECUTABLE(async-macosx async-macosx.c) | ||
TARGET_LINK_LIBRARIES(async-macosx valkey ${CF}) | ||
ENDIF() | ||
|
||
IF (ENABLE_SSL) | ||
ADD_EXECUTABLE(example-ssl example-ssl.c) | ||
TARGET_LINK_LIBRARIES(example-ssl valkey valkey_ssl) | ||
ENDIF() | ||
|
||
ADD_EXECUTABLE(example blocking.c) | ||
TARGET_LINK_LIBRARIES(example valkey) | ||
|
||
ADD_EXECUTABLE(blocking-push blocking-push.c) | ||
TARGET_LINK_LIBRARIES(blocking-push valkey) | ||
if(ENABLE_SSL) | ||
add_executable(example-cluster-tls cluster-tls.c) | ||
target_link_libraries(example-cluster-tls valkey valkey_ssl) | ||
endif() |