diff options
author | Mark Nunberg <mnunberg@haskalah.org> | 2018-10-01 21:38:45 -0400 |
---|---|---|
committer | Mark Nunberg <mnunberg@haskalah.org> | 2019-02-20 05:01:08 -0500 |
commit | bbad21f5cac8295e83e4d118d450aaa32e4435d8 (patch) | |
tree | 9ef64ef2e0db81af5dabb301fb928bc29b19f120 | |
parent | ead586a2cb7de8a17073a96704a4200d63a380e5 (diff) |
Add examples to CMakeLists
-rw-r--r-- | CMakeLists.txt | 3 | ||||
-rw-r--r-- | examples/CMakeLists.txt | 41 |
2 files changed, 44 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b1771d5..f3a87f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,8 @@ getVersionBit(HIREDIS_PATCH) MESSAGE("Detected version: ${HIREDIS_MAJOR}.${HIREDIS_MINOR}.${HIREDIS_PATCH}") +INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) + ADD_LIBRARY(hiredis SHARED async.c dict.c @@ -44,4 +46,5 @@ ADD_EXECUTABLE(hiredis-test TARGET_LINK_LIBRARIES(hiredis-test hiredis) # Add examples +ADD_SUBDIRECTORY(examples) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..27388cb --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,41 @@ +INCLUDE(FindPkgConfig) +# Check for GLib + +PKG_CHECK_MODULES(GLIB2 glib-2.0) +if (GLIB2_FOUND) + INCLUDE_DIRECTORIES(${GLIB2_INCLUDE_DIRS}) + LINK_DIRECTORIES(${GLIB2_LIBRARY_DIRS}) + ADD_EXECUTABLE(example-glib example-glib.c) + TARGET_LINK_LIBRARIES(example-glib hiredis ${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(example-libev example-libev.c) + TARGET_LINK_LIBRARIES(example-libev hiredis ev) +ENDIF() + +FIND_PATH(LIBEVENT event.h) +if (LIBEVENT) + ADD_EXECUTABLE(example-libevent example-libevent) + TARGET_LINK_LIBRARIES(example-libevent hiredis event) +ENDIF() + +FIND_PATH(LIBUV uv.h) +IF (LIBUV) + ADD_EXECUTABLE(example-libuv example-libuv.c) + TARGET_LINK_LIBRARIES(example-libuv hiredis uv) +ENDIF() + +IF (APPLE) + FIND_LIBRARY(CF CoreFoundation) + ADD_EXECUTABLE(example-macosx example-macosx.c) + TARGET_LINK_LIBRARIES(example-macosx hiredis ${CF}) +ENDIF() + +ADD_EXECUTABLE(example example.c) +TARGET_LINK_LIBRARIES(example hiredis)
\ No newline at end of file |