Commit c0a7e59674086afb903ac3a2c25dcd43d352e3d3
Merge pull request #32 from esindril/master
Add CMake find module for hiredis and libev
Showing
3 changed files
with
79 additions
and
5 deletions
CMakeLists.txt
| @@ -17,11 +17,28 @@ if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) | @@ -17,11 +17,28 @@ if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) | ||
| 17 | endif(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) | 17 | endif(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) |
| 18 | 18 | ||
| 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -Wall") | 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -Wall") |
| 20 | +set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) | ||
| 20 | 21 | ||
| 21 | # Print out compiler commands | 22 | # Print out compiler commands |
| 22 | # set(CMAKE_VERBOSE_MAKEFILE ON) | 23 | # set(CMAKE_VERBOSE_MAKEFILE ON) |
| 23 | 24 | ||
| 24 | # --------------------------------------------------------- | 25 | # --------------------------------------------------------- |
| 26 | +# Check for required dependencies | ||
| 27 | +# --------------------------------------------------------- | ||
| 28 | +if(CMAKE_VERSION VERSION_GREATER 2.8.5 OR CMAKE_VERSION VERSION_EQUAL 2.8.5) | ||
| 29 | + include(GNUInstallDirs) | ||
| 30 | +endif() | ||
| 31 | + | ||
| 32 | +find_package(Threads REQUIRED) | ||
| 33 | +find_package(hiredis REQUIRED) | ||
| 34 | +find_package(libev REQUIRED) | ||
| 35 | + | ||
| 36 | +set(REDOX_LIB_DEPS | ||
| 37 | + ${HIREDIS_LIBRARIES} | ||
| 38 | + ${LIBEV_LIBRARIES} | ||
| 39 | + ${CMAKE_THREAD_LIBS_INIT}) | ||
| 40 | + | ||
| 41 | +# --------------------------------------------------------- | ||
| 25 | # Source files | 42 | # Source files |
| 26 | # --------------------------------------------------------- | 43 | # --------------------------------------------------------- |
| 27 | 44 | ||
| @@ -49,11 +66,6 @@ set(INC_REDOX_ALL ${INC_REDOX_CORE} ${INC_REDOX_UTILS} ${INC_REDOX_WRAPPER}) | @@ -49,11 +66,6 @@ set(INC_REDOX_ALL ${INC_REDOX_CORE} ${INC_REDOX_UTILS} ${INC_REDOX_WRAPPER}) | ||
| 49 | include_directories(${INC_REDOX_DIR}) | 66 | include_directories(${INC_REDOX_DIR}) |
| 50 | include_directories(${INC_REDOX_DIR}/redox) | 67 | include_directories(${INC_REDOX_DIR}/redox) |
| 51 | 68 | ||
| 52 | -# Dependent libraries - you may have to change | ||
| 53 | -# pthread to whatever C++11 threads depends on | ||
| 54 | -# for your platform | ||
| 55 | -set(REDOX_LIB_DEPS ev pthread hiredis) | ||
| 56 | - | ||
| 57 | # --------------------------------------------------------- | 69 | # --------------------------------------------------------- |
| 58 | # Library generation | 70 | # Library generation |
| 59 | # --------------------------------------------------------- | 71 | # --------------------------------------------------------- |
cmake/Findhiredis.cmake
0 → 100644
| 1 | +# Try to find hiredis | ||
| 2 | +# Once done, this will define | ||
| 3 | +# | ||
| 4 | +# HIREDIS_FOUND - system has hiredis | ||
| 5 | +# HIREDIS_INCLUDE_DIRS - hiredis include directories | ||
| 6 | +# HIREDIS_LIBRARIES - libraries need to use hiredis | ||
| 7 | + | ||
| 8 | +if(HIREDIS_INCLUDE_DIRS AND HIREDIS_LIBRARIES) | ||
| 9 | + set(HIREDIS_FIND_QUIETLY TRUE) | ||
| 10 | +else() | ||
| 11 | + find_path( | ||
| 12 | + HIREDIS_INCLUDE_DIR | ||
| 13 | + NAMES hiredis/hiredis.h | ||
| 14 | + HINTS ${HIREDIS_ROOT_DIR} | ||
| 15 | + PATH_SUFFIXES include) | ||
| 16 | + | ||
| 17 | + find_library( | ||
| 18 | + HIREDIS_LIBRARY | ||
| 19 | + NAMES hiredis | ||
| 20 | + HINTS ${HIREDIS_ROOT_DIR} | ||
| 21 | + PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR}) | ||
| 22 | + | ||
| 23 | + set(HIREDIS_INCLUDE_DIRS ${HIREDIS_INCLUDE_DIR}) | ||
| 24 | + set(HIREDIS_LIBRARIES ${HIREDIS_LIBRARY}) | ||
| 25 | + | ||
| 26 | + include (FindPackageHandleStandardArgs) | ||
| 27 | + find_package_handle_standard_args( | ||
| 28 | + hiredis DEFAULT_MSG HIREDIS_LIBRARY HIREDIS_INCLUDE_DIR) | ||
| 29 | + | ||
| 30 | + mark_as_advanced(HIREDIS_LIBRARY HIREDIS_INCLUDE_DIR) | ||
| 31 | +endif() |
cmake/Findlibev.cmake
0 → 100644
| 1 | +# Try to find libev | ||
| 2 | +# Once done, this will define | ||
| 3 | +# | ||
| 4 | +# LIBEV_FOUND - system has libev | ||
| 5 | +# LIBEV_INCLUDE_DIRS - libev include directories | ||
| 6 | +# LIBEV_LIBRARIES - libraries needed to use libev | ||
| 7 | + | ||
| 8 | +if(LIBEV_INCLUDE_DIRS AND LIBEV_LIBRARIES) | ||
| 9 | + set(LIBEV_FIND_QUIETLY TRUE) | ||
| 10 | +else() | ||
| 11 | + find_path( | ||
| 12 | + LIBEV_INCLUDE_DIR | ||
| 13 | + NAMES ev.h | ||
| 14 | + HINTS ${LIBEV_ROOT_DIR} | ||
| 15 | + PATH_SUFFIXES include) | ||
| 16 | + | ||
| 17 | + find_library( | ||
| 18 | + LIBEV_LIBRARY | ||
| 19 | + NAME ev | ||
| 20 | + HINTS ${LIBEV_ROOT_DIR} | ||
| 21 | + PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR}) | ||
| 22 | + | ||
| 23 | + set(LIBEV_INCLUDE_DIRS ${LIBEV_INCLUDE_DIR}) | ||
| 24 | + set(LIBEV_LIBRARIES ${LIBEV_LIBRARY}) | ||
| 25 | + | ||
| 26 | + include(FindPackageHandleStandardArgs) | ||
| 27 | + find_package_handle_standard_args( | ||
| 28 | + libev DEFAULT_MSG LIBEV_LIBRARY LIBEV_INCLUDE_DIR) | ||
| 29 | + | ||
| 30 | + mark_as_advanced(LIBEV_LIBRARY LIBEV_INCLUDE_DIR) | ||
| 31 | +endif() |