forked from tindy2013/stairspeedtest-reborn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
116 lines (97 loc) · 3.3 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
project(stairspeedtest LANGUAGES CXX)
cmake_minimum_required(VERSION 3.4)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include/")
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF()
SET(CMAKE_CXX_STANDARD 17)
ADD_DEFINITIONS(-Wall -Wextra -Wno-unused-parameter -Wno-unused-result)
OPTION(USING_STD_REGEX "Use std::regex from C++ library instead of PCRE2." OFF)
INCLUDE(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES(
"
#include<string>
void main(){std::to_string(0);}
" HAVE_TO_STRING)
INCLUDE(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(MSG_NOSIGNAL "sys/socket.h" HAVE_MSG_NOSIGNAL)
IF(APPLE)
ADD_DEFINITIONS(-D_MACOS)
ENDIF()
IF(HAVE_TO_STRING)
ADD_DEFINITIONS(-DHAVE_TO_STRING)
ENDIF()
IF(HAVE_MSG_NOSIGNAL)
ADD_DEFINITIONS(-DHAVE_MSG_NOSIGNAL)
ENDIF()
ADD_EXECUTABLE(stairspeedtest
src/confbuild.cpp
src/geoip.cpp
src/logger.cpp
src/main.cpp
src/md5.cpp
src/misc.cpp
src/multithread_test.cpp
src/ntt.cpp
src/printmsg.cpp
src/processes.cpp
src/renderer.cpp
src/rulematch.cpp
src/socket.cpp
src/speedtestutil.cpp
src/tcping.cpp
src/webget.cpp
src/webgui_wrapper.cpp
src/webserver_libevent.cpp)
INCLUDE_DIRECTORIES(src)
LINK_DIRECTORIES(${CMAKE_SOURCE_DIR})
FIND_PACKAGE(PkgConfig REQUIRED)
SET(THREADS_PREFER_PTHREAD_FLAG ON)
FIND_PACKAGE(Threads REQUIRED)
TARGET_LINK_LIBRARIES(stairspeedtest ${CMAKE_THREAD_LIBS_INIT})
PKG_CHECK_MODULES(LIBEVENT libevent REQUIRED)
FIND_PATH(LIBEVENT_INCLUDE_DIR NAMES event.h PATHS ${LIBEVENT_INCLUDE_DIRS})
FIND_LIBRARY(LIBEVENT_LIBRARY NAMES event PATHS ${LIBEVENT_LIBRARY_DIRS})
LINK_DIRECTORIES(${LIBEVENT_LIBRARY_DIRS})
INCLUDE_DIRECTORIES(${LIBEVENT_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(stairspeedtest ${LIBEVENT_LIBRARY})
FIND_PACKAGE(CURL 7.54.0 REQUIRED)
LINK_DIRECTORIES(${CURL_LIBRARY_DIRS})
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(stairspeedtest CURL::libcurl)
ADD_DEFINITIONS(-DCURL_STATICLIB)
FIND_PACKAGE(OpenSSL 1.1.0 REQUIRED)
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(stairspeedtest ${OPENSSL_LIBRARIES})
FIND_PACKAGE(Rapidjson REQUIRED)
INCLUDE_DIRECTORIES(${RAPIDJSON_INCLUDE_DIRS})
FIND_PACKAGE(PNG REQUIRED)
INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(stairspeedtest ${PNG_LIBRARIES})
ADD_DEFINITIONS(${PNG_DEFINITIONS})
FIND_PACKAGE(Freetype REQUIRED)
INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIR_freetype2})
TARGET_LINK_LIBRARIES(stairspeedtest ${FREETYPE_LIBRARIES})
FIND_PACKAGE(PNGwriter 0.7.0 REQUIRED)
INCLUDE_DIRECTORIES(${PNGwriter_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(stairspeedtest PNGwriter::PNGwriter)
PKG_CHECK_MODULES(YAML_CPP yaml-cpp REQUIRED)
FIND_LIBRARY(YAML_CPP_LIBRARY NAMES yaml-cpp yaml-cppd PATHS ${YAML_CPP_LIBRARY_DIRS})
LINK_DIRECTORIES(${YAML_CPP_LIBRARY_DIRS})
INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(stairspeedtest ${YAML_CPP_LIBRARY})
IF(USING_STD_REGEX STREQUAL "ON")
ADD_DEFINITIONS(-DUSE_STD_REGEX)
ELSE()
FIND_PACKAGE(PCRE2 REQUIRED)
INCLUDE_DIRECTORIES(${PCRE2_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(stairspeedtest ${PCRE2_LIBRARY})
ADD_DEFINITIONS(-DPCRE2_STATIC)
ENDIF()
IF(WIN32)
TARGET_LINK_LIBRARIES(stairspeedtest wsock32 ws2_32)
ELSE()
INCLUDE(GNUInstallDirs)
INSTALL(TARGETS stairspeedtest DESTINATION ${CMAKE_INSTALL_BINDIR})
ENDIF()