-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
302 lines (258 loc) · 9.13 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
project(libotp)
find_package(PythonLibs)
if (NOT PYTHONLIBS_FOUND)
message(FATAL_ERROR "Python libs not found.")
endif()
find_package(PythonInterp)
if(NOT PYTHONINTERP_FOUND)
message(FATAL_ERROR "Python interpreter not found.")
endif()
if(PYTHON_VERSION_MAJOR EQUAL 2)
set(PYTHON2_EXECUTABLE "${PYTHON_EXECUTABLE}")
else()
set(PYTHON2_EXECUTABLE python2)
endif()
### Panda3D dir ###
SET(PANDA_DIR "D:\\Panda3D-1.10.0" CACHE STRING "Panda3D directory.")
### OpenSSL dir ###
SET(OPEN_SSL_DIR "C:\\openssl" CACHE STRING "OpenSSL directory.")
# Toggle for Themdia use
option(WANT_THEMDIA "If this is TRUE/On Themdia will be used if possible.")
# Toggle for Static Library
option(STATIC_LIB "If this is TRUE, The compiler will output a static library instead of a shared one.")
# Toggle for Themdia use
option(PANDA_OPTIMIZED "Set this to true if NDEBUG was not defined when Panda was compiled! (NDEBUG will not be defined on high optimization levels.)")
### Themdia dir (Optional)###
SET(THEMDIA_DIR "C:\\Program Files\\Themida" CACHE STRING "Themdia directory. (Optional)")
execute_process(COMMAND ${PYTHON2_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/run_interrogate.py" "${PANDA_DIR}")
### Define core components ###
set(BASE_FILES
src/base/config_libotp.h
src/base/config_libotp.cxx
src/base/config_libotp.N
src/base/util.h
)
set(COMPONENTS_FILES
src/components/AESKeyScrambler.cxx
src/components/AESKeyScrambler.h
src/components/AESKeyStore.cxx
src/components/AESKeyStore.h
src/components/CMoverGroup.cxx
src/components/CMoverGroup.h
src/components/CMover.cxx
src/components/CMover.h
src/components/CImpulse.cxx
src/components/CImpulse.h
src/components/CRandom.cxx
src/components/CPyObjectHandler.cxx
src/components/CPyObjectHandler.h
src/components/CRandom.h
)
set(NAMETAG_FILES
src/nametag/ChatBalloon.cxx
src/nametag/ChatBalloon.h
src/nametag/NametagGlobals.cxx
src/nametag/NametagGlobals.h
src/nametag/NametagGroup.cxx
src/nametag/NametagGroup.h
src/nametag/Nametag.cxx
src/nametag/Nametag.h
src/nametag/Nametag2d.cxx
src/nametag/Nametag2d.h
src/nametag/Nametag3d.cxx
src/nametag/Nametag3d.h
src/nametag/NametagFloat2d.cxx
src/nametag/NametagFloat2d.h
src/nametag/NametagFloat3d.cxx
src/nametag/NametagFloat3d.h
)
set(MARGINS_FILES
src/margins/ClickablePopup.cxx
src/margins/ClickablePopup.h
src/margins/MarginCell.cxx
src/margins/MarginCell.h
src/margins/MarginManager.cxx
src/margins/MarginManager.h
src/margins/MarginPopup.cxx
src/margins/MarginPopup.h
src/margins/PopupMouseWatcherRegion.cxx
src/margins/PopupMouseWatcherRegion.h
src/margins/WhisperPopup.cxx
src/margins/WhisperPopup.h
)
set(SETTINGS_FILES
src/settings/Settings.cxx
src/settings/Settings.h
)
set(IGATE_FILES
src/base_igate.cxx
src/components_igate.cxx
src/nametag_igate.cxx
src/margins_igate.cxx
src/settings_igate.cxx
src/libotp_module.cxx
)
include_directories(src/base)
include_directories(src/nametag)
include_directories(src/margins)
include_directories(src/settings)
include_directories(src/secure)
include_directories(src/components)
include_directories(${PANDA_DIR}/include)
include_directories(${OPEN_SSL_DIR}/include)
include_directories(${PYTHON_INCLUDE_DIR})
link_directories(${PANDA_DIR}/lib)
link_directories(${OPEN_SSL_DIR}/lib)
set(LIBPFX "")
if(WIN32)
set(LIBPFX "lib")
add_definitions(/wd4275)
add_definitions(/EHa)
add_definitions(/GF)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
execute_process(COMMAND "${CMAKE_C_COMPILER}" -dumpversion OUTPUT_VARIABLE GCC_VERSION)
message(STATUS "GCC Version: ${GCC_VERSION}")
if(GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)
add_definitions(-std=c++11) # Enable the new C++ standard
else()
add_definitions(-std=c++0x) # Enable the new C++ standard
endif()
endif()
add_definitions(-DBUILDING_LIBOTP)
add_definitions(/Ob1)
set(PANDA_LIBS
${LIBPFX}p3framework
${LIBPFX}panda
${LIBPFX}pandafx
${LIBPFX}pandaexpress
${LIBPFX}p3dtool
${LIBPFX}p3dtoolconfig
${LIBPFX}p3direct
${LIBPFX}p3pandatoolbase
)
set(OPEN_SSL_LIBS
libeay32
ssleay32
)
set(THEMDIA_LIBS
)
if(WIN32)
LIST(APPEND OPEN_SSL_LIBS crypt32)
LIST(APPEND OPEN_SSL_LIBS psapi)
endif()
# Add p3interrogatedb, if it exists
find_library(HAVE_P3INTERROGATEDB
${LIBPFX}p3interrogatedb
HINTS ${PANDA_DIR}/lib)
if (HAVE_P3INTERROGATEDB)
message(STATUS "libp3interrogatedb found")
LIST(APPEND PANDA_LIBS ${LIBPFX}p3interrogatedb)
else()
message(STATUS "libp3interrogatedb not found")
endif()
# Add Themdia, if it exists
find_library(HAVE_THEMDIA
SecureEngineSDK32
HINTS ${THEMDIA_DIR}/ThemidaSDK/Lib/COFF)
if (HAVE_THEMDIA)
message(STATUS "Themdia found!")
LIST(APPEND THEMDIA_LIBS SecureEngineSDK32)
add_definitions(-DHAVE_THEMDIA)
include_directories(${THEMDIA_DIR}/ThemidaSDK/Include/C)
link_directories(${THEMDIA_DIR}/ThemidaSDK/Lib/COFF)
else()
message(STATUS "Themdia (Optional) was NOT found!")
endif()
# Add p3framework, if it exists
find_library(HAVE_P3FRAMEWORK
${LIBPFX}p3framework
HINTS ${PANDA_DIR}/lib)
if (HAVE_P3FRAMEWORK)
message(STATUS "libp3framework found")
LIST(APPEND PANDA_LIBS ${LIBPFX}p3framework)
else()
message(STATUS "libp3framework not found")
endif()
if (WANT_THEMDIA)
# Add Themdia, if it exists
find_library(HAVE_THEMDIA
SecureEngineSDK32
HINTS ${THEMDIA_DIR}/ThemidaSDK/Lib/COFF)
if (HAVE_THEMDIA)
message(STATUS "Themdia found!")
LIST(APPEND THEMDIA_LIBS SecureEngineSDK32)
add_definitions(-DHAVE_THEMDIA)
include_directories(${THEMDIA_DIR}/ThemidaSDK/Include/C)
link_directories(${THEMDIA_DIR}/ThemidaSDK/Lib/COFF)
else()
message(STATUS "Themdia (Optional) was NOT found!")
endif()
else()
set(HAVE_THEMDIA OFF)
endif()
if (PANDA_OPTIMIZED)
add_definitions(-DPANDA_OPTIMIZED)
add_definitions(-DNDEBUG)
add_definitions(/O2)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /GL")
string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO}")
set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /GL")
set(CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL "${CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL} /LTCG")
set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /LTCG")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /LTCG")
else()
add_definitions(-D_DEBUG)
endif()
if (STATIC_LIB)
add_library(libotp STATIC
${BASE_FILES}
${COMPONENTS_FILES}
${NAMETAG_FILES}
${MARGINS_FILES}
${SETTINGS_FILES}
${SECURE_FILES}
${IGATE_FILES}
)
SET_TARGET_PROPERTIES(libotp PROPERTIES SUFFIX ".lib")
else()
add_library(libotp SHARED
${BASE_FILES}
${COMPONENTS_FILES}
${NAMETAG_FILES}
${MARGINS_FILES}
${SETTINGS_FILES}
${SECURE_FILES}
${IGATE_FILES}
)
if(WIN32)
SET_TARGET_PROPERTIES(libotp PROPERTIES SUFFIX ".pyd")
endif()
endif()
if (HAVE_THEMDIA)
target_link_libraries(libotp ${PANDA_LIBS} ${THEMDIA_LIBS} ${OPEN_SSL_LIBS} ${PYTHON_LIBRARY})
else()
target_link_libraries(libotp ${PANDA_LIBS} ${OPEN_SSL_LIBS} ${PYTHON_LIBRARY})
endif()
add_custom_command(TARGET libotp
PRE_BUILD
COMMAND ${PYTHON2_EXECUTABLE} "${CMAKE_SOURCE_DIR}/src/run_interrogate.py" "${PANDA_DIR}"
COMMENT "Interrogate")
### Setup source groups and defines for configurables ###
source_group("base" FILES ${BASE_FILES})
source_group("components" FILES ${COMPONENTS_FILES})
source_group("nametag" FILES ${NAMETAG_FILES})
source_group("margins" FILES ${MARGINS_FILES})
source_group("settings" FILES ${SETTINGS_FILES})
source_group("secure" FILES ${SECURE_FILES})
source_group("interrogate_files" FILES ${IGATE_FILES})