-
Notifications
You must be signed in to change notification settings - Fork 12
/
Magic.cmake
143 lines (136 loc) · 5.83 KB
/
Magic.cmake
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
133
134
135
136
137
138
139
140
141
142
143
if(CMAKE_BUILD_TYPE STREQUAL Release)
message("~~~~~~~~~~~~~~Release~~~~~~~~~~~~~~~")
if(WIN32 AND NOT MINGW)
message("~~~~~~~~~WIN32 Configuration~~~~~~~~")
elseif(WIN32 AND MINGW)
message("~~~~~~~~~MINGW Configuration~~~~~~~~")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
elseif(UNIX AND ANDROID)
message("~~~~~~~~~ANDROID Configuration~~~~~~~~~")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
elseif(UNIX AND NOT ANDROID)
message("~~~~~~~~~UNIX Configuration~~~~~~~~~")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors")
if(Sanitize STREQUAL leak)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
elseif(Sanitize STREQUAL address)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
elseif(Sanitize STREQUAL thread)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -pie -g")
elseif(Sanitize STREQUAL undefined)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif()
endif()
else()
message("~~~~~~~~~~~~~~~Debug~~~~~~~~~~~~~~~~")
if(WIN32 AND NOT MINGW)
message("~~~~~~~~~WIN32 Configuration~~~~~~~~")
elseif(WIN32 AND MINGW)
message("~~~~~~~~~MINGW Configuration~~~~~~~~")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
elseif(UNIX AND ANDROID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
elseif(UNIX AND NOT ANDROID)
message("~~~~~~~~~UNIX Configuration~~~~~~~~~")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfatal-errors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
if(Sanitize STREQUAL leak)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
elseif(Sanitize STREQUAL address)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
elseif(Sanitize STREQUAL thread)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -pie -g")
elseif(Sanitize STREQUAL undefined)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
endif()
endif()
endif()
set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS})
# Platform
if(WIN32)
#WIN32 Library
set(PLATFORM
ws2_32
mswsock
)
elseif(UNIX)
#UNIX Library
set(PLATFORM
)
endif()
# ThirdParty
find_package(ZLIB QUIET)
if(ZLIB_FOUND)
add_definitions(-DZLIB)
message("Found ZLib Library")
set(THIRDPARTY ${THIRDPARTY} ZLIB::ZLIB)
else()
find_library(Z z)
find_path(ZLIB zlib.h)
if(NOT ${Z} STREQUAL "Z-NOTFOUND" AND NOT ${ZLIB} STREQUAL "ZLIB-NOTFOUND")
add_definitions(-DZLIB)
include_directories(${ZLIB})
message("Found ZLib Library")
set(THIRDPARTY ${THIRDPARTY} ${Z})
endif()
endif()
find_package(OpenSSL QUIET)
if(OpenSSL_FOUND)
add_definitions(-DOPENSSL)
message("Found OpenSSL Library")
set(THIRDPARTY ${THIRDPARTY} OpenSSL::Crypto OpenSSL::SSL)
else()
find_library(SSL ssl)
find_library(CRYPTO crypto)
find_path(OPENSSL openssl/conf.h)
if(NOT ${SSL} STREQUAL "SSL-NOTFOUND" AND NOT ${CRYPTO} STREQUAL "CRYPTO-NOTFOUND")
add_definitions(-DOPENSSL)
include_directories(${OPENSSL})
message("Found OpenSSL Library")
set(THIRDPARTY ${THIRDPARTY} ${SSL} ${CRYPTO})
endif()
endif()
if(MySql STREQUAL ON)
add_definitions(-DMYSQLDB)
set(THIRDPARTY ${THIRDPARTY} mariadbclient)
endif()
set(MAGIC_DEPEND_LIBRARY ${PLATFORM} ${THIRDPARTY})