2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

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