2018-01-19 18:31:32 +01:00
|
|
|
cmake_minimum_required(VERSION 3.6)
|
|
|
|
|
|
|
|
project(resply VERSION 0.1.0 DESCRIPTION "Modern redis client for C++")
|
2018-01-31 11:11:21 +01:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2018-01-19 18:31:32 +01:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
option(BUILD_DOC "Build documentation using doxygen" ON)
|
|
|
|
|
|
|
|
add_definitions(-DASIO_STANDALONE)
|
|
|
|
|
2018-01-31 11:11:21 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors -Werror -Wall -Wextra")
|
|
|
|
|
|
|
|
# Apparently, protobuf uses __builtin_offsetof in a way which clang declares as
|
|
|
|
# a extension to the language - gcc not. Disable that warning to get it to compile.
|
2018-02-28 09:17:03 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-extended-offsetof")
|
2018-01-31 11:11:21 +01:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
|
2018-01-19 18:31:32 +01:00
|
|
|
|
|
|
|
include_directories(include)
|
|
|
|
|
|
|
|
# https://github.com/chriskohlhoff/asio
|
2018-02-26 12:10:03 +01:00
|
|
|
include_directories($ENV{ASIO_INCLUDE_PATH})
|
2018-01-19 18:31:32 +01:00
|
|
|
|
|
|
|
# https://github.com/nlohmann/json
|
|
|
|
# should refer to the directory 'src' of json
|
2018-02-26 12:10:03 +01:00
|
|
|
include_directories($ENV{JSON_INCLUDE_PATH})
|
2018-01-19 18:31:32 +01:00
|
|
|
|
|
|
|
# https://github.com/muellan/clipp
|
2018-02-26 12:10:03 +01:00
|
|
|
include_directories($ENV{CLIPP_INCLUDE_PATH})
|
2018-01-19 18:31:32 +01:00
|
|
|
|
|
|
|
# https://github.com/gabime/spdlog
|
2018-02-26 12:10:03 +01:00
|
|
|
include_directories($ENV{SPDLOG_INCLUDE_PATH})
|
2018-01-19 18:31:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
# protobuf
|
|
|
|
find_package(Protobuf REQUIRED)
|
|
|
|
include_directories(${Protobuf_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
|
|
file(GLOB protos protos/*.proto)
|
|
|
|
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${protos})
|
|
|
|
|
|
|
|
# libresply
|
2018-01-25 23:39:12 +01:00
|
|
|
add_library(libresply OBJECT src/libresply.cc src/resp-parser.cc)
|
2018-01-19 18:31:32 +01:00
|
|
|
target_compile_definitions(libresply PRIVATE RESPLY_VERSION="${PROJECT_VERSION}")
|
|
|
|
|
|
|
|
add_library(resply-shared SHARED $<TARGET_OBJECTS:libresply>)
|
|
|
|
add_library(resply-static STATIC $<TARGET_OBJECTS:libresply>)
|
|
|
|
|
|
|
|
set_target_properties(resply-static PROPERTIES OUTPUT_NAME resply)
|
|
|
|
set_target_properties(resply-shared PROPERTIES OUTPUT_NAME resply)
|
|
|
|
|
|
|
|
install(TARGETS resply-shared DESTINATION lib)
|
|
|
|
install(TARGETS resply-static DESTINATION lib)
|
|
|
|
install(FILES include/resply.h DESTINATION include)
|
|
|
|
|
|
|
|
|
|
|
|
# cli
|
|
|
|
add_executable(resply-cli src/resply-cli.cc)
|
|
|
|
target_link_libraries(resply-cli resply-static)
|
|
|
|
|
|
|
|
add_executable(proto-cli src/proto-cli.cc ${PROTO_SRCS})
|
|
|
|
target_link_libraries(proto-cli ${PROTOBUF_LIBRARIES})
|
|
|
|
|
|
|
|
add_executable(grpc-cli src/grpc-cli.cc)
|
|
|
|
|
|
|
|
|
|
|
|
# proxy
|
|
|
|
add_executable(proxy src/proxy.cc ${PROTO_SRCS})
|
|
|
|
target_link_libraries(proxy resply-static ${PROTOBUF_LIBRARIES})
|
|
|
|
|
|
|
|
|
|
|
|
# tests
|
|
|
|
file(GLOB tests_source tests/*.cc)
|
|
|
|
foreach (test_source ${tests_source})
|
|
|
|
get_filename_component(name ${test_source} NAME_WE)
|
2018-01-20 00:20:55 +01:00
|
|
|
set(tests ${tests} ${name})
|
2018-01-19 18:31:32 +01:00
|
|
|
|
|
|
|
add_executable(${name} ${test_source})
|
|
|
|
target_link_libraries(${name} resply-static)
|
|
|
|
set_target_properties(${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
|
|
|
|
endforeach ()
|
|
|
|
|
2018-01-20 00:20:55 +01:00
|
|
|
string(STRIP "${tests}" tests)
|
2018-01-19 18:31:32 +01:00
|
|
|
|
|
|
|
add_custom_target(
|
|
|
|
tests
|
2018-01-31 11:48:05 +01:00
|
|
|
COMMAND for t in ${tests}\; do printf %s \"$$t: \"\; ./tests/$$t && echo success || echo failed\; done
|
2018-01-19 18:31:32 +01:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
DEPENDS ${tests}
|
|
|
|
COMMENT "Running tests")
|
|
|
|
|
|
|
|
|
|
|
|
# documentation
|
|
|
|
find_package(Doxygen)
|
|
|
|
if (BUILD_DOC AND DOXYGEN_FOUND)
|
|
|
|
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
|
|
|
|
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
|
|
|
|
|
|
|
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
|
|
|
|
|
|
|
|
add_custom_target(
|
|
|
|
doc
|
|
|
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
COMMENT "Generating API documentation with Doxygen"
|
|
|
|
VERBATIM)
|
|
|
|
else ()
|
|
|
|
message("Doxygen need to be installed to generate the doxygen documentation")
|
|
|
|
endif ()
|