-project(umurmurd)
-
cmake_minimum_required(VERSION 2.8)
-add_definitions()
+project(umurmurd C)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
-include(FindPkgConfig)
+find_package(Libconfig REQUIRED)
+find_package(ProtobufC REQUIRED)
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)
-endif()
-
-pkg_check_modules(LIBCONFIG REQUIRED libconfig)
-pkg_check_modules(LIBPROTOBUF REQUIRED libprotobuf-c)
-
-link_directories(${LIBCONFIG_LIBDIR} ${LIBPROTOBUF_LIBDIR})
+ 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")
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
set(SOURCE "")
add_subdirectory(src)
-include_directories(include)
-add_executable(umurmurd ${SOURCE})
+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_definitions(${LIBCONFIG_CFLAGS} ${LIBPROTOBUF_CFLAGS} ${SSLIMP_CFLAGS})
-target_link_libraries(umurmurd ${LIBCONFIG_LIBRARIES} ${LIBPROTOBUF_LIBRARIES} ${SSLIMP_LIBRARIES})
+add_executable(umurmurd ${SOURCE})
-configure_file(src/config.h.in ${CMAKE_SOURCE_DIR}/src/config.h)
+add_definitions(${SSLIMP_CFLAGS})
+target_link_libraries(umurmurd ${LIBCONFIG_LIBRARIES} ${PROTOBUFC_LIBRARIES} ${SSLIMP_LIBRARIES})
--- /dev/null
+include(FindPackageHandleStandardArgs)
+
+message("-- looking for libconfig")
+
+find_path(LIBCONFIG_INCLUDE_DIR NAMES "libconfig.h" PATHS /usr/pkg /usr/local /usr PATH_SUFFIXES "include")
+find_path(LIBCONFIG_LIB_DIR NAMES "libconfig.so" PATHS /usr/pkg /usr/local /usr PATH_SUFFIXES "lib")
+
+if(LIBCONFIG_INCLUDE_DIR AND LIBCONFIG_LIB_DIR)
+ set(LIBCONFIG_LIBRARIES config)
+endif(LIBCONFIG_INCLUDE_DIR AND LIBCONFIG_LIB_DIR)
+
+find_package_handle_standard_args(Libconfig DEFAULT LIBCONFIG_INCLUDE_DIR LIBCONFIG_LIBRARIES LIBCONFIG_LIB_DIR)
--- /dev/null
+include(FindPackageHandleStandardArgs)
+include(CheckSymbolExists)
+
+find_path(POLARSSL_INCLUDE_DIR NAMES "version.h" PATHS /usr/pkg /usr/local /usr PATH_SUFFIXES "include/polarssl")
+find_path(POLARSSL_LIB_DIR NAMES "libpolarssl.so" PATHS /usr/pkg /usr/local /usr PATH_SUFFIXES "lib")
+
+if(POLARSSL_INCLUDE_DIR AND POLARSSL_LIB_DIR)
+ set(POLARSSL_LIBRARIES polarssl)
+ check_symbol_exists(POLARSSL_ZLIB_SUPPORT "${POLARSSL_INCLUDE_DIR}/version.h" HAVE_ZLIB_SUPPORT)
+ if(HAVE_ZLIB_SUPPORT)
+ set(POLARSSL_LIBRARIES ${POLARSSL_LIBRARIES} z)
+ endif(HAVE_ZLIB_SUPPORT)
+endif(POLARSSL_INCLUDE_DIR AND POLARSSL_LIB_DIR)
+
+find_package_handle_standard_args(PolarSSL REQUIRED_VARS POLARSSL_INCLUDE_DIR POLARSSL_LIBRARIES POLARSSL_LIB_DIR)
--- /dev/null
+include(FindPackageHandleStandardArgs)
+
+find_path(PROTOBUFC_INCLUDE_DIR NAMES "protobuf-c.h" PATHS /usr/pkg /usr/local /usr PATH_SUFFIXES "include/google/protobuf-c")
+find_path(PROTOBUFC_LIB_DIR NAMES "libprotobuf-c.so" PATHS /usr/pkg /usr/local /usr PATH_SUFFIXES "lib")
+
+if(PROTOBUFC_INCLUDE_DIR AND PROTOBUFC_LIB_DIR)
+ set(PROTOBUFC_LIBRARIES protobuf-c)
+endif(PROTOBUFC_INCLUDE_DIR AND PROTOBUFC_LIB_DIR)
+
+find_package_handle_standard_args(ProtobufC REQUIRED_VARS PROTOBUFC_INCLUDE_DIR PROTOBUFC_LIBRARIES PROTOBUFC_LIB_DIR)