2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

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