82 lines
2.2 KiB
CMake
82 lines
2.2 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")
|
|
|
|
# Add global sources.
|
|
add_subdirectory(lib)
|
|
|
|
# Setup Platform specific libraries
|
|
set(LIBS_PLATFORM "")
|
|
if(NOT WIN32)
|
|
list(APPEND LIBS_PLATFORM m)
|
|
endif()
|
|
|
|
# Include tools
|
|
add_subdirectory(tools)
|
|
|
|
# Include the client or the test tools
|
|
if(TARGET_TYPE STREQUAL test)
|
|
add_subdirectory(test)
|
|
elseif(TARGET_TYPE STREQUAL game)
|
|
add_subdirectory(client)
|
|
endif()
|
|
|
|
|
|
# Set up shared assets
|
|
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
|
|
)
|
|
|
|
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
|
|
)
|
|
|
|
tool_texture(texture_test
|
|
${ASSETS_SOURCE_DIR}/shared/textures/test_texture.png textures/test_texture
|
|
)
|
|
|
|
tool_copy(locale_en
|
|
${ASSETS_SOURCE_DIR}/locale/language/en-US.csv locale/language/en-US.csv
|
|
)
|
|
|
|
# Add actual game sources
|
|
add_subdirectory(src) |