-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
132 lines (101 loc) · 3.6 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 2.6)
project(paygateway)
set(PROJECT_MAJOR_VERSION 1)
set(PROJECT_MINOR_VERSION 0)
set(PROJECT_PATCH_VERSION 0)
set (PROJECT_VERSION ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION})
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
INCLUDE (CheckFunctionExists)
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckTypeSize)
CHECK_FUNCTION_EXISTS(alloca C_ALLOCA)
CHECK_FUNCTION_EXISTS(memcmp HAVE_MEMCMP)
CHECK_FUNCTION_EXISTS(strndup HAVE_STRNDUP)
CHECK_FUNCTION_EXISTS(strnlen HAVE_STRNLEN)
CHECK_INCLUDE_FILES(alloca.h HAVE_ALLOCA_H)
CHECK_INCLUDE_FILES(strings.h HAVE_STRINGS_H)
CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H)
CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILES(sys/times.h HAVE_SYS_TIMES_H)
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILES(memory.h HAVE_MEMORY_H)
CHECK_INCLUDE_FILES(stdarg.h HAVE_STDARG_PROTOTYPES)
CHECK_INCLUDE_FILES(sys/tree.h HAVE_SYS_TREE)
CHECK_INCLUDE_FILES(sys/queue.h HAVE_SYS_QUEUE)
CHECK_INCLUDE_FILES(sys/un.h HAVE_SYS_UN)
CHECK_TYPE_SIZE("int" SIZEOF_INT)
CHECK_TYPE_SIZE("long" SIZEOF_LONG)
CHECK_TYPE_SIZE("short" SIZEOF_SHORT)
if (NOT HAVE_STRNDUP)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_STRNDUP")
endif(NOT HAVE_STRNDUP)
if (NOT HAVE_STRNLEN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_STRNLEN")
endif(NOT HAVE_STRNLEN)
if (NOT HAVE_SYS_UN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_SYS_UN")
endif(NOT HAVE_SYS_UN)
# -DEVHTP_DISABLE_SSL:STRING=ON
OPTION(EVHTP_DISABLE_SSL "Disable ssl support" OFF)
# -DEVHTP_DISABLE_EVTHR:STRING=ON
OPTION(EVHTP_DISABLE_EVTHR "Disable evthread support" OFF)
# -DEVHTP_DISABLE_REGEX:STRING=ON
OPTION(EVHTP_DIABLE_REGEX "Disable regex support" OFF)
# -DEVHTP_BUILD_SHARED:STRING=ON
OPTION(EVHTP_BUILD_SHARED "Build shared library too" OFF)
# -DEVHTP_USE_DEFER_ACCEPT:STRING=ON
OPTION(EVHTP_USE_DEFER_ACCEPT "Enable TCP_DEFER_ACCEPT" OFF)
if (EVHTP_USE_DEFER_ACCEPT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_DEFER_ACCEPT")
endif(EVHTP_USE_DEFER_ACCEPT)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
include(BaseConfig)
message("Build Type: ${CMAKE_BUILD_TYPE}")
message("Std CFLAGS: ${CMAKE_C_FLAGS}")
message("Dbg CFLAGS: ${CMAKE_C_FLAGS_DEBUG}")
message("Rel CFLAGS: ${CMAKE_C_FLAGS_RELEASE}")
find_package(LibEvent REQUIRED)
find_package(OpenSSL)
find_package(libevhtp REQUIRED)
find_package(Protobuf REQUIRED)
find_path(LIBEVENT_INCLUDE_DIR event2/event.h REQUIRED)
if (NOT OPENSSL_FOUND)
message("Diabling SSL")
set (EVHTP_DISABLE_SSL ON)
set (OPENSSL_CRYPTO_LIBRARY "")
set (OPENSSL_INCLUDE_DIR "")
set (OPENSSL_LIBRARIES "")
set (LIBEVENT_OPENSSL_LIBRARY "")
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${OPENSSL_INCLUDE_DIR}
${LIBEVENT_INCLUDE_DIR}
${PROTOBUF_INCLUDE_DIRS}
)
set(PAYGATEWAY_EXTERNAL_LIBS
${LIBEVENT_LIBRARY}
${LIBEVENT_PTHREADS_LIBRARY}
${LIBEVENT_OPENSSL_LIBRARY}
${OPENSSL_LIBRARIES}
${LIBEVHTP_LIBRARY}
${LIBEVENT_LIBRARY}
${PROTOBUF_LIBRARIES}
)
if (NOT ${LIBEVENT_PTHREADS_FOUND})
set(EVHTP_DISABLE_EVTHR 1)
endif(NOT ${LIBEVENT_PTHREADS_FOUND})
if (NOT ${LIBEVENT_OPENSSL_FOUND})
set (EVHTP_DISABLE_SSL 1)
endif(NOT ${LIBEVENT_OPENSSL_FOUND})
if (NOT EVHTP_DISABLE_EVTHR)
set (PAYGATEWAY_EXTERNAL_LIBS ${PAYGATEWAY_EXTERNAL_LIBS} pthread)
endif(NOT EVHTP_DISABLE_EVTHR)
if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNDEBUG")
endif (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
if (EVHTP_DISABLE_SSL)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DEVHTP_DISABLE_SSL")
endif()
ADD_SUBDIRECTORY(src)