X-Git-Url: http://git.code-monkey.de/?p=umurmur.git;a=blobdiff_plain;f=CMakeLists.txt;h=9a089951764995f7cefe1d8f78f28463a4896412;hp=6e81c3c12906a2bd8cd14367e9455b155c32a73c;hb=d017730cd2eb7eeb219e7fb975cce7c7c377b195;hpb=a7ffadd41a1457e24ffde19a081c4b8bffe1b3b8 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e81c3c..9a08995 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,70 +1,32 @@ -cmake_minimum_required(VERSION 2.8) - +cmake_minimum_required(VERSION 2.8.3) project(umurmurd C) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true) +set(UMURMUR_BINARY_DIR "${CMAKE_BINARY_DIR}/bin") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${UMURMUR_BINARY_DIR}") -option(USE_POLARSSL_TESTCERT "Link to the PolarSSL test certificate and key." OFF) -option(USE_POLARSSL_HAVEGE "Use the PolarSSL HAVEGE random generator key." OFF) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release CACHE STRING "The type of build product that should be produced." FORCE) +endif() -if(USE_POLARSSL_TESTCERT OR USE_POLARSSL_HAVEGE) - if(SSL MATCHES "openssl") - message(FATAL_ERROR "Selecting USE_POLARSSL_TESTCERT or USE_POLARSSL_HAVEGE implies SSL=polarssl") - endif(SSL MATCHES "openssl") -endif(USE_POLARSSL_TESTCERT OR USE_POLARSSL_HAVEGE) +include(SelectTLSBackend) +include(SelectRTBackend) -find_package(Libconfig REQUIRED) -find_package(ProtobufC REQUIRED) -include(CheckFunctionExists) -include(CheckLibraryExists) +SelectRTBackend() +SelectTLSBackend("${SSL}") -if(SSL MATCHES "openssl") - find_package(OpenSSL REQUIRED) - if(OPENSSL_FOUND) - set(SSLIMP_LIBRARIES ${OPENSSL_LIBRARIES}) - set(SSLIMP_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}) - set(SSLIMP_LIBRARY_DIR ${OPENSSL_LIB_DIR}) - endif(OPENSSL_FOUND) -else(SSL MATCHES "openssl") - find_package(PolarSSL REQUIRED) - if(POLARSSL_FOUND) - set(USE_POLARSSL ON) - set(SSLIMP_LIBRARIES ${POLARSSL_LIBRARIES}) - set(SSLIMP_INCLUDE_DIR ${POLARSSL_INCLUDE_DIR}) - set(SSLIMP_LIBRARY_DIR ${POLARSSL_LIB_DIR}) - endif(POLARSSL_FOUND) -endif(SSL MATCHES "openssl") +include(Options) +include(Tools) -check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT) - -if(NOT HAVE_CLOCK_GETTIME_RT) - check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) - if(NOT HAVE_CLOCK_GETTIME) - check_library_exists(c clock_get_time "mach/time.h" HAVE_CLOCK_GET_TIME) - if(NOT HAVE_CLOCK_GET_TIME) - message(FATAL_ERROR "Didn't find clock_gettime() or clock_get_time!") - endif() - endif() -else() - set(LIBRT rt) -endif() +find_package(Libconfig REQUIRED) +find_package(ProtobufC REQUIRED) -set(SOURCE "") add_subdirectory(src) -configure_file(src/config.h.in ${CMAKE_SOURCE_DIR}/src/config.h) - -include_directories(${LIBCONFIG_INCLUDE_DIR} ${PROTOBUFC_INCLUDE_DIR} ${SSLIMP_INCLUDE_DIR}) -link_directories(${LIBCONFIG_LIB_DIR} ${PROTOBUFC_LIB_DIR} ${SSLIMP_LIB_DIR}) - -add_executable(umurmurd ${SOURCE}) -install(TARGETS umurmurd RUNTIME DESTINATION "bin") - find_path(OLD_CONFIG_FILE NAMES "umurmur.conf" PATHS ${CMAKE_INSTALL_PREFIX} PATH_SUFFIXES "etc") + if(NOT OLD_CONFIG_FILE) install(FILES "umurmur.conf.example" DESTINATION "etc" RENAME "umurmur.conf") -endif(NOT OLD_CONFIG_FILE) +endif() -add_definitions(${SSLIMP_CFLAGS}) -target_link_libraries(umurmurd ${LIBCONFIG_LIBRARIES} ${PROTOBUFC_LIBRARIES} ${SSLIMP_LIBRARIES} ${LIBRT})