Add Travis CI configuration
[umurmur.git] / CMakeLists.txt
index e1755fe97806d62c699afca4d742b51d8a33bc42..9a089951764995f7cefe1d8f78f28463a4896412 100644 (file)
@@ -1,48 +1,32 @@
-project(umurmurd)
+cmake_minimum_required(VERSION 2.8.3)
+project(umurmurd C)
 
-cmake_minimum_required(VERSION 2.8)
+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}")
 
-add_definitions()
-
-include(FindPkgConfig)
-include(CheckFunctionExists)
-include(CheckLibraryExists)
-include(CheckSymbolExists)
-
-if(SSL MATCHES "openssl")
-  pkg_check_modules(SSLIMP REQUIRED openssl)
-else()
-  pkg_check_modules(SSLIMP REQUIRED polarssl)
-  set(USE_POLARSSL ON)
+if(NOT CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE Release CACHE STRING "The type of build product that should be produced." FORCE)
 endif()
 
-pkg_check_modules(LIBCONFIG libconfig)
-pkg_check_modules(LIBPROTOBUF libprotobuf-c)
+include(SelectTLSBackend)
+include(SelectRTBackend)
 
-link_directories(${LIBCONFIG_LIBDIR} ${LIBPROTOBUF_LIBDIR})
+SelectRTBackend()
+SelectTLSBackend("${SSL}")
 
-check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
+include(Options)
+include(Tools)
 
-if(NOT HAVE_CLOCK_GETTIME)
-  check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT)
-  if(NOT HAVE_CLOCK_GETTIME_RT)
-    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()
-  else()
-    set(LIBRARIES ${LIBRARIES} rt)
-  endif()
-endif()
+find_package(Libconfig REQUIRED)
+find_package(ProtobufC REQUIRED)
 
-set(SOURCE "")
 add_subdirectory(src)
-include_directories(include)
 
-add_executable(umurmurd ${SOURCE})
+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()
 
-add_definitions(${LIBCONFIG_CFLAGS} ${LIBPROTOBUF_CFLAGS} ${SSLIMP_CFLAGS})
-target_link_libraries(umurmurd ${LIBCONFIG_LIBRARIES} ${LIBPROTOBUF_LIBRARIES} ${SSLIMP_LIBRARIES})
-
-configure_file(src/config.h.in ${CMAKE_SOURCE_DIR}/src/config.h)