Dawn/CMakeLists.txt

151 lines
3.8 KiB
CMake

# Copyright (c) 2021 Dominic Msters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Set up the base CMake stuff.
cmake_minimum_required(VERSION 3.13)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
# Set some global flags
add_compile_definitions(
_CRT_SECURE_NO_WARNINGS=1
ASSET_PREFIX="../assets/"
)
# Do initial set up depending on the build target type.
if(TARGET_TYPE STREQUAL test)
set(TARGET_NAME test)
elseif(TARGET_TYPE STREQUAL game)
set(TARGET_NAME ${TARGET_GAME})
else()
message(FATAL_ERROR "Missing or invalid definition of TARGET_TYPE")
endif()
# Set up the project
project(${TARGET_NAME} VERSION 1.0)
add_executable(${PROJECT_NAME})
# Variables
set(ROOT_DIR "${CMAKE_SOURCE_DIR}")
set(BUILD_DIR "${CMAKE_BINARY_DIR}")
set(TOOLS_DIR "${ROOT_DIR}/tools")
set(ASSETS_SOURCE_DIR "${ROOT_DIR}/assets")
set(ASSETS_BUILD_DIR "${BUILD_DIR}/assets")
set(TEMP_DIR "${BUILD_DIR}/temp")
# Include tools
add_subdirectory(tools)
# Now change sources depending on the target type
if(TARGET_TYPE STREQUAL test)
add_subdirectory(test)
elseif(TARGET_TYPE STREQUAL game)
# Set up shared assets
# Shaders
tool_copy(shader_textured
${ASSETS_SOURCE_DIR}/shared/shaders/textured.vert shaders/textured.vert
${ASSETS_SOURCE_DIR}/shared/shaders/textured.frag shaders/textured.frag
)
tool_copy(shader_singlerenderlist
${ASSETS_SOURCE_DIR}/shared/shaders/singlerenderlist.vert shaders/singlerenderlist.vert
${ASSETS_SOURCE_DIR}/shared/shaders/singlerenderlist.frag shaders/singlerenderlist.frag
)
# Fonts
tool_copy(font_opensans
${ASSETS_SOURCE_DIR}/shared/fonts/opensans/OpenSans-Regular.ttf fonts/opensans/OpenSans-Regular.ttf
${ASSETS_SOURCE_DIR}/shared/fonts/opensans/OpenSans-Bold.ttf fonts/opensans/OpenSans-Bold.ttf
)
# Textures
tool_texture(texture_test
${ASSETS_SOURCE_DIR}/shared/textures/test_texture.png textures/test_texture
)
# Locales
tool_copy(locale_en
${ASSETS_SOURCE_DIR}/locale/language/en-US.csv locale/language/en-US.csv
)
# Poker Game
if(TARGET_GAME STREQUAL poker)
add_compile_definitions(
GAME_NAME="Penny's Poker"
GAME_FILE="poker/game.h"
GAME_TYPE=pokergame_t
GAME_INIT=pokerGameInit
GAME_UPDATE=pokerGameUpdate
GAME_DISPOSE=pokerGameDispose
GAME_VERSION=1.0
)
# Characters
set(DIR_CHARS "${ASSETS_SOURCE_DIR}/poker/characters")
tool_vn_character(vn_penny
${DIR_CHARS}/penny/character.xml poker/characters/penny/sprite
)
tool_vn_character(vn_lucy
${DIR_CHARS}/lucy/character.xml poker/characters/lucy/sprite
)
tool_vn_character(vn_julie
${DIR_CHARS}/julie/character.xml poker/characters/julie/sprite
)
tool_vn_character(vn_sammy
${DIR_CHARS}/sammy/character.xml poker/characters/sammy/sprite
)
tool_vn_character(vn_jenny
${DIR_CHARS}/jenny/character.xml poker/characters/jenny/sprite
)
# World
tool_texture(texture_pub
${ASSETS_SOURCE_DIR}/poker/world/pub/pub_skywall.png poker/world/pub
)
tool_assets(
shader_textured
shader_singlerenderlist
font_opensans
texture_test
texture_pub
vn_penny
vn_lucy
vn_julie
vn_sammy
vn_jenny
locale_en
)
elseif(TARGET_GAME STREQUAL sandbox)
add_compile_definitions(
GAME_NAME="Sandbox"
GAME_FILE="sandbox/game.h"
GAME_TYPE=sandboxgame_t
GAME_INIT=sandboxGameInit
GAME_UPDATE=sandboxGameUpdate
GAME_DISPOSE=sandboxGameDispose
GAME_VERSION=1.0
)
tool_assets(
shader_textured
font_opensans
texture_test
)
endif()
# Common Game Dependencies.
add_dependencies(${PROJECT_NAME} assets )
add_subdirectory(client)
endif()
# Add global sources.
add_subdirectory(lib)
add_subdirectory(src)