2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 11 KiB

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