1 cmake_minimum_required(VERSION 2.8)
5 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
6 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true)
8 option(USE_POLARSSL_TESTCERT "Link to the PolarSSL test certificate and key." OFF)
9 option(USE_POLARSSL_HAVEGE "Use the PolarSSL HAVEGE random generator key." OFF)
11 if(USE_POLARSSL_TESTCERT OR USE_POLARSSL_HAVEGE)
12 if(SSL MATCHES "openssl")
13 message(FATAL_ERROR "Selecting USE_POLARSSL_TESTCERT or USE_POLARSSL_HAVEGE implies SSL=polarssl")
14 endif(SSL MATCHES "openssl")
15 endif(USE_POLARSSL_TESTCERT OR USE_POLARSSL_HAVEGE)
17 find_package(Libconfig REQUIRED)
18 find_package(ProtobufC REQUIRED)
19 include(CheckFunctionExists)
20 include(CheckLibraryExists)
22 if(SSL MATCHES "openssl")
23 find_package(OpenSSL REQUIRED)
25 set(SSLIMP_LIBRARIES ${OPENSSL_LIBRARIES})
26 set(SSLIMP_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR})
27 set(SSLIMP_LIBRARY_DIR ${OPENSSL_LIB_DIR})
29 else(SSL MATCHES "openssl")
30 find_package(PolarSSL REQUIRED)
33 set(SSLIMP_LIBRARIES ${POLARSSL_LIBRARIES})
34 set(SSLIMP_INCLUDE_DIR ${POLARSSL_INCLUDE_DIR})
35 set(SSLIMP_LIBRARY_DIR ${POLARSSL_LIB_DIR})
37 endif(SSL MATCHES "openssl")
39 check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
41 if(NOT HAVE_CLOCK_GETTIME)
42 check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT)
43 if(NOT HAVE_CLOCK_GETTIME_RT)
44 check_library_exists(c clock_get_time "mach/time.h" HAVE_CLOCK_GET_TIME)
45 if(NOT HAVE_CLOCK_GET_TIME)
46 message(FATAL_ERROR "Didn't find clock_gettime() or clock_get_time!")
56 configure_file(src/config.h.in ${CMAKE_SOURCE_DIR}/src/config.h)
58 include_directories(${LIBCONFIG_INCLUDE_DIR} ${PROTOBUFC_INCLUDE_DIR} ${SSLIMP_INCLUDE_DIR})
59 link_directories(${LIBCONFIG_LIB_DIR} ${PROTOBUFC_LIB_DIR} ${SSLIMP_LIB_DIR})
61 add_executable(umurmurd ${SOURCE})
62 install(TARGETS umurmurd RUNTIME DESTINATION "bin")
64 find_path(OLD_CONFIG_FILE NAMES "umurmur.conf" PATHS ${CMAKE_INSTALL_PREFIX} PATH_SUFFIXES "etc")
65 if(NOT OLD_CONFIG_FILE)
66 install(FILES "umurmur.conf.example" DESTINATION "etc" RENAME "umurmur.conf")
67 endif(NOT OLD_CONFIG_FILE)
69 add_definitions(${SSLIMP_CFLAGS})
70 target_link_libraries(umurmurd ${LIBCONFIG_LIBRARIES} ${PROTOBUFC_LIBRARIES} ${SSLIMP_LIBRARIES} ${LIBRT})