2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

CMakeLists.txt 13 KiB

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