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.

CMakeLists.txt 13 KiB

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