Skip to content

Commit

Permalink
Add CMake system. Initial commit
Browse files Browse the repository at this point in the history
This provides a target to build a DSO, as well as the ability to install
it.
  • Loading branch information
mnunberg committed Feb 20, 2019
1 parent c732240 commit ead586a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions 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

0 comments on commit ead586a

Please sign in to comment.