|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462 |
- cmake_minimum_required(VERSION 3.21)
- project(izanagi C)
- set(CMAKE_C_STANDARD 11)
-
- #
- # Set platform
- #
- if (WIN32)
- # TODO set arch on target instead of generator
- set(IZ_PLATFORM WINDOWS)
- set(IZ_CRYPTO_LIBRARIES libcrypto libssl)
- set(IZ_GETOPT_DEPENDENCIES dependencies/getopt-for-windows/getopt.h
- dependencies/getopt-for-windows/getopt.c)
- add_definitions(
- -DIZ_WINDOWS
- )
- if (CMAKE_SIZEOF_VOID_P EQUAL 8)
- set(IZ_PROJECT_ARCH x64)
- set(IZ_SDL_ARCH x64)
- add_definitions(
- -DIZ_WIN64
- )
- else ()
- set(IZ_PROJECT_ARCH x86)
- set(IZ_SDL_ARCH Win32)
- add_definitions(
- -DIZ_WIN32
- )
- endif ()
- elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- set(IZ_PLATFORM MACOS)
- set(IZ_CRYPTO_LIBRARIES crypto ssl)
- add_definitions(
- -DIZ_MACOS
- )
- else()
- set(IZ_PLATFORM UNIX)
- set(IZ_CRYPTO_LIBRARIES crypto ssl)
- add_definitions(
- -DIZ_UNIX
- )
- endif ()
-
- #
- # Add configurations
- #
- add_definitions(
- -DIZ_APP_NAME="Izanagi"
- -DIZ_APP_DESCRIPTION="Run and gun game"
- -DIZ_APP_SERVER_DESCRIPTION="Dedicated server"
- -DIZ_PLAYERS=1
- #-DIZ_LOG_DATE_FUNCTION=IZ_TimerElapsed
- -DIZ_LOG_DATE_FUNCTION=IZ_TimerNow
- -DIZ_CONFIG_GAME_PATH="config-game.ini"
- -DIZ_CONFIG_SERVER_PATH="config-server.ini"
- )
-
- if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
- add_definitions(-DIZ_DEBUG)
- endif()
-
- #
- # Specify directories
- #
- include_directories(
- "${CMAKE_HOME_DIRECTORY}/subprojects/SDL/include"
- "${CMAKE_HOME_DIRECTORY}/dependencies/SDL2_image"
- "${CMAKE_HOME_DIRECTORY}/dependencies/SDL2_image/include"
- "${CMAKE_HOME_DIRECTORY}/dependencies/SDL2_ttf/include"
- "${CMAKE_HOME_DIRECTORY}/subprojects/ini-config/subprojects/minIni/dev"
- "${CMAKE_HOME_DIRECTORY}/subprojects/ini-config"
- "${CMAKE_HOME_DIRECTORY}/subprojects/bdd-for-c"
- "${CMAKE_HOME_DIRECTORY}/subprojects/bdd-for-c-mocks"
- "${CMAKE_HOME_DIRECTORY}/subprojects/midi-utils"
- "${CMAKE_HOME_DIRECTORY}/subprojects/portmidi/pm_common"
- "${CMAKE_HOME_DIRECTORY}/dependencies/spine-runtimes/spine-c/spine-c/include"
- "${CMAKE_HOME_DIRECTORY}/dependencies/getopt-for-windows"
- "${CMAKE_HOME_DIRECTORY}/dependencies/libwebsockets/build/include"
- "${CMAKE_HOME_DIRECTORY}/dependencies/openssl/${IZ_PROJECT_ARCH}/include"
- "${CMAKE_HOME_DIRECTORY}/dependencies/sqlite"
-
- "${CMAKE_HOME_DIRECTORY}"
- "${CMAKE_HOME_DIRECTORY}/src/packages"
- "${CMAKE_HOME_DIRECTORY}/__mocks__"
- "${CMAKE_HOME_DIRECTORY}/__mocks__/src/packages"
- "${CMAKE_HOME_DIRECTORY}/__tests__/src/packages"
- )
-
- if (IZ_PLATFORM STREQUAL "WINDOWS")
- link_directories(
- "${CMAKE_HOME_DIRECTORY}/subprojects/SDL/VisualC/${IZ_SDL_ARCH}/${CMAKE_BUILD_TYPE}"
- "${CMAKE_HOME_DIRECTORY}/dependencies/SDL2_image/lib/${IZ_PROJECT_ARCH}"
- "${CMAKE_HOME_DIRECTORY}/dependencies/SDL2_ttf/lib/${IZ_PROJECT_ARCH}"
- "${CMAKE_HOME_DIRECTORY}/subprojects/portmidi/build/Release"
- "${CMAKE_HOME_DIRECTORY}/dependencies/libwebsockets/build/lib/Release"
- "${CMAKE_HOME_DIRECTORY}/dependencies/openssl/${IZ_PROJECT_ARCH}/lib"
- )
- if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
- set(IZ_EXECUTABLE_TYPE WIN32)
- endif()
- elseif(IZ_PLATFORM STREQUAL "MACOS")
- include_directories(
- /usr/local/include
- /usr/local/include/SDL2
- /usr/local/include/openssl
-
- "${CMAKE_HOME_DIRECTORY}"
- "${CMAKE_HOME_DIRECTORY}/src/packages"
- "${CMAKE_HOME_DIRECTORY}/__mocks__"
- "${CMAKE_HOME_DIRECTORY}/__mocks__/src/packages"
- "${CMAKE_HOME_DIRECTORY}/__tests__/src/packages"
- )
-
- link_directories(
- /usr/local/lib
- )
- elseif(IZ_PLATFORM STREQUAL "UNIX")
- include_directories(
- /usr/local/include
- /usr/local/include/SDL2
- /usr/local/include/openssl
-
- "${CMAKE_HOME_DIRECTORY}"
- "${CMAKE_HOME_DIRECTORY}/src/packages"
- "${CMAKE_HOME_DIRECTORY}/__mocks__"
- "${CMAKE_HOME_DIRECTORY}/__mocks__/src/packages"
- "${CMAKE_HOME_DIRECTORY}/__tests__/src/packages"
- )
-
- link_directories(
- /usr/local/lib
- )
- endif()
-
- #
- # Define executables
- #
- add_executable(
- game
- ${IZ_EXECUTABLE_TYPE}
- subprojects/ini-config/subprojects/minIni/dev/minIni.h
- subprojects/ini-config/subprojects/minIni/dev/minIni.c
- subprojects/ini-config/ini-config.h
- subprojects/ini-config/ini-config.c
- subprojects/midi-utils/midi-utils.h
- subprojects/midi-utils/midi-utils.c
- ${IZ_GETOPT_DEPENDENCIES}
- src/packages/game/output/video/IZ_video.h
- src/packages/game/output/video/IZ_video.c
- src/packages/common/IZ_common.h
- src/packages/game/input/IZ_action.h
- src/packages/game/IZ_app.h
- src/packages/game/IZ_app.c
- src/packages/game/main.c
- src/packages/game/input/IZ_joystick.c
- src/packages/game/input/IZ_joystick.h
- src/packages/game/input/IZ_keyboard.c
- src/packages/game/input/IZ_keyboard.h
- src/packages/game/geometry/IZ_vector2d.c
- src/packages/game/geometry/IZ_vector2d.h
- src/packages/game/geometry/IZ_rect.c
- src/packages/game/geometry/IZ_rect.h
- src/packages/game/core/IZ_object.c
- src/packages/game/core/IZ_object.h
- src/packages/game/core/IZ_creature.c
- src/packages/game/core/IZ_creature.h
- src/packages/game/core/IZ_entity.c
- src/packages/game/core/IZ_entity.h
- src/packages/game/memory/IZ_pool.c
- src/packages/game/memory/IZ_pool.h
- src/packages/game/input/IZ_input.c
- src/packages/game/input/IZ_input.h
- src/packages/game/input/IZ_midi.c
- src/packages/game/input/IZ_midi.h
- src/packages/game/data/IZ_list.c
- src/packages/game/data/IZ_list.h
- src/packages/net/svc/IZ_wsclient.c
- src/packages/net/svc/IZ_wsclient.h
- src/packages/log/IZ_intercept.c
- src/packages/log/IZ_intercept.h
- src/packages/net/core/IZ_websocket.h
- src/packages/net/core/IZ_websocket.c
- src/packages/net/IZ_net_client.c
- src/packages/net/IZ_net_client.h
- src/packages/game/IZ_app_net.c
- src/packages/game/IZ_app_net.h
- src/packages/game/IZ_app_video.c
- src/packages/game/IZ_app_video.h
- src/packages/game/IZ_subsystem.h
- src/packages/game/IZ_app_input.c
- src/packages/game/IZ_app_input.h
- src/packages/game/IZ_app_config.c
- src/packages/game/IZ_app_config.h
- src/packages/game/asset/IZ_asset.c
- src/packages/game/asset/IZ_asset.h
- src/packages/stdinc/IZ_string.c
- src/packages/stdinc/IZ_string.h
- src/packages/io/IZ_io.c
- src/packages/io/IZ_io.h
- 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_compat.h
- src/packages/stdinc/IZ_stdlib.c
- src/packages/stdinc/IZ_stdlib.h
- src/packages/config/IZ_config_guid.c
- src/packages/config/IZ_config_guid.h
- )
-
- target_link_libraries(
- game
- SDL2main
- SDL2
- SDL2_image
- SDL2_ttf
- portmidi
- ${IZ_CRYPTO_LIBRARIES}
- websockets
- )
-
- add_executable(
- test-game-geometry
- subprojects/bdd-for-c/bdd-for-c.h
- subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h
-
- src/packages/game/geometry/IZ_rect.h
- src/packages/game/geometry/IZ_rect.c
- src/packages/game/geometry/IZ_vector2d.h
- src/packages/game/geometry/IZ_vector2d.c
- __tests__/src/packages/game/geometry.test.c
- )
-
- add_executable(
- test-game-input
- subprojects/bdd-for-c/bdd-for-c.h
- subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h
-
- __mocks__/subprojects/minIni/minIni.mock.h
- __mocks__/subprojects/SDL/SDL_keyboard.mock.h
- __mocks__/subprojects/SDL/SDL_events.mock.h
- __mocks__/subprojects/SDL/SDL_joystick.mock.h
- __mocks__/subprojects/SDL/SDL_stdinc.mock.h
- __mocks__/subprojects/portmidi/portmidi.mock.h
-
- src/packages/game/input/IZ_keyboard.h
- src/packages/game/input/IZ_keyboard.c
-
- src/packages/game/input/IZ_joystick.h
- src/packages/game/input/IZ_joystick.c
-
- src/packages/game/input/IZ_midi.h
- src/packages/game/input/IZ_midi.c
-
- subprojects/midi-utils/midi-utils.h
- subprojects/midi-utils/midi-utils.c
-
- src/packages/stdinc/IZ_string.h
- __mocks__/src/packages/stdinc/IZ_string.mock.h
-
- src/packages/stdinc/IZ_stdlib.h
- __mocks__/src/packages/stdinc/IZ_stdlib.mock.h
-
- __tests__/src/packages/game/input.test.c
- __mocks__/subprojects/ini-config/ini-config.mock.h
- )
-
- target_link_libraries(
- test-game-input
- SDL2main
- SDL2
- )
-
- add_executable(
- test-game-output
- subprojects/bdd-for-c/bdd-for-c.h
- subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h
-
- __mocks__/subprojects/minIni/minIni.mock.h
- __mocks__/subprojects/SDL/SDL_stdinc.mock.h
- __mocks__/subprojects/SDL/SDL_render.mock.h
-
- src/packages/game/output/video/IZ_video.h
- src/packages/game/output/video/IZ_video.c
- __tests__/src/packages/game/output.test.c
- )
-
- add_executable(
- test-game-memory
- subprojects/bdd-for-c/bdd-for-c.h
- subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h
-
- src/packages/timer/IZ_timer.h
- src/packages/timer/IZ_timer.c
-
- src/packages/stdinc/IZ_stdlib.h
- __mocks__/src/packages/stdinc/IZ_stdlib.mock.h
-
- src/packages/stdinc/IZ_string.h
- __mocks__/src/packages/stdinc/IZ_string.mock.h
-
- src/packages/log/IZ_log.h
- __mocks__/src/packages/log/IZ_log.mock.h
-
- src/packages/game/data/IZ_list.c
- src/packages/game/data/IZ_list.h
- src/packages/game/memory/IZ_pool.h
- src/packages/game/memory/IZ_pool.c
- __tests__/src/packages/game/memory.test.c
- )
-
- target_link_libraries(
- test-game-memory
- SDL2main
- SDL2
- )
-
- add_executable(
- test-game-data
- subprojects/bdd-for-c/bdd-for-c.h
- subprojects/bdd-for-c-mocks/bdd-for-c-mocks.h
-
- src/packages/stdinc/IZ_stdlib.h
- __mocks__/src/packages/stdinc/IZ_stdlib.mock.h
-
- src/packages/game/data/IZ_list.h
- src/packages/game/data/IZ_list.c
- __tests__/src/packages/game/data.test.c
- )
-
- target_link_libraries(
- test-game-data
- SDL2main
- SDL2
- )
-
- add_executable(
- server
- dependencies/sqlite/sqlite3.h
- dependencies/sqlite/sqlite3.c
- subprojects/ini-config/subprojects/minIni/dev/minIni.h
- subprojects/ini-config/subprojects/minIni/dev/minIni.c
- subprojects/ini-config/ini-config.h
- subprojects/ini-config/ini-config.c
- src/packages/log/IZ_intercept.h
- src/packages/log/IZ_intercept.c
- src/packages/server/main.c
- src/packages/server/IZ_app.c
- src/packages/server/IZ_app.h
- src/packages/server/IZ_app_config.h
- src/packages/server/IZ_app_config.c
- src/packages/net/svc/IZ_wsserver.c
- src/packages/net/svc/IZ_wsserver.h
- src/packages/net/core/IZ_websocket.h
- src/packages/net/core/IZ_websocket.c
- src/packages/net/IZ_net_server.c
- src/packages/net/IZ_net_server.h
- src/packages/server/db/IZ_repo.c
- src/packages/server/db/IZ_repo.h
- src/packages/server/IZ_subsystem.h
- src/packages/stdinc/IZ_string.c
- src/packages/stdinc/IZ_string.h
- src/packages/io/IZ_io.c
- src/packages/io/IZ_io.h
- src/packages/log/IZ_log.c
- src/packages/log/IZ_log.h
- src/packages/timer/IZ_timer.c
- src/packages/timer/IZ_timer.h
- )
-
- target_link_libraries(
- server
- SDL2main
- SDL2
- ${IZ_CRYPTO_LIBRARIES}
- websockets
- )
-
- add_executable(
- asset-inv
- subprojects/ini-config/subprojects/minIni/dev/minIni.h
- subprojects/ini-config/subprojects/minIni/dev/minIni.c
- subprojects/ini-config/ini-config.h
- subprojects/ini-config/ini-config.c
- src/packages/common/IZ_common.h
- src/packages/asset-inv/main.c
- )
-
- #
- # Add DLLs and required assets to the build directory
- #
- if (IZ_PLATFORM STREQUAL "WINDOWS")
- add_custom_command(TARGET game POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/subprojects/SDL/VisualC/${IZ_SDL_ARCH}/${CMAKE_BUILD_TYPE}/SDL2.dll"
- $<TARGET_FILE_DIR:game>)
-
- add_custom_command(TARGET game POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/dependencies/SDL2_image/lib/${IZ_PROJECT_ARCH}/SDL2_image.dll"
- $<TARGET_FILE_DIR:game>)
-
- add_custom_command(TARGET game POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/dependencies/SDL2_ttf/lib/${IZ_PROJECT_ARCH}/SDL2_ttf.dll"
- $<TARGET_FILE_DIR:game>)
-
- add_custom_command(TARGET game POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/subprojects/portmidi/build/Release/portmidi.dll"
- $<TARGET_FILE_DIR:game>)
-
- add_custom_command(TARGET game POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/dependencies/libwebsockets/build/bin/Release/websockets.dll"
- $<TARGET_FILE_DIR:game>)
-
- add_custom_command(TARGET game POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/dependencies/openssl/${IZ_PROJECT_ARCH}/bin/libssl-1_1-${IZ_SDL_ARCH}.dll"
- $<TARGET_FILE_DIR:game>)
-
- add_custom_command(TARGET game POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/dependencies/openssl/${IZ_PROJECT_ARCH}/bin/libcrypto-1_1-${IZ_SDL_ARCH}.dll"
- $<TARGET_FILE_DIR:game>)
-
- add_custom_command(TARGET server POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/subprojects/SDL/VisualC/${IZ_SDL_ARCH}/${CMAKE_BUILD_TYPE}/SDL2.dll"
- $<TARGET_FILE_DIR:server>)
-
- add_custom_command(TARGET server POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/dependencies/libwebsockets/build/bin/Release/websockets.dll"
- $<TARGET_FILE_DIR:server>)
-
- add_custom_command(TARGET server POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/dependencies/openssl/${IZ_PROJECT_ARCH}/bin/libssl-1_1-${IZ_SDL_ARCH}.dll"
- $<TARGET_FILE_DIR:server>)
-
- add_custom_command(TARGET server POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/dependencies/openssl/${IZ_PROJECT_ARCH}/bin/libcrypto-1_1-${IZ_SDL_ARCH}.dll"
- $<TARGET_FILE_DIR:server>)
-
- add_custom_command(TARGET test-game-input POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- "${CMAKE_HOME_DIRECTORY}/subprojects/SDL/VisualC/${IZ_SDL_ARCH}/${CMAKE_BUILD_TYPE}/SDL2.dll"
- $<TARGET_FILE_DIR:test-game-input>)
- endif ()
-
- add_custom_command(TARGET game POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory
- "${CMAKE_HOME_DIRECTORY}/assets"
- $<TARGET_FILE_DIR:game>/assets)
-
- add_custom_command(TARGET asset-inv POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory
- "${CMAKE_HOME_DIRECTORY}/assets"
- $<TARGET_FILE_DIR:game>/assets)
|