This repository has been archived by the owner on Oct 24, 2022. It is now read-only.
forked from nekipelov/redisclient
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
87 lines (71 loc) · 2.49 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# CMake script for RedisClient
############################################################
cmake_minimum_required(VERSION 3.2)
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.23.101.tar.gz"
SHA1 "ccb234f5ea9dc89989b28164cb38cb4ebb04237c"
)
# Project and Versioning
project(RedisClient)
set(VERSION_MAJOR 1 CACHE STRING "Project major version number.")
set(VERSION_MINOR 0 CACHE STRING "Project minor version number.")
set(VERSION_PATCH 0 CACHE STRING "Project patch version number.")
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
mark_as_advanced(VERSION_MAJOR VERSION_MINOR VERSION_PATCH VERSION)
# Include utility functions
include(cmake/Utils.cmake)
# Set the C++11 standard
set(CMAKE_CXX_STANDARD 11 CACHE STRING "Default C++ standard")
# Build options
option(ADDRESS_SANITIZER "Enable address sanitizer" OFF)
option(BENCHMARK "Build benmarks" OFF)
option(BUILD_SHARED_LIBS "Whether to build shared libraries" ON)
option(BUILD_TEST "Whether to build the unit tests" ON)
option(BUILD_EXAMPLES "Whether to build the examples" ON)
option(HEADER_ONLY "Whether to build in header-only mode" OFF)
# Default to Release mode
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
# Optionally add the address sanitizer
if (ADDRESS_SANITIZER)
message(STATUS "Build with address-sanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_LD_FLAGS "-fsanitize=address")
endif()
if(HUNTER_ENABLED)
hunter_add_package(Boost COMPONENTS system)
find_package(Boost CONFIG REQUIRED system)
else()
if (MSVC)
add_definitions(-DBOOST_ALL_NO_LIB)
endif()
if (NOT Boost_USE_STATIC_LIBS)
add_definitions(-DBOOST_ALL_DYN_LINK)
endif()
# Find all of our dependencies
include(cmake/Dependencies.cmake)
endif()
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od -DDEBUG ")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 -DNDEBUG")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra -pthread")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3 -DDEBUG ")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG")
endif()
add_subdirectory(src)
if (BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if (BUILD_TEST)
enable_testing()
add_subdirectory(tests)
endif()
if (BENCHMARK)
add_subdirectory(benchmarks)
endif()
include(cmake/Install.cmake)