summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Nunberg <mnunberg@haskalah.org>2018-09-25 19:44:58 -0400
committerMark Nunberg <mnunberg@haskalah.org>2019-02-20 05:01:08 -0500
commitead586a2cb7de8a17073a96704a4200d63a380e5 (patch)
treeed51d6a129ead0d7b6e891f1dc4235c415ae5e85
parentc732240152331f33bfe54e8cff451e515ba2fee5 (diff)
Add CMake system. Initial commit
This provides a target to build a DSO, as well as the ability to install it.
-rw-r--r--CMakeLists.txt47
1 files changed, 47 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..b1771d5
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,47 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
+INCLUDE(GNUInstallDirs)
+PROJECT(redisearch)
+
+# Get the version numbers
+MACRO(getVersionBit name)
+
+EXECUTE_PROCESS(
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ COMMAND grep "${name}" hiredis.h COMMAND awk "{print $3}"
+ OUTPUT_VARIABLE "${name}"
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ENDMACRO(getVersionBit)
+
+getVersionBit(HIREDIS_MAJOR)
+getVersionBit(HIREDIS_MINOR)
+getVersionBit(HIREDIS_PATCH)
+
+MESSAGE("Detected version: ${HIREDIS_MAJOR}.${HIREDIS_MINOR}.${HIREDIS_PATCH}")
+
+ADD_LIBRARY(hiredis SHARED
+ async.c
+ dict.c
+ hiredis.c
+ net.c
+ read.c
+ sds.c)
+
+SET_TARGET_PROPERTIES(hiredis
+ PROPERTIES
+ VERSION "${HIREDIS_MAJOR}.${HIREDIS_MINOR}.${HIREDIS_PATCH}")
+
+INSTALL(TARGETS hiredis
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+
+INSTALL(FILES hiredis.h read.h sds.h
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/hiredis)
+
+# Add tests: Currently, I don't know how to make the tests actually run
+# without hanging!
+ENABLE_TESTING()
+ADD_EXECUTABLE(hiredis-test
+ test.c)
+TARGET_LINK_LIBRARIES(hiredis-test hiredis)
+
+# Add examples
+