-
Notifications
You must be signed in to change notification settings - Fork 142
/
CMakeLists.txt
343 lines (269 loc) · 10.7 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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
cmake_minimum_required(VERSION 3.6)
project (gkENGINE)
if (APPLE)
MESSAGE ("This is build for ios, use static lib")
set(CoreLinkType STATIC)
else()
MESSAGE ("This is build for windows, use dynamic lib")
set(CoreLinkType SHARED)
# add warning mute
add_compile_options(/w44996)
add_compile_options(/w44819)
add_compile_options(/w44215)
add_compile_options(/w44251)
add_compile_options(/w44267)
add_compile_options(/w44005)
add_compile_options(/w44311)
add_compile_options(/w44302)
add_compile_options(/w44067)
add_compile_options(/w44566)
endif()
set(CMAKE_MACOSX_RPATH 0)
# The version number.
set (gkENGINE_VERSION_MAJOR 1)
set (gkENGINE_VERSION_MINOR 0)
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
include_directories ("${PROJECT_BINARY_DIR}")
# add the global inlude dir
include_directories ("${PROJECT_SOURCE_DIR}/code/engine/gkCommon")
include_directories ("${PROJECT_SOURCE_DIR}/code/engine/gkCommon/MathLib")
include_directories ("${PROJECT_SOURCE_DIR}/code/engine/gkCommon/serializer")
include_directories ("${PROJECT_SOURCE_DIR}/code/thirdparty")
include_directories ("${PROJECT_SOURCE_DIR}/code/thirdparty/rapidxml")
# add gkCore
FILE(GLOB sources ./code/engine/gkCore/*.cpp ./code/engine/gkCore/*/*.cpp)
add_library(gkCore ${CoreLinkType} ${sources})
target_include_directories(gkCore PRIVATE
./code/engine/gkCore/
./code/engine/gkCore/include/
)
set (EXTRA_LIBS ${EXTRA_LIBS} gkCore)
# add gkFont
FILE(GLOB sources ./code/engine/gkFont/*.cpp ./code/engine/gkFont/*/*.cpp)
add_library(gkFont ${CoreLinkType} ${sources})
target_include_directories(gkFont PRIVATE
./code/engine/gkFont/
./code/engine/gkFont/include/
./code/ThirdParty/freetype/include/
)
if (IOS)
target_link_libraries(gkFont
${PROJECT_SOURCE_DIR}/code/ThirdParty/freetype/lib/ios/Release-iphoneos/libfreetype2.a
)
elseif(OSX)
target_link_libraries(gkFont
${PROJECT_SOURCE_DIR}/code/ThirdParty/freetype/lib/ios/Release-OSX/libfreetype2.a
)
else()
target_link_libraries(gkFont
${PROJECT_SOURCE_DIR}/code/ThirdParty/freetype/lib/freetype_x64release.lib
)
endif()
set (EXTRA_LIBS ${EXTRA_LIBS} gkFont)
FILE(GLOB sources ./code/engine/gkGameFramework/*.cpp ./code/engine/gkGameFramework/*/*.cpp)
add_library(gkGameFramework ${CoreLinkType} ${sources})
target_include_directories(gkGameFramework PRIVATE
./code/engine/gkGameFramework/
./code/engine/gkGameFramework/include/
)
set (EXTRA_LIBS ${EXTRA_LIBS} gkGameFramework)
FILE(GLOB sources ./code/engine/gkGameObjectSystem/*.cpp ./code/engine/gkGameObjectSystem/*/*.cpp)
add_library(gkGameObjectSystem ${CoreLinkType} ${sources})
target_include_directories(gkGameObjectSystem PRIVATE
./code/engine/gkGameObjectSystem/
./code/engine/gkGameObjectSystem/include/
)
set (EXTRA_LIBS ${EXTRA_LIBS} gkGameObjectSystem)
# gkInput
FILE(GLOB sources ./code/engine/gkInput/*.cpp ./code/engine/gkInput/source/*.cpp)
if (APPLE)
add_library(gkInput ${CoreLinkType}
./code/engine/gkInput/source/dllmain.cpp
./code/engine/gkInput/source/gkInputManager.cpp
./code/engine/gkInput/source/gkIOSInput.cpp
./code/engine/gkInput/source/InputStableHeader.cpp
)
else()
add_library(gkInput ${CoreLinkType} ${sources})
endif()
target_include_directories(gkInput PRIVATE
./code/engine/gkInput/
./code/engine/gkInput/include/
./code/ThirdParty/DXSDK/include/
)
if (APPLE)
else()
target_link_libraries(gkInput
${PROJECT_SOURCE_DIR}/code/ThirdParty/DXSDK/lib/x64/dinput8.lib
${PROJECT_SOURCE_DIR}/code/ThirdParty/DXSDK/lib/x64/dxguid.lib
)
endif()
set (EXTRA_LIBS ${EXTRA_LIBS} gkInput)
# gkSystem
if (APPLE)
FILE(GLOB sources ./code/engine/gkCommon/*.cpp ./code/engine/gkSystem/*.cpp ./code/engine/gkSystem/*/*.cpp ./code/engine/gkSystem/*/*.mm ./code/engine/gkSystem/*/*.c)
else()
FILE(GLOB sources ./code/engine/gkCommon/*.cpp ./code/engine/gkSystem/*.cpp ./code/engine/gkSystem/*/*.cpp ./code/engine/gkSystem/*/*.c)
endif()
add_library(gkSystem ${CoreLinkType} ${sources})
target_include_directories(gkSystem PRIVATE
./code/engine/gkSystem/
./code/engine/gkSystem/include/
)
if (APPLE)
else()
target_link_libraries(gkSystem
winmm.lib
)
endif()
set (EXTRA_LIBS ${EXTRA_LIBS} gkSystem)
# Testcases
add_library(Testcases ${CoreLinkType} ./code/engine/gkTestApps/TestCases/TestCaseFramework.cpp)
target_include_directories(Testcases PRIVATE
./code/engine/gkTestApps/TestCases/
)
set (EXTRA_LIBS ${EXTRA_LIBS} Testcases)
# platfrom specific
if (APPLE)
if(IOS)
FILE(GLOB sources
./code/engine/gkRendererGL/*.cpp
./code/engine/gkRendererGL/RenderRes/*.cpp
./code/engine/gkRendererGL/Platform/IOS/*.mm
)
list(FILTER sources EXCLUDE REGEX ".*DDsTextureLoader.cpp$")
add_library(gkRendererGLES2 ${CoreLinkType} ${sources})
target_include_directories(gkRendererGLES2 PRIVATE
./code/engine/gkRendererGL/
./code/engine/gkRendererGLES2/
./code/engine/gkRendererGLES2/include/
)
target_compile_definitions(gkRendererGLES2 PRIVATE -DBUILD_OGLES2 -DRENDERER_GLES -DRENDERAPI_GLES2)
set (EXTRA_LIBS ${EXTRA_LIBS} gkRendererGLES2)
FILE(GLOB sources ./code/engine/gkLauncherUniverse/*.m ./code/engine/gkLauncherUniverse/*.mm)
add_executable(gkLauncher ${sources})
target_include_directories(gkLauncher PRIVATE
./code/engine/gkLauncherUniverse/
./code/engine/gkLauncherUniverse/include/
)
target_link_libraries(gkLauncher "-framework Foundation -framework UIKit -framework OpenGLES -framework CoreGraphics -framework QuartzCore")
target_link_libraries (gkLauncher ${EXTRA_LIBS} )
set(DEPLOYMENT_TARGET 8.0)
else()
#OSX
FILE(GLOB sources
./code/engine/gkRendererGL/*.cpp
./code/engine/gkRendererGL/RenderRes/*.cpp
./code/engine/gkRendererGL/Platform/OSX/*.cpp
./code/engine/gkRendererGL/Platform/OSX/*.mm
)
list(FILTER sources EXCLUDE REGEX ".*HwTextureLoader.cpp$")
list(FILTER sources EXCLUDE REGEX ".*glExtension.cpp$")
add_library(gkRendererGL330 ${CoreLinkType} ${sources})
target_include_directories(gkRendererGL330 PRIVATE
./code/engine/gkRendererGL/
./code/engine/gkRendererGL330/
./code/engine/gkRendererGL330/include/
./code/thirdparty/oglsdk/include/
)
target_compile_definitions(gkRendererGL330 PRIVATE -DRENDERAPI_GL330)
set (EXTRA_LIBS ${EXTRA_LIBS} gkRendererGL330)
target_link_libraries(gkRendererGL330
${PROJECT_SOURCE_DIR}/code/ThirdParty/oglsdk/lib/libglfw3.a
)
FILE(GLOB sources ./code/engine/gkLauncherMac/*.m ./code/engine/gkLauncherMac/*.mm)
add_executable(gkLauncher ${sources})
target_include_directories(gkLauncher PRIVATE
./code/engine/gkLauncherMac/
./code/engine/gkLauncherMac/include/
)
target_link_libraries(gkLauncher "-framework AppKit -framework OpenGL -framework CoreGraphics -framework IOKit -framework CoreVideo")
target_link_libraries (gkLauncher ${EXTRA_LIBS} )
#set(DEPLOYMENT_TARGET 8.0)
endif()
#file(GLOB IOSAssets ios/assets/*.png)
#list(REMOVE_ITEM IOSAssets ${CMAKE_CURRENT_SOURCE_DIR}/ios/assets/[email protected])
#list(REMOVE_ITEM IOSAssets ${CMAKE_CURRENT_SOURCE_DIR}/ios/assets/[email protected])
#file(INSTALL ${IOSAssets} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/assets)
#file(GLOB IOSAssets ios/assets/Default-568h@*.png)
#file(INSTALL ${IOSAssets} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
#set(RSRC_XIB_FILES assets/[email protected])
#set(RSRC_XIB_FILES "Launch Screen.storyboard")
#set_source_files_properties(${RSRC_XIB_FILES}
# PROPERTIES MACOSX_PACKAGE_LOCATION Resources
#)
if(CMAKE_GENERATOR STREQUAL "Xcode")
set(APP_DIR_NAME "$(TARGET_BUILD_DIR)/$(FULL_PRODUCT_NAME)")
else()
set(APP_DIR_NAME "$<TARGET_FILE_DIR:PPSSPP>")
endif()
add_custom_command(TARGET gkLauncher POST_BUILD
COMMAND rm -rf "$(TARGET_BUILD_DIR)/$(PRODUCT_NAME).app/data"
COMMAND mkdir "$(TARGET_BUILD_DIR)/$(PRODUCT_NAME).app/data"
COMMAND cp -Rf "$(BUILD_DIR)/../exec/paks" "$(TARGET_BUILD_DIR)/$(PRODUCT_NAME).app/data/paks"
)
set(MACOSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET})
if(IOS)
set_target_properties(gkLauncher PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/code/engine/gkLauncherUniverse/Info.plist"
#RESOURCE "ios/Launch Screen.storyboard"
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "iPhone/iPad"
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
XCODE_ATTRIBUTE_ENABLE_BITCODE NO
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-"
)
set_target_properties(gkLauncher
PROPERTIES
#ARCHIVE_OUTPUT_DIRECTORY "/home/xy/cmake_practice/lib/"
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${PROJECT_SOURCE_DIR}/exec/ios"
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${PROJECT_SOURCE_DIR}/exec/ios"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_SOURCE_DIR}/exec/ios"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_SOURCE_DIR}/exec/ios"
)
else()
set_target_properties(gkLauncher PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/code/engine/gkLauncherUniverse/Info.plist"
#RESOURCE "ios/Launch Screen.storyboard"
#XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}
#XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "iPhone/iPad"
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
#XCODE_ATTRIBUTE_ENABLE_BITCODE NO
#XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-"
)
endif()
else()
FILE(GLOB sources ./code/engine/gkRendererD3D9/*.cpp ./code/engine/gkRendererD3D9/*/*.cpp)
add_library(gkRendererD3D9 ${CoreLinkType} ${sources})
target_include_directories(gkRendererD3D9 PRIVATE
./code/ThirdParty/DXSDK/include
./code/engine/gkRendererD3D9/DXUT/
./code/engine/gkRendererD3D9/RenderRes/
./code/engine/gkRendererD3D9/
./code/engine/gkRendererD3D9/include/
)
target_link_libraries(gkRendererD3D9
winmm.lib
comctl32.lib
${PROJECT_SOURCE_DIR}/code/ThirdParty/DXSDK/lib/x64/d3d9.lib
${PROJECT_SOURCE_DIR}/code/ThirdParty/DXSDK/lib/x64/dxerr.lib
${PROJECT_SOURCE_DIR}/code/ThirdParty/DXSDK/lib/x64/dxguid.lib
${PROJECT_SOURCE_DIR}/code/ThirdParty/DXSDK/lib/x64/d3dx9.lib
${PROJECT_SOURCE_DIR}/code/ThirdParty/DXSDK/lib/x64/d3dx10.lib
)
FILE(GLOB sources ./code/engine/gkLauncherUniverse/*.cpp ./code/engine/gkLauncherUniverse/*/*.cpp)
add_executable(gkLauncher ${sources})
target_include_directories(gkLauncher PRIVATE
./code/engine/gkLauncherUniverse/
./code/engine/gkLauncherUniverse/include/
)
# set all targets output dir
set_target_properties(gkCore gkLauncher gkSystem gkRendererD3D9 gkInput gkGameObjectSystem gkGameFramework gkFont Testcases
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${PROJECT_SOURCE_DIR}/exec/bin64"
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${PROJECT_SOURCE_DIR}/exec/bin64"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_SOURCE_DIR}/exec/bin64"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_SOURCE_DIR}/exec/bin64"
)
endif()