-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
85 lines (73 loc) · 2.52 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
cmake_minimum_required (VERSION 3.7.2)
project (beastquest CXX)
# Set compiler if CXX is defined
if($ENV{CXX})
set(CMAKE_CXX_COMPILER $ENV{CXX})
endif($ENV{CXX})
# Set standard
set (CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set build type to release by default
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)
# Enable warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# Generate code coverage
if(BeastQuest_TEST_COVERAGE)
set(CMAKE_BUILD_TYPE COVERAGE)
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(COVERAGE_FLAG "--coverage")
endif(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS_COVERAGE "-g -O0 ${COVERAGE_FLAG} -fprofile-arcs -ftest-coverage")
endif(BeastQuest_TEST_COVERAGE)
# Set library variables
set(BeastQuest_LIBRARIES ${PROJECT_NAME} CACHE INTERNAL "")
# Build dependencies if specified
if(BeastQuest_BUILD_DEPS)
set(BeastQuest_BUILD_BOOST ON)
set(BeastQuest_BUILD_OPENSSL ON)
endif(BeastQuest_BUILD_DEPS)
if(BeastQuest_BUILD_BOOST OR BeastQuest_BUILD_OPENSSL)
add_subdirectory(deps)
endif(BeastQuest_BUILD_BOOST OR BeastQuest_BUILD_OPENSSL)
# Set Boost options if handling Boost
if(BeastQuest_BUILD_BOOST)
# Use static libs by default when handling Boost
if(NOT DEFINED Boost_USE_STATIC_LIBS)
set(Boost_USE_STATIC_LIBS ON)
endif(NOT DEFINED Boost_USE_STATIC_LIBS)
set(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/deps/boost/")
set(BOOST_INCLUDEDIR "${BOOST_ROOT}")
set(BOOST_LIBRARYDIR "${BOOST_ROOT}/build/lib")
endif(BeastQuest_BUILD_BOOST)
find_package(Boost COMPONENTS system REQUIRED)
# Set OpenSSL options if handling OpenSSL
if(BeastQuest_BUILD_OPENSSL)
# Use static libs by default on Windows and Apple when handling OpenSSL
if(WIN32 OR APPLE AND NOT DEFINED OPENSSL_USE_STATIC_LIBS)
set(OPENSSL_USE_STATIC_LIBS TRUE)
endif(WIN32 OR APPLE AND NOT DEFINED OPENSSL_USE_STATIC_LIBS)
set(OPENSSL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps/openssl")
set(OPENSSL_INCLUDE_DIR "${OPENSSL_ROOT_DIR}/include")
endif(BeastQuest_BUILD_OPENSSL)
find_package(OpenSSL REQUIRED)
# Set include directories
set(BeastQuest_INCLUDEDIR
"${CMAKE_CURRENT_SOURCE_DIR}/include"
CACHE
INTERNAL
""
)
include_directories(
${BeastQuest_INCLUDEDIR}
${BOOST_INCLUDEDIR}
${OPENSSL_INCLUDE_DIR}
)
# Build BeastQuest lib
add_subdirectory(src)
# Build tests if enabled
if(BeastQuest_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif(BeastQuest_BUILD_TESTS)