2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

431 lines
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/stdinc/IZ_string.h
  213. __mocks__/src/packages/stdinc/IZ_string.mock.h
  214. src/packages/game/input/input.test.c
  215. )
  216. add_executable(
  217. game-test-output
  218. dependencies/bdd-for-c/bdd-for-c.h
  219. dependencies/bdd-for-c-mocks/bdd-for-c-mocks.h
  220. __mocks__/dependencies/minIni/minIni.mock.h
  221. __mocks__/dependencies/SDL2/SDL_stdinc.mock.h
  222. __mocks__/dependencies/SDL2/SDL_render.mock.h
  223. src/packages/config/IZ_config.h
  224. src/packages/game/output/video/IZ_video.h
  225. src/packages/game/output/video/IZ_video.c
  226. src/packages/game/output/output.test.c
  227. )
  228. add_executable(
  229. game-test-memory
  230. dependencies/bdd-for-c/bdd-for-c.h
  231. dependencies/bdd-for-c-mocks/bdd-for-c-mocks.h
  232. src/packages/timer/IZ_timer.h
  233. src/packages/timer/IZ_timer.c
  234. src/packages/stdinc/IZ_stdlib.h
  235. __mocks__/src/packages/stdinc/IZ_stdlib.mock.h
  236. src/packages/stdinc/IZ_string.h
  237. __mocks__/src/packages/stdinc/IZ_string.mock.h
  238. src/packages/log/IZ_log.h
  239. __mocks__/src/packages/log/IZ_log.mock.h
  240. src/packages/game/data/IZ_list.c
  241. src/packages/game/data/IZ_list.h
  242. src/packages/game/memory/IZ_pool.h
  243. src/packages/game/memory/IZ_pool.c
  244. src/packages/game/memory/memory.test.c
  245. )
  246. target_link_libraries(
  247. game-test-memory
  248. SDL2main
  249. SDL2
  250. )
  251. add_executable(
  252. game-test-data
  253. dependencies/bdd-for-c/bdd-for-c.h
  254. dependencies/bdd-for-c-mocks/bdd-for-c-mocks.h
  255. src/packages/stdinc/IZ_stdlib.h
  256. __mocks__/src/packages/stdinc/IZ_stdlib.mock.h
  257. src/packages/game/data/IZ_list.h
  258. src/packages/game/data/IZ_list.c
  259. src/packages/game/data/data.test.c
  260. )
  261. target_link_libraries(
  262. game-test-data
  263. SDL2main
  264. SDL2
  265. )
  266. add_executable(
  267. server
  268. dependencies/sqlite/sqlite3.h
  269. dependencies/sqlite/sqlite3.c
  270. dependencies/minIni/dev/minIni.h
  271. dependencies/minIni/dev/minIni.c
  272. src/packages/log/IZ_intercept.h
  273. src/packages/log/IZ_intercept.c
  274. src/packages/server/main.c
  275. src/packages/server/IZ_app.c
  276. src/packages/server/IZ_app.h
  277. src/packages/server/IZ_app_config.h
  278. src/packages/server/IZ_app_config.c
  279. src/packages/net/svc/IZ_wsserver.c
  280. src/packages/net/svc/IZ_wsserver.h
  281. src/packages/net/core/IZ_websocket.h
  282. src/packages/net/core/IZ_websocket.c
  283. src/packages/config/IZ_config.h
  284. src/packages/config/IZ_config.c
  285. src/packages/net/IZ_net_server.c
  286. src/packages/net/IZ_net_server.h
  287. src/packages/server/db/IZ_repo.c
  288. src/packages/server/db/IZ_repo.h
  289. src/packages/server/IZ_subsystem.h
  290. src/packages/stdinc/IZ_string.c
  291. src/packages/stdinc/IZ_string.h
  292. src/packages/io/IZ_io.c
  293. src/packages/io/IZ_io.h
  294. src/packages/log/IZ_log.c
  295. src/packages/log/IZ_log.h
  296. src/packages/timer/IZ_timer.c
  297. src/packages/timer/IZ_timer.h
  298. )
  299. if (WIN32)
  300. target_link_libraries(
  301. server
  302. SDL2main
  303. SDL2
  304. libcrypto
  305. libssl
  306. websockets
  307. )
  308. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  309. target_link_libraries(
  310. server
  311. SDL2main
  312. SDL2
  313. crypto
  314. ssl
  315. websockets
  316. )
  317. endif()
  318. add_executable(
  319. asset-inv
  320. dependencies/minIni/dev/minIni.h
  321. dependencies/minIni/dev/minIni.c
  322. src/packages/common/IZ_common.h
  323. src/packages/asset-inv/main.c
  324. )
  325. #
  326. # Add DLLs and required assets to the build directory
  327. #
  328. if (WIN32)
  329. add_custom_command(TARGET game POST_BUILD
  330. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  331. "${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}/SDL2.dll"
  332. $<TARGET_FILE_DIR:game>)
  333. add_custom_command(TARGET game POST_BUILD
  334. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  335. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_image/lib/${PROJECT_ARCH}/SDL2_image.dll"
  336. $<TARGET_FILE_DIR:game>)
  337. add_custom_command(TARGET game POST_BUILD
  338. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  339. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_ttf/lib/${PROJECT_ARCH}/SDL2_ttf.dll"
  340. $<TARGET_FILE_DIR:game>)
  341. add_custom_command(TARGET game POST_BUILD
  342. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  343. "${PROJECT_SOURCE_DIR}/dependencies/portmidi/Release/portmidi.dll"
  344. $<TARGET_FILE_DIR:game>)
  345. add_custom_command(TARGET game POST_BUILD
  346. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  347. "${PROJECT_SOURCE_DIR}/dependencies/libwebsockets/build/bin/Release/websockets.dll"
  348. $<TARGET_FILE_DIR:game>)
  349. add_custom_command(TARGET game POST_BUILD
  350. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  351. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/bin/libssl-1_1-x64.dll"
  352. $<TARGET_FILE_DIR:game>)
  353. add_custom_command(TARGET game POST_BUILD
  354. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  355. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/bin/libcrypto-1_1-x64.dll"
  356. $<TARGET_FILE_DIR:game>)
  357. add_custom_command(TARGET server POST_BUILD
  358. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  359. "${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}/SDL2.dll"
  360. $<TARGET_FILE_DIR:server>)
  361. add_custom_command(TARGET server POST_BUILD
  362. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  363. "${PROJECT_SOURCE_DIR}/dependencies/libwebsockets/build/bin/Release/websockets.dll"
  364. $<TARGET_FILE_DIR:server>)
  365. add_custom_command(TARGET server POST_BUILD
  366. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  367. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/bin/libssl-1_1-x64.dll"
  368. $<TARGET_FILE_DIR:server>)
  369. add_custom_command(TARGET server POST_BUILD
  370. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  371. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/bin/libcrypto-1_1-x64.dll"
  372. $<TARGET_FILE_DIR:server>)
  373. endif ()
  374. add_custom_command(TARGET game POST_BUILD
  375. COMMAND ${CMAKE_COMMAND} -E copy_directory
  376. "${PROJECT_SOURCE_DIR}/assets"
  377. $<TARGET_FILE_DIR:game>/assets)
  378. add_custom_command(TARGET asset-inv POST_BUILD
  379. COMMAND ${CMAKE_COMMAND} -E copy_directory
  380. "${PROJECT_SOURCE_DIR}/assets"
  381. $<TARGET_FILE_DIR:game>/assets)