2016-07-14 15:36:14 +00:00
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
2017-05-20 00:50:50 +00:00
project(incredis VERSION 0.1.0 LANGUAGES CXX)
2016-07-14 15:36:14 +00:00
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
include(shared_git_project)
2016-12-02 14:16:32 +00:00
include(CTest)
2016-07-14 15:36:14 +00:00
2017-05-04 21:54:21 +00:00
option(INCREDIS_FORCE_DISABLE_TESTS "Ignore unit tests even if BUILD_TESTING is set to ON - useful if you want to disable incredis tests from your top-level cmake project" OFF)
2017-06-06 22:00:54 +00:00
option(INCREDIS_OWN_BETTER_ENUM "Use bundled better-enum" ON)
option(INCREDIS_OWN_DUCKHANDY "Use bundled duckhandy" ON)
2017-05-20 00:50:50 +00:00
set(CMAKE_INSTALL_INCLUDEDIR "" CACHE PATH "Specify the output directory for header files (default is include)")
2017-05-20 01:19:22 +00:00
set(CMAKE_INSTALL_LIBDIR "" CACHE PATH "Specify the output directory for libraries (default is lib)")
set(CMAKE_INSTALL_PKGCONFIGDIR "" CACHE PATH "Specify the output directory for pkgconfig files (default is lib/pkgconfig)")
set(PROJECT_URL "https://github.com/KingDuckZ/incredis")
set(PROJECT_DESCRIPTION "A lightweight C++ wrapper around hiredis")
2017-05-20 00:50:50 +00:00
if(NOT CMAKE_INSTALL_INCLUDEDIR)
set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
endif(NOT CMAKE_INSTALL_INCLUDEDIR)
2017-05-20 01:19:22 +00:00
if(NOT CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
endif(NOT CMAKE_INSTALL_LIBDIR)
if(NOT CMAKE_INSTALL_PKGCONFIGDIR)
set(CMAKE_INSTALL_PKGCONFIGDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif(NOT CMAKE_INSTALL_PKGCONFIGDIR)
2017-05-04 21:54:21 +00:00
2016-07-15 18:19:16 +00:00
find_package(hiredis 0.11.0 REQUIRED)
2016-07-14 15:36:14 +00:00
find_package(CryptoPP 5.6)
find_package(libev 4.0 REQUIRED)
find_package(Boost 1.53.0 REQUIRED)
2017-06-06 22:00:54 +00:00
if (NOT INCREDIS_OWN_BETTER_ENUM)
find_package(better_enum REQUIRED)
endif()
if (INCREDIS_OWN_DUCKHANDY)
add_shared_git_project("lib/duckhandy")
else()
find_package(duckhandy REQUIRED)
endif()
2016-07-14 15:49:09 +00:00
2016-07-14 15:36:14 +00:00
add_library(${PROJECT_NAME} SHARED
src/command.cpp
src/scan_iterator.cpp
src/reply.cpp
src/batch.cpp
src/script.cpp
src/script_manager.cpp
src/async_connection.cpp
src/incredis.cpp
src/incredis_batch.cpp
2016-12-06 18:39:41 +00:00
src/reply_list.cpp
2016-07-14 15:36:14 +00:00
)
target_include_directories(${PROJECT_NAME} SYSTEM
PUBLIC ${Boost_INCLUDE_DIRS}
PRIVATE ${HIREDIS_INCLUDE_DIRS}
PRIVATE ${LIBEV_INCLUDE_DIRS}
)
2017-06-06 22:00:54 +00:00
target_include_directories(${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC $<INSTALL_INTERFACE:include>
2016-07-14 15:36:14 +00:00
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
2016-07-14 17:13:03 +00:00
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/incredis
2016-07-14 15:36:14 +00:00
)
2017-06-06 22:00:54 +00:00
if (INCREDIS_OWN_BETTER_ENUM)
target_include_directories(${PROJECT_NAME} SYSTEM
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/better-enums>
)
else()
target_include_directories(${PROJECT_NAME} SYSTEM
PUBLIC ${BETTER_ENUM_INCLUDE_DIRS}
)
endif()
if (INCREDIS_OWN_DUCKHANDY)
target_link_libraries(${PROJECT_NAME}
PUBLIC $<BUILD_INTERFACE:duckhandy>
)
else()
target_include_directories(${PROJECT_NAME}
PUBLIC ${DUCKHANDY_INCLUDE_DIRS}
)
endif()
2016-07-14 15:36:14 +00:00
target_link_libraries(${PROJECT_NAME}
PRIVATE ${HIREDIS_LIBRARIES}
PRIVATE ${LIBEV_LIBRARIES}
PRIVATE ${Boost_LIBRARIES}
)
configure_file(
src/incredisConfig.h.in
${CMAKE_CURRENT_BINARY_DIR}/incredisConfig.h
)
2017-05-20 01:19:22 +00:00
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig/incredis.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/incredis.pc"
@ONLY
)
2016-07-14 15:36:14 +00:00
target_compile_definitions(${PROJECT_NAME}
PRIVATE EV_COMPAT3=0
)
if (CryptoPP_FOUND)
target_link_libraries(${PROJECT_NAME} PRIVATE ${CryptoPP_LIBRARIES})
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${CryptoPP_INCLUDE_DIRS})
set (has_cryptopp_lib ON)
else()
set (has_cryptopp_lib OFF)
endif()
2016-12-02 14:16:32 +00:00
set(INCREDIS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
2016-07-14 15:36:14 +00:00
2017-05-20 01:19:22 +00:00
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Config
2016-07-14 15:36:14 +00:00
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib/static
)
2017-05-20 00:50:50 +00:00
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT ${PROJECT_NAME}Config DESTINATION share/${PROJECT_NAME}/cmake)
2017-05-20 01:19:22 +00:00
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/incredis.pc" DESTINATION ${CMAKE_INSTALL_PKGCONFIGDIR})
2016-07-14 15:36:14 +00:00
target_compile_features(${PROJECT_NAME}
PUBLIC cxx_nullptr
PUBLIC cxx_range_for
PUBLIC cxx_lambdas
PUBLIC cxx_decltype_auto
PUBLIC cxx_defaulted_functions
PUBLIC cxx_deleted_functions
PUBLIC cxx_auto_type
PUBLIC cxx_decltype_incomplete_return_types
PUBLIC cxx_defaulted_move_initializers
PUBLIC cxx_noexcept
PUBLIC cxx_rvalue_references
)
2016-12-02 14:16:32 +00:00
2017-05-04 21:54:21 +00:00
if (BUILD_TESTING AND NOT INCREDIS_FORCE_DISABLE_TESTS)
2016-12-02 14:16:32 +00:00
add_subdirectory(test/integration)
endif()