2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

CMakeLists.txt 14 KiB

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