2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

CMakeLists.txt 11 KiB

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