2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

428 行
12 KiB

  1. cmake_minimum_required(VERSION 3.21)
  2. project(izanagi C)
  3. set(CMAKE_C_STANDARD 11)
  4. #
  5. # Set platform
  6. #
  7. if (WIN32)
  8. # TODO set arch on target instead of generator
  9. set(PLATFORM WINDOWS)
  10. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  11. set(PROJECT_ARCH x64)
  12. add_definitions(
  13. -DIZ_WIN64
  14. )
  15. else ()
  16. set(PROJECT_ARCH x86)
  17. add_definitions(
  18. -DIZ_WIN32
  19. )
  20. endif ()
  21. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  22. set(PLATFORM MACOS)
  23. add_definitions(
  24. -DIZ_MACOS
  25. )
  26. else()
  27. set(PLATFORM UNIX)
  28. add_definitions(
  29. -DIZ_UNIX
  30. )
  31. endif ()
  32. #
  33. # Add configurations
  34. #
  35. add_definitions(
  36. -DIZ_APP_NAME="Izanagi"
  37. -DIZ_APP_DESCRIPTION="Run and gun game"
  38. -DIZ_APP_SERVER_DESCRIPTION="Dedicated server"
  39. -DIZ_PLAYERS=1
  40. #-DIZ_LOG_DATE_FUNCTION=IZ_TimerElapsed
  41. -DIZ_LOG_DATE_FUNCTION=IZ_TimerNow
  42. -DIZ_CONFIG_GAME_PATH="config-game.ini"
  43. -DIZ_CONFIG_SERVER_PATH="config-server.ini"
  44. )
  45. if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
  46. add_definitions(-DIZ_DEBUG)
  47. endif()
  48. #
  49. # Specify directories
  50. #
  51. include_directories(
  52. "${PROJECT_SOURCE_DIR}/dependencies/SDL2/include"
  53. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_image"
  54. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_image/include"
  55. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_ttf/include"
  56. "${PROJECT_SOURCE_DIR}/dependencies/minIni/dev"
  57. "${PROJECT_SOURCE_DIR}/dependencies/bdd-for-c"
  58. "${PROJECT_SOURCE_DIR}/dependencies/bdd-for-c-mocks"
  59. "${PROJECT_SOURCE_DIR}/dependencies/portmidi/pm_common"
  60. "${PROJECT_SOURCE_DIR}/dependencies/spine-runtimes/spine-c/spine-c/include"
  61. "${PROJECT_SOURCE_DIR}/dependencies/getopt-for-windows"
  62. "${PROJECT_SOURCE_DIR}/dependencies/libwebsockets/build/include"
  63. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/include"
  64. "${PROJECT_SOURCE_DIR}/dependencies/sqlite"
  65. )
  66. if (WIN32)
  67. link_directories(
  68. "${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}"
  69. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_image/lib/${PROJECT_ARCH}"
  70. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_ttf/lib/${PROJECT_ARCH}"
  71. "${PROJECT_SOURCE_DIR}/dependencies/portmidi/Release"
  72. "${PROJECT_SOURCE_DIR}/dependencies/libwebsockets/build/lib/Release"
  73. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/lib"
  74. )
  75. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  76. include_directories(
  77. /usr/local/include
  78. /usr/local/include/SDL2
  79. /usr/local/include/openssl
  80. )
  81. link_directories(
  82. /usr/local/lib
  83. )
  84. endif()
  85. #
  86. # Define executables
  87. #
  88. add_executable(
  89. game
  90. dependencies/minIni/dev/minIni.h
  91. dependencies/minIni/dev/minIni.c
  92. dependencies/getopt-for-windows/getopt.h
  93. dependencies/getopt-for-windows/getopt.c
  94. src/packages/game/output/video/IZ_video.h
  95. src/packages/game/output/video/IZ_video.c
  96. src/packages/common/IZ_common.h
  97. src/packages/game/input/IZ_action.h
  98. src/packages/game/IZ_app.h
  99. src/packages/game/IZ_app.c
  100. src/packages/game/main.c
  101. src/packages/game/input/IZ_joystick.c
  102. src/packages/game/input/IZ_joystick.h
  103. src/packages/game/input/IZ_keyboard.c
  104. src/packages/game/input/IZ_keyboard.h
  105. src/packages/config/IZ_config.c
  106. src/packages/config/IZ_config.h
  107. src/packages/game/geometry/IZ_vector2d.c
  108. src/packages/game/geometry/IZ_vector2d.h
  109. src/packages/game/geometry/IZ_rect.c
  110. src/packages/game/geometry/IZ_rect.h
  111. src/packages/game/core/IZ_object.c
  112. src/packages/game/core/IZ_object.h
  113. src/packages/game/core/IZ_creature.c
  114. src/packages/game/core/IZ_creature.h
  115. src/packages/game/core/IZ_entity.c
  116. src/packages/game/core/IZ_entity.h
  117. src/packages/game/memory/IZ_pool.c
  118. src/packages/game/memory/IZ_pool.h
  119. src/packages/game/input/IZ_input.c
  120. src/packages/game/input/IZ_input.h
  121. src/packages/game/input/IZ_midi.c
  122. src/packages/game/input/IZ_midi.h
  123. src/packages/game/data/IZ_list.c
  124. src/packages/game/data/IZ_list.h
  125. src/packages/net/svc/IZ_wsclient.c
  126. src/packages/net/svc/IZ_wsclient.h
  127. src/packages/log/IZ_intercept.c
  128. src/packages/log/IZ_intercept.h
  129. src/packages/midi/IZ_midi.c
  130. src/packages/midi/IZ_midi.h
  131. src/packages/net/core/IZ_websocket.h
  132. src/packages/net/core/IZ_websocket.c
  133. src/packages/net/IZ_net_client.c
  134. src/packages/net/IZ_net_client.h
  135. src/packages/game/IZ_app_net.c
  136. src/packages/game/IZ_app_net.h
  137. src/packages/game/IZ_app_video.c
  138. src/packages/game/IZ_app_video.h
  139. src/packages/game/IZ_subsystem.h
  140. src/packages/game/IZ_app_input.c
  141. src/packages/game/IZ_app_input.h
  142. src/packages/game/IZ_app_config.c
  143. src/packages/game/IZ_app_config.h
  144. src/packages/game/asset/IZ_asset.c
  145. src/packages/game/asset/IZ_asset.h
  146. src/packages/stdinc/IZ_string.c
  147. src/packages/stdinc/IZ_string.h
  148. src/packages/io/IZ_io.c
  149. src/packages/io/IZ_io.h
  150. src/packages/log/IZ_log.c
  151. src/packages/log/IZ_log.h
  152. src/packages/timer/IZ_timer.c
  153. src/packages/timer/IZ_timer.h
  154. src/packages/compat/IZ_windows.h
  155. src/packages/stdinc/IZ_stdlib.c
  156. src/packages/stdinc/IZ_stdlib.h
  157. )
  158. if (WIN32)
  159. target_link_libraries(
  160. game
  161. SDL2main
  162. SDL2
  163. SDL2_image
  164. SDL2_ttf
  165. portmidi
  166. libcrypto
  167. libssl
  168. websockets
  169. )
  170. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  171. target_link_libraries(
  172. game
  173. SDL2main
  174. SDL2
  175. SDL2_image
  176. SDL2_ttf
  177. portmidi
  178. crypto
  179. ssl
  180. websockets
  181. )
  182. endif()
  183. add_executable(
  184. game-test-geometry
  185. dependencies/bdd-for-c/bdd-for-c.h
  186. dependencies/bdd-for-c-mocks/bdd-for-c-mocks.h
  187. src/packages/game/geometry/IZ_rect.h
  188. src/packages/game/geometry/IZ_rect.c
  189. src/packages/game/geometry/IZ_vector2d.h
  190. src/packages/game/geometry/IZ_vector2d.c
  191. src/packages/game/geometry/geometry.test.c
  192. )
  193. add_executable(
  194. game-test-input
  195. dependencies/bdd-for-c/bdd-for-c.h
  196. dependencies/bdd-for-c-mocks/bdd-for-c-mocks.h
  197. __mocks__/dependencies/minIni/minIni.mock.h
  198. __mocks__/dependencies/SDL2/SDL_keyboard.mock.h
  199. __mocks__/dependencies/SDL2/SDL_events.mock.h
  200. __mocks__/dependencies/SDL2/SDL_joystick.mock.h
  201. __mocks__/dependencies/SDL2/SDL_stdinc.mock.h
  202. __mocks__/dependencies/portmidi/portmidi.mock.h
  203. src/packages/config/IZ_config.h
  204. src/packages/game/input/IZ_keyboard.h
  205. src/packages/game/input/IZ_keyboard.c
  206. src/packages/game/input/IZ_joystick.h
  207. src/packages/game/input/IZ_joystick.c
  208. src/packages/game/input/IZ_midi.h
  209. src/packages/game/input/IZ_midi.c
  210. src/packages/midi/IZ_midi.c
  211. src/packages/midi/IZ_midi.h
  212. src/packages/game/input/input.test.c
  213. )
  214. add_executable(
  215. game-test-output
  216. dependencies/bdd-for-c/bdd-for-c.h
  217. dependencies/bdd-for-c-mocks/bdd-for-c-mocks.h
  218. __mocks__/dependencies/minIni/minIni.mock.h
  219. __mocks__/dependencies/SDL2/SDL_stdinc.mock.h
  220. __mocks__/dependencies/SDL2/SDL_render.mock.h
  221. src/packages/config/IZ_config.h
  222. src/packages/game/output/video/IZ_video.h
  223. src/packages/game/output/video/IZ_video.c
  224. src/packages/game/output/output.test.c
  225. )
  226. add_executable(
  227. game-test-memory
  228. dependencies/bdd-for-c/bdd-for-c.h
  229. dependencies/bdd-for-c-mocks/bdd-for-c-mocks.h
  230. src/packages/timer/IZ_timer.h
  231. src/packages/timer/IZ_timer.c
  232. src/packages/stdinc/IZ_stdlib.h
  233. __mocks__/src/packages/stdinc/IZ_stdlib.mock.h
  234. src/packages/stdinc/IZ_string.h
  235. __mocks__/src/packages/stdinc/IZ_string.mock.h
  236. src/packages/log/IZ_log.h
  237. __mocks__/src/packages/log/IZ_log.mock.h
  238. src/packages/game/data/IZ_list.c
  239. src/packages/game/data/IZ_list.h
  240. src/packages/game/memory/IZ_pool.h
  241. src/packages/game/memory/IZ_pool.c
  242. src/packages/game/memory/memory.test.c
  243. )
  244. target_link_libraries(
  245. game-test-memory
  246. SDL2main
  247. SDL2
  248. )
  249. add_executable(
  250. game-test-data
  251. dependencies/bdd-for-c/bdd-for-c.h
  252. dependencies/bdd-for-c-mocks/bdd-for-c-mocks.h
  253. src/packages/stdinc/IZ_stdlib.h
  254. __mocks__/src/packages/stdinc/IZ_stdlib.mock.h
  255. src/packages/game/data/IZ_list.h
  256. src/packages/game/data/IZ_list.c
  257. src/packages/game/data/data.test.c
  258. )
  259. target_link_libraries(
  260. game-test-data
  261. SDL2main
  262. SDL2
  263. )
  264. add_executable(
  265. server
  266. dependencies/sqlite/sqlite3.h
  267. dependencies/sqlite/sqlite3.c
  268. dependencies/minIni/dev/minIni.h
  269. dependencies/minIni/dev/minIni.c
  270. src/packages/log/IZ_intercept.h
  271. src/packages/log/IZ_intercept.c
  272. src/packages/server/main.c
  273. src/packages/server/IZ_app.c
  274. src/packages/server/IZ_app.h
  275. src/packages/server/IZ_app_config.h
  276. src/packages/server/IZ_app_config.c
  277. src/packages/net/svc/IZ_wsserver.c
  278. src/packages/net/svc/IZ_wsserver.h
  279. src/packages/net/core/IZ_websocket.h
  280. src/packages/net/core/IZ_websocket.c
  281. src/packages/config/IZ_config.h
  282. src/packages/config/IZ_config.c
  283. src/packages/net/IZ_net_server.c
  284. src/packages/net/IZ_net_server.h
  285. src/packages/server/db/IZ_repo.c
  286. src/packages/server/db/IZ_repo.h
  287. src/packages/server/IZ_subsystem.h
  288. src/packages/stdinc/IZ_string.c
  289. src/packages/stdinc/IZ_string.h
  290. src/packages/io/IZ_io.c
  291. src/packages/io/IZ_io.h
  292. src/packages/log/IZ_log.c
  293. src/packages/log/IZ_log.h
  294. src/packages/timer/IZ_timer.c
  295. src/packages/timer/IZ_timer.h
  296. )
  297. if (WIN32)
  298. target_link_libraries(
  299. server
  300. SDL2main
  301. SDL2
  302. libcrypto
  303. libssl
  304. websockets
  305. )
  306. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  307. target_link_libraries(
  308. server
  309. SDL2main
  310. SDL2
  311. crypto
  312. ssl
  313. websockets
  314. )
  315. endif()
  316. add_executable(
  317. asset-inv
  318. dependencies/minIni/dev/minIni.h
  319. dependencies/minIni/dev/minIni.c
  320. src/packages/common/IZ_common.h
  321. src/packages/asset-inv/main.c
  322. )
  323. #
  324. # Add DLLs and required assets to the build directory
  325. #
  326. if (WIN32)
  327. add_custom_command(TARGET game POST_BUILD
  328. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  329. "${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}/SDL2.dll"
  330. $<TARGET_FILE_DIR:game>)
  331. add_custom_command(TARGET game POST_BUILD
  332. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  333. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_image/lib/${PROJECT_ARCH}/SDL2_image.dll"
  334. $<TARGET_FILE_DIR:game>)
  335. add_custom_command(TARGET game POST_BUILD
  336. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  337. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_ttf/lib/${PROJECT_ARCH}/SDL2_ttf.dll"
  338. $<TARGET_FILE_DIR:game>)
  339. add_custom_command(TARGET game POST_BUILD
  340. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  341. "${PROJECT_SOURCE_DIR}/dependencies/portmidi/Release/portmidi.dll"
  342. $<TARGET_FILE_DIR:game>)
  343. add_custom_command(TARGET game POST_BUILD
  344. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  345. "${PROJECT_SOURCE_DIR}/dependencies/libwebsockets/build/bin/Release/websockets.dll"
  346. $<TARGET_FILE_DIR:game>)
  347. add_custom_command(TARGET game POST_BUILD
  348. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  349. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/bin/libssl-1_1-x64.dll"
  350. $<TARGET_FILE_DIR:game>)
  351. add_custom_command(TARGET game POST_BUILD
  352. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  353. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/bin/libcrypto-1_1-x64.dll"
  354. $<TARGET_FILE_DIR:game>)
  355. add_custom_command(TARGET server POST_BUILD
  356. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  357. "${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}/SDL2.dll"
  358. $<TARGET_FILE_DIR:server>)
  359. add_custom_command(TARGET server POST_BUILD
  360. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  361. "${PROJECT_SOURCE_DIR}/dependencies/libwebsockets/build/bin/Release/websockets.dll"
  362. $<TARGET_FILE_DIR:server>)
  363. add_custom_command(TARGET server POST_BUILD
  364. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  365. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/bin/libssl-1_1-x64.dll"
  366. $<TARGET_FILE_DIR:server>)
  367. add_custom_command(TARGET server POST_BUILD
  368. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  369. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/bin/libcrypto-1_1-x64.dll"
  370. $<TARGET_FILE_DIR:server>)
  371. endif ()
  372. add_custom_command(TARGET game POST_BUILD
  373. COMMAND ${CMAKE_COMMAND} -E copy_directory
  374. "${PROJECT_SOURCE_DIR}/assets"
  375. $<TARGET_FILE_DIR:game>/assets)
  376. add_custom_command(TARGET asset-inv POST_BUILD
  377. COMMAND ${CMAKE_COMMAND} -E copy_directory
  378. "${PROJECT_SOURCE_DIR}/assets"
  379. $<TARGET_FILE_DIR:game>/assets)