2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

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