-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
132 lines (118 loc) · 4.43 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
cmake_minimum_required(VERSION 3.13.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(Mokaccino)
file(GLOB_RECURSE sources "src/*.cpp")
file(GLOB_RECURSE tests "tests/*.cpp")
#options
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_DEBUG OFF)
set(OPENSSL_USE_STATIC_LIBS OFF)
#packages
find_package(Boost COMPONENTS thread chrono program_options REQUIRED)
find_package(portaudio REQUIRED)
find_package(Opus REQUIRED)
find_package(OpenSSL REQUIRED)
if(OPENSSL_FOUND)
include_directories(${OPENSSL_INCLUDE_DIR})
link_libraries(OpenSSL::Crypto)
else()
add_compile_definitions(NO_OPENSSL)
endif()
#debug
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(_DEBUG)
endif()
#definitions
add_compile_definitions(_WIN32_WINNT=0x0601)
option(DISABLE_ANSI_ESCAPE "If enabled the output text won't use ANSI escape sequences" OFF)
if(DISABLE_ANSI_ESCAPE)
message(STATUS "Disabling output colors")
add_compile_definitions(NO_ANSI_ESCAPE)
endif()
option(DISABLE_TERMINAL_UI "If enabled the output text won't use ANSI to behave like a terminal user interface" OFF)
if(DISABLE_TERMINAL_UI OR DISABLE_ANSI_ESCAPE)
message(STATUS "Disabling terminal UI")
add_compile_definitions(NO_TERMINAL_UI)
endif()
option(DISABLE_CURSES "If enabled then PDCurses or NCurses will not be used" OFF)
if(NOT DISABLE_CURSES)
if(WIN32)
set(PDCurses_INCLUDE_DIRS "C:/Program Files/PDCurses/include")
set(PDCurses_LIBRARIES "C:/Program Files/PDCurses/lib/PDCurses.lib")
if(EXISTS ${PDCurses_LIBRARIES})
include_directories(${PDCurses_INCLUDE_DIRS})
link_libraries(${PDCurses_LIBRARIES})
message(STATUS "Found PDCurses at \"C:/Program Files/PDCurses\"")
else()
message(STATUS "Could NOT find PDCurses")
add_compile_definitions(NO_CURSES)
endif()
else()
find_package(Curses)
if(CURSES_FOUND)
include_directories(${CURSES_INCLUDE_DIRS})
link_libraries(${CURSES_LIBRARIES})
else()
add_compile_definitions(NO_CURSES)
endif()
endif()
else()
message(STATUS "Disabling CURSES")
add_compile_definitions(NO_CURSES)
endif()
option(DISABLE_CLOCK "If enabled the output will no more include a clock" OFF)
if(DISABLE_CLOCK)
add_compile_definitions(NO_CLOCK)
message(STATUS "Disabling clock")
endif()
#git tag as version
execute_process(COMMAND git describe --tags
TIMEOUT 5
OUTPUT_VARIABLE GIT_TAG_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(GIT_TAG_VERSION)
message(STATUS "Building with git tag ${GIT_TAG_VERSION}")
add_compile_definitions(BUILD_TAG_VERSION=\"${GIT_TAG_VERSION}\")
else()
message(WARNING "Error finding git tag, defaulting to version v1.0.0")
add_compile_definitions(BUILD_TAG_VERSION=\"v1.0.0\")
endif()
option(ECDSA "Use ECDSA instead of RSA to sign messages" ON)
if(ECDSA)
message(STATUS "Using signature algorithm ECDSA (521b)")
add_compile_definitions(USE_EC_AUTHENTICATION)
else()
message(STATUS "Using signature algorithm RSA (3072b)")
endif()
option(LOW_LEVEL_DEBUG "If enabled the logger will log every udp packet sent or received" OFF)
if(LOW_LEVEL_DEBUG)
message(STATUS "Enabling low level debug log")
add_compile_definitions(LL_DEBUG)
else()
message(STATUS "Disabling low level debug log")
endif()
#link and include
include_directories(${Boost_INCLUDE_DIRS})
link_libraries(${Boost_LIBRARIES} portaudio_static Opus::opus)
add_executable(Mokaccino ${sources})
#testing
enable_testing()
set(STARTING_TEST_PORT 23235)
foreach(test IN ITEMS ${tests})
get_filename_component(TEST_NAME ${test} NAME_WE)
message(STATUS "Adding test " ${TEST_NAME})
add_executable(test-${TEST_NAME} ${sources} ${test})
target_compile_definitions(test-${TEST_NAME} PUBLIC _TEST PUBLIC NO_ANSI_ESCAPE NO_CURSES)
target_include_directories(test-${TEST_NAME} PUBLIC "src")
add_test(NAME test-${TEST_NAME} COMMAND $<TARGET_FILE:test-${TEST_NAME}> --port ${STARTING_TEST_PORT})
math(EXPR STARTING_TEST_PORT "${STARTING_TEST_PORT}+1" OUTPUT_FORMAT DECIMAL)
set(TESTS ${TESTS} test-${TEST_NAME})
endforeach()
set_tests_properties(${TESTS} PROPERTIES TIMEOUT 10)