2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 14 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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. __mocks__/subprojects/minIni/minIni.mock.h
  224. __mocks__/subprojects/SDL/SDL_keyboard.mock.h
  225. __mocks__/subprojects/SDL/SDL_events.mock.h
  226. __mocks__/subprojects/SDL/SDL_joystick.mock.h
  227. __mocks__/subprojects/SDL/SDL_stdinc.mock.h
  228. __mocks__/subprojects/portmidi/portmidi.mock.h
  229. src/packages/game/input/IZ_keyboard.h
  230. src/packages/game/input/IZ_keyboard.c
  231. src/packages/game/input/IZ_joystick.h
  232. src/packages/game/input/IZ_joystick.c
  233. src/packages/game/input/IZ_midi.h
  234. src/packages/game/input/IZ_midi.c
  235. subprojects/midi-utils/midi-utils.h
  236. subprojects/midi-utils/midi-utils.c
  237. src/packages/stdinc/IZ_string.h
  238. __mocks__/src/packages/stdinc/IZ_string.mock.h
  239. src/packages/stdinc/IZ_stdlib.h
  240. __mocks__/src/packages/stdinc/IZ_stdlib.mock.h
  241. __tests__/src/packages/game/input.test.c
  242. __mocks__/src/packages/config/IZ_config.mock.h
  243. )
  244. target_link_libraries(
  245. test-game-input
  246. SDL2main
  247. SDL2
  248. )
  249. add_executable(
  250. test-game-output
  251. subprojects/bdd-for-c/bdd-for-c.h
  252. subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h
  253. __mocks__/subprojects/minIni/minIni.mock.h
  254. __mocks__/subprojects/SDL/SDL_stdinc.mock.h
  255. __mocks__/subprojects/SDL/SDL_render.mock.h
  256. src/packages/game/output/video/IZ_video.h
  257. src/packages/game/output/video/IZ_video.c
  258. __tests__/src/packages/game/output.test.c
  259. )
  260. add_executable(
  261. test-game-memory
  262. subprojects/bdd-for-c/bdd-for-c.h
  263. subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h
  264. src/packages/timer/IZ_timer.h
  265. src/packages/timer/IZ_timer.c
  266. src/packages/stdinc/IZ_stdlib.h
  267. __mocks__/src/packages/stdinc/IZ_stdlib.mock.h
  268. src/packages/stdinc/IZ_string.h
  269. __mocks__/src/packages/stdinc/IZ_string.mock.h
  270. src/packages/log/IZ_log.h
  271. __mocks__/src/packages/log/IZ_log.mock.h
  272. src/packages/game/data/IZ_list.c
  273. src/packages/game/data/IZ_list.h
  274. src/packages/game/memory/IZ_pool.h
  275. src/packages/game/memory/IZ_pool.c
  276. __tests__/src/packages/game/memory.test.c
  277. )
  278. target_link_libraries(
  279. test-game-memory
  280. SDL2main
  281. SDL2
  282. )
  283. add_executable(
  284. test-game-data
  285. subprojects/bdd-for-c/bdd-for-c.h
  286. subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h
  287. src/packages/stdinc/IZ_stdlib.h
  288. __mocks__/src/packages/stdinc/IZ_stdlib.mock.h
  289. src/packages/game/data/IZ_list.h
  290. src/packages/game/data/IZ_list.c
  291. __tests__/src/packages/game/data.test.c
  292. )
  293. target_link_libraries(
  294. test-game-data
  295. SDL2main
  296. SDL2
  297. )
  298. add_executable(
  299. server
  300. dependencies/sqlite/sqlite3.h
  301. dependencies/sqlite/sqlite3.c
  302. subprojects/ini-config/subprojects/minIni/dev/minIni.h
  303. subprojects/ini-config/subprojects/minIni/dev/minIni.c
  304. subprojects/ini-config/ini-config.h
  305. subprojects/ini-config/ini-config.c
  306. src/packages/log/IZ_intercept.h
  307. src/packages/log/IZ_intercept.c
  308. src/packages/server/main.c
  309. src/packages/server/IZ_app.c
  310. src/packages/server/IZ_app.h
  311. src/packages/server/IZ_app_config.h
  312. src/packages/server/IZ_app_config.c
  313. src/packages/net/svc/IZ_wsserver.c
  314. src/packages/net/svc/IZ_wsserver.h
  315. src/packages/net/core/IZ_websocket.h
  316. src/packages/net/core/IZ_websocket.c
  317. src/packages/net/IZ_net_server.c
  318. src/packages/net/IZ_net_server.h
  319. src/packages/server/db/IZ_repo.c
  320. src/packages/server/db/IZ_repo.h
  321. src/packages/server/IZ_subsystem.h
  322. src/packages/stdinc/IZ_string.c
  323. src/packages/stdinc/IZ_string.h
  324. src/packages/io/IZ_io.c
  325. src/packages/io/IZ_io.h
  326. src/packages/log/IZ_log.c
  327. src/packages/log/IZ_log.h
  328. src/packages/timer/IZ_timer.c
  329. src/packages/timer/IZ_timer.h
  330. )
  331. target_link_libraries(
  332. server
  333. SDL2main
  334. SDL2
  335. ${IZ_CRYPTO_LIBRARIES}
  336. websockets
  337. )
  338. add_executable(
  339. asset-inv
  340. subprojects/ini-config/subprojects/minIni/dev/minIni.h
  341. subprojects/ini-config/subprojects/minIni/dev/minIni.c
  342. subprojects/ini-config/ini-config.h
  343. subprojects/ini-config/ini-config.c
  344. src/packages/common/IZ_common.h
  345. src/packages/asset-inv/main.c
  346. )
  347. #
  348. # Add DLLs and required assets to the build directory
  349. #
  350. if (IZ_PLATFORM STREQUAL "WINDOWS")
  351. add_custom_command(TARGET game POST_BUILD
  352. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  353. "${CMAKE_HOME_DIRECTORY}/subprojects/SDL/VisualC/${IZ_SDL_ARCH}/${CMAKE_BUILD_TYPE}/SDL2.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_image/lib/${IZ_PROJECT_ARCH}/SDL2_image.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}/dependencies/SDL2_ttf/lib/${IZ_PROJECT_ARCH}/SDL2_ttf.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}/subprojects/portmidi/build/Release/portmidi.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/libwebsockets/build/bin/Release/websockets.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/libssl-1_1-${IZ_SDL_ARCH}.dll"
  374. $<TARGET_FILE_DIR:game>)
  375. add_custom_command(TARGET game POST_BUILD
  376. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  377. "${CMAKE_HOME_DIRECTORY}/dependencies/openssl/${IZ_PROJECT_ARCH}/bin/libcrypto-1_1-${IZ_SDL_ARCH}.dll"
  378. $<TARGET_FILE_DIR:game>)
  379. add_custom_command(TARGET server POST_BUILD
  380. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  381. "${CMAKE_HOME_DIRECTORY}/subprojects/SDL/VisualC/${IZ_SDL_ARCH}/${CMAKE_BUILD_TYPE}/SDL2.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/libwebsockets/build/bin/Release/websockets.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/libssl-1_1-${IZ_SDL_ARCH}.dll"
  390. $<TARGET_FILE_DIR:server>)
  391. add_custom_command(TARGET server POST_BUILD
  392. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  393. "${CMAKE_HOME_DIRECTORY}/dependencies/openssl/${IZ_PROJECT_ARCH}/bin/libcrypto-1_1-${IZ_SDL_ARCH}.dll"
  394. $<TARGET_FILE_DIR:server>)
  395. add_custom_command(TARGET test-game-input POST_BUILD
  396. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  397. "${CMAKE_HOME_DIRECTORY}/subprojects/SDL/VisualC/${IZ_SDL_ARCH}/${CMAKE_BUILD_TYPE}/SDL2.dll"
  398. $<TARGET_FILE_DIR:test-game-input>)
  399. endif ()
  400. add_custom_command(TARGET game POST_BUILD
  401. COMMAND ${CMAKE_COMMAND} -E copy_directory
  402. "${CMAKE_HOME_DIRECTORY}/assets"
  403. $<TARGET_FILE_DIR:game>/assets)
  404. add_custom_command(TARGET asset-inv POST_BUILD
  405. COMMAND ${CMAKE_COMMAND} -E copy_directory
  406. "${CMAKE_HOME_DIRECTORY}/assets"
  407. $<TARGET_FILE_DIR:game>/assets)