forked from tindy2013/subconverter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
103 lines (87 loc) · 3.2 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
project(subconverter 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)
IF (NOT MSVC)
ADD_COMPILE_OPTIONS(-Wall -Wextra -Wno-unused-parameter -Wno-unused-result)
ELSE()
ADD_COMPILE_OPTIONS(/W4)
ENDIF()
#remove std::regex support since it is not compatible with group modifiers and slow
#OPTION(USING_STD_REGEX "Use std::regex from C++ library instead of PCRE2." OFF)
OPTION(USING_MALLOC_TRIM "Call malloc_trim after processing request to lower memory usage (Your system must support malloc_trim)." OFF)
#now using internal MD5 calculation
#OPTION(USING_MBEDTLS "Use mbedTLS instead of OpenSSL for MD5 calculation." OFF)
INCLUDE(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES(
"
#include<string>
void main(){std::to_string(0);}
" HAVE_TO_STRING)
IF(HAVE_TO_STRING)
ADD_DEFINITIONS(-DHAVE_TO_STRING)
ENDIF()
IF(USING_MALLOC_TRIM)
ADD_DEFINITIONS(-DMALLOC_TRIM)
ENDIF()
ADD_EXECUTABLE(subconverter
src/interfaces.cpp
src/logger.cpp
src/main.cpp
src/md5.cpp
src/misc.cpp
src/multithread.cpp
src/nodemanip.cpp
src/script.cpp
src/speedtestutil.cpp
src/subexport.cpp
src/templates.cpp
src/upload.cpp
src/webget.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(subconverter ${CMAKE_THREAD_LIBS_INIT})
PKG_CHECK_MODULES(LIBEVENT libevent>=2.1.10 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(subconverter ${LIBEVENT_LIBRARY})
FIND_PACKAGE(CURL 7.54.0 REQUIRED)
LINK_DIRECTORIES(${CURL_LIBRARY_DIRS})
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(subconverter CURL::libcurl)
ADD_DEFINITIONS(-DCURL_STATICLIB)
FIND_PACKAGE(Rapidjson REQUIRED)
INCLUDE_DIRECTORIES(${RAPIDJSON_INCLUDE_DIRS})
PKG_CHECK_MODULES(YAML_CPP yaml-cpp>=0.6.3 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(subconverter ${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(subconverter ${PCRE2_LIBRARY})
ADD_DEFINITIONS(-DPCRE2_STATIC)
#ENDIF()
FIND_PACKAGE(Duktape REQUIRED)
INCLUDE_DIRECTORIES(${DUKTAPE_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(subconverter ${DUKTAPE_LIBRARIES})
IF(WIN32)
TARGET_LINK_LIBRARIES(subconverter wsock32 ws2_32)
ELSE()
INCLUDE(GNUInstallDirs)
INSTALL(TARGETS subconverter DESTINATION ${CMAKE_INSTALL_BINDIR}/subconverter)
INSTALL(DIRECTORY base/ DESTINATION ${CMAKE_INSTALL_BINDIR}/subconverter FILES_MATCHING PATTERN "*")
ENDIF()