2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

CMakeLists.txt 11 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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/portmidi/pm_common"
  59. "${PROJECT_SOURCE_DIR}/dependencies/spine-runtimes/spine-c/spine-c/include"
  60. "${PROJECT_SOURCE_DIR}/dependencies/getopt-for-windows"
  61. "${PROJECT_SOURCE_DIR}/dependencies/libwebsockets/build/include"
  62. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/include"
  63. "${PROJECT_SOURCE_DIR}/dependencies/sqlite"
  64. )
  65. if (WIN32)
  66. link_directories(
  67. "${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}"
  68. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_image/lib/${PROJECT_ARCH}"
  69. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_ttf/lib/${PROJECT_ARCH}"
  70. "${PROJECT_SOURCE_DIR}/dependencies/portmidi/Release"
  71. "${PROJECT_SOURCE_DIR}/dependencies/libwebsockets/build/lib/Release"
  72. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/lib"
  73. )
  74. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  75. include_directories(
  76. /usr/local/include
  77. /usr/local/include/SDL2
  78. /usr/local/include/openssl
  79. )
  80. link_directories(
  81. /usr/local/lib
  82. )
  83. endif()
  84. #
  85. # Define executables
  86. #
  87. add_executable(
  88. game
  89. dependencies/minIni/dev/minIni.h
  90. dependencies/minIni/dev/minIni.c
  91. dependencies/getopt-for-windows/getopt.h
  92. dependencies/getopt-for-windows/getopt.c
  93. src/packages/game/output/video/IZ_video.h
  94. src/packages/game/output/video/IZ_video.c
  95. src/packages/common/IZ_common.h
  96. src/packages/game/input/IZ_action.h
  97. src/packages/game/IZ_app.h
  98. src/packages/game/IZ_app.c
  99. src/packages/game/main.c
  100. src/packages/game/input/IZ_joystick.c
  101. src/packages/game/input/IZ_joystick.h
  102. src/packages/game/input/IZ_keyboard.c
  103. src/packages/game/input/IZ_keyboard.h
  104. src/packages/config/IZ_config.c
  105. src/packages/config/IZ_config.h
  106. src/packages/game/geometry/IZ_vector2d.c
  107. src/packages/game/geometry/IZ_vector2d.h
  108. src/packages/game/geometry/IZ_rect.c
  109. src/packages/game/geometry/IZ_rect.h
  110. src/packages/game/core/IZ_object.c
  111. src/packages/game/core/IZ_object.h
  112. src/packages/game/core/IZ_creature.c
  113. src/packages/game/core/IZ_creature.h
  114. src/packages/game/core/IZ_entity.c
  115. src/packages/game/core/IZ_entity.h
  116. src/packages/game/memory/IZ_pool.c
  117. src/packages/game/memory/IZ_pool.h
  118. src/packages/game/input/IZ_input.c
  119. src/packages/game/input/IZ_input.h
  120. src/packages/game/input/IZ_midi.c
  121. src/packages/game/input/IZ_midi.h
  122. src/packages/game/data/IZ_list.c
  123. src/packages/game/data/IZ_list.h
  124. src/packages/net/svc/IZ_wsclient.c
  125. src/packages/net/svc/IZ_wsclient.h
  126. src/packages/log/IZ_intercept.c
  127. src/packages/log/IZ_intercept.h
  128. src/packages/midi/IZ_midi.c
  129. src/packages/midi/IZ_midi.h
  130. src/packages/net/core/IZ_websocket.h
  131. src/packages/net/core/IZ_websocket.c
  132. src/packages/net/IZ_net_client.c
  133. src/packages/net/IZ_net_client.h
  134. src/packages/game/IZ_app_net.c
  135. src/packages/game/IZ_app_net.h
  136. src/packages/game/IZ_app_video.c
  137. src/packages/game/IZ_app_video.h
  138. src/packages/game/IZ_subsystem.h
  139. src/packages/game/IZ_app_input.c
  140. src/packages/game/IZ_app_input.h
  141. src/packages/game/IZ_app_config.c
  142. src/packages/game/IZ_app_config.h
  143. src/packages/game/asset/IZ_asset.c
  144. src/packages/game/asset/IZ_asset.h
  145. src/packages/string/IZ_string.c
  146. src/packages/string/IZ_string.h
  147. src/packages/io/IZ_io.c
  148. src/packages/io/IZ_io.h
  149. src/packages/log/IZ_log.c src/packages/log/IZ_log.h src/packages/timer/IZ_timer.c src/packages/timer/IZ_timer.h src/packages/compat/IZ_windows.h)
  150. if (WIN32)
  151. target_link_libraries(
  152. game
  153. SDL2main
  154. SDL2
  155. SDL2_image
  156. SDL2_ttf
  157. portmidi
  158. libcrypto
  159. libssl
  160. websockets
  161. )
  162. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  163. target_link_libraries(
  164. game
  165. SDL2main
  166. SDL2
  167. SDL2_image
  168. SDL2_ttf
  169. portmidi
  170. crypto
  171. ssl
  172. websockets
  173. )
  174. endif()
  175. add_executable(
  176. game-test-geometry
  177. dependencies/bdd-for-c/bdd-for-c.h
  178. src/packages/test/IZ_mock.h
  179. src/packages/test/IZ_test.h
  180. src/packages/game/geometry/IZ_rect.h
  181. src/packages/game/geometry/IZ_rect.c
  182. src/packages/game/geometry/IZ_vector2d.h
  183. src/packages/game/geometry/IZ_vector2d.c
  184. src/packages/game/geometry/geometry.test.c
  185. )
  186. add_executable(
  187. game-test-input
  188. dependencies/bdd-for-c/bdd-for-c.h
  189. src/packages/test/IZ_mock.h
  190. src/packages/test/IZ_test.h
  191. __mocks__/minIni.mock.h
  192. __mocks__/SDL_keyboard.mock.h
  193. __mocks__/SDL_events.mock.h
  194. __mocks__/SDL_joystick.mock.h
  195. __mocks__/SDL_stdinc.mock.h
  196. __mocks__/portmidi.mock.h
  197. src/packages/config/IZ_config.h
  198. src/packages/game/input/IZ_keyboard.h
  199. src/packages/game/input/IZ_keyboard.c
  200. src/packages/game/input/IZ_joystick.h
  201. src/packages/game/input/IZ_joystick.c
  202. src/packages/game/input/IZ_midi.h
  203. src/packages/game/input/IZ_midi.c
  204. src/packages/midi/IZ_midi.c
  205. src/packages/midi/IZ_midi.h
  206. src/packages/game/input/input.test.c
  207. )
  208. add_executable(
  209. game-test-output
  210. dependencies/bdd-for-c/bdd-for-c.h
  211. src/packages/test/IZ_mock.h
  212. src/packages/test/IZ_test.h
  213. __mocks__/minIni.mock.h
  214. __mocks__/SDL_stdinc.mock.h
  215. __mocks__/SDL_render.mock.h
  216. src/packages/config/IZ_config.h
  217. src/packages/game/output/video/IZ_video.h
  218. src/packages/game/output/video/IZ_video.c
  219. src/packages/game/output/output.test.c
  220. )
  221. add_executable(
  222. game-test-memory
  223. dependencies/bdd-for-c/bdd-for-c.h
  224. src/packages/test/IZ_mock.h
  225. src/packages/test/IZ_test.h
  226. src/packages/game/memory/IZ_pool.h
  227. src/packages/game/memory/IZ_pool.c
  228. src/packages/game/memory/memory.test.c
  229. src/packages/game/data/IZ_list.c
  230. src/packages/game/data/IZ_list.h
  231. )
  232. add_executable(
  233. game-test-data
  234. dependencies/bdd-for-c/bdd-for-c.h
  235. src/packages/test/IZ_mock.h
  236. src/packages/test/IZ_test.h
  237. src/packages/game/data/IZ_list.h
  238. src/packages/game/data/IZ_list.c
  239. src/packages/game/data/data.test.c
  240. )
  241. add_executable(
  242. server
  243. dependencies/sqlite/sqlite3.h
  244. dependencies/sqlite/sqlite3.c
  245. dependencies/minIni/dev/minIni.h
  246. dependencies/minIni/dev/minIni.c
  247. src/packages/log/IZ_intercept.h
  248. src/packages/log/IZ_intercept.c
  249. src/packages/server/main.c
  250. src/packages/server/IZ_app.c
  251. src/packages/server/IZ_app.h
  252. src/packages/server/IZ_app_config.h
  253. src/packages/server/IZ_app_config.c
  254. src/packages/net/svc/IZ_wsserver.c
  255. src/packages/net/svc/IZ_wsserver.h
  256. src/packages/net/core/IZ_websocket.h
  257. src/packages/net/core/IZ_websocket.c
  258. src/packages/config/IZ_config.h
  259. src/packages/config/IZ_config.c
  260. src/packages/net/IZ_net_server.c
  261. src/packages/net/IZ_net_server.h
  262. src/packages/server/db/IZ_repo.c
  263. src/packages/server/db/IZ_repo.h
  264. src/packages/server/IZ_subsystem.h
  265. src/packages/string/IZ_string.c
  266. src/packages/string/IZ_string.h
  267. src/packages/io/IZ_io.c
  268. src/packages/io/IZ_io.h
  269. src/packages/log/IZ_log.c
  270. src/packages/log/IZ_log.h
  271. src/packages/timer/IZ_timer.c
  272. src/packages/timer/IZ_timer.h
  273. )
  274. if (WIN32)
  275. target_link_libraries(
  276. server
  277. SDL2main
  278. SDL2
  279. libcrypto
  280. libssl
  281. websockets
  282. )
  283. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  284. target_link_libraries(
  285. server
  286. SDL2main
  287. SDL2
  288. crypto
  289. ssl
  290. websockets
  291. )
  292. endif()
  293. add_executable(
  294. asset-inv
  295. dependencies/minIni/dev/minIni.h
  296. dependencies/minIni/dev/minIni.c
  297. src/packages/common/IZ_common.h
  298. src/packages/asset-inv/main.c
  299. )
  300. #
  301. # Add DLLs and required assets to the build directory
  302. #
  303. if (WIN32)
  304. add_custom_command(TARGET game POST_BUILD
  305. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  306. "${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}/SDL2.dll"
  307. $<TARGET_FILE_DIR:game>)
  308. add_custom_command(TARGET game POST_BUILD
  309. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  310. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_image/lib/${PROJECT_ARCH}/SDL2_image.dll"
  311. $<TARGET_FILE_DIR:game>)
  312. add_custom_command(TARGET game POST_BUILD
  313. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  314. "${PROJECT_SOURCE_DIR}/dependencies/SDL2_ttf/lib/${PROJECT_ARCH}/SDL2_ttf.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/portmidi/Release/portmidi.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/libwebsockets/build/bin/Release/websockets.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/openssl/${PROJECT_ARCH}/bin/libssl-1_1-x64.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/openssl/${PROJECT_ARCH}/bin/libcrypto-1_1-x64.dll"
  331. $<TARGET_FILE_DIR:game>)
  332. add_custom_command(TARGET server POST_BUILD
  333. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  334. "${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}/SDL2.dll"
  335. $<TARGET_FILE_DIR:server>)
  336. add_custom_command(TARGET server POST_BUILD
  337. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  338. "${PROJECT_SOURCE_DIR}/dependencies/libwebsockets/build/bin/Release/websockets.dll"
  339. $<TARGET_FILE_DIR:server>)
  340. add_custom_command(TARGET server POST_BUILD
  341. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  342. "${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/bin/libssl-1_1-x64.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/openssl/${PROJECT_ARCH}/bin/libcrypto-1_1-x64.dll"
  347. $<TARGET_FILE_DIR:server>)
  348. endif ()
  349. add_custom_command(TARGET game POST_BUILD
  350. COMMAND ${CMAKE_COMMAND} -E copy_directory
  351. "${PROJECT_SOURCE_DIR}/assets"
  352. $<TARGET_FILE_DIR:game>/assets)
  353. add_custom_command(TARGET asset-inv POST_BUILD
  354. COMMAND ${CMAKE_COMMAND} -E copy_directory
  355. "${PROJECT_SOURCE_DIR}/assets"
  356. $<TARGET_FILE_DIR:game>/assets)