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.
 
 
 
 
 
 

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