Added settings to CMake

This commit is contained in:
2021-08-14 07:51:46 -07:00
parent 98b50f5987
commit e7f6e356e0
9 changed files with 78 additions and 30 deletions

View File

@ -14,35 +14,63 @@ include(FetchContent)
#Vars
set(DEPS_DIR "${PROJECT_BINARY_DIR}/_deps")
################################## Settings ####################################
# Platform Settings
set(SETTING_PLATFORM_GLFW 1)
set(SETTING_PLATFORM SETTING_PLATFORM_GLFW)
# Game Settings
set(SETTING_GAME_POKER 1)
set(SETTING_GAME_DAWN 2)
set(SETTING_GAME SETTING_GAME_POKER)
set(SETTING_GAME_NAME "DawnGame")
# Configuring
configure_file(config.h.in config.h)
#################################### PROJECT ###################################
project(DawnGame VERSION 1.0)
project(${SETTING_GAME_NAME} VERSION 1.0)
##################################### SRCS #####################################
file(GLOB_RECURSE SOURCE_FILES ${CMAKE_SOURCE_DIR}/src/*.c)
file(GLOB_RECURSE HEADER_FILES ${CMAKE_SOURCE_DIR}/src/*.h)
file(GLOB_RECURSE SOURCE_PLATFORM_FILES
${CMAKE_SOURCE_DIR}/platform/${PLATFORM}/*.c
)
file(GLOB_RECURSE HEADER_PLATFORM_FILES
${CMAKE_SOURCE_DIR}/platform/${PLATFORM}/*.h
)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/assets DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
##################################### LIBS #####################################
include_directories(${CMAKE_SOURCE_DIR}/lib/stb)
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
################################## EXECUTABLE ##################################
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
add_executable(${PROJECT_NAME}
${HEADER_FILES} ${HEADER_PLATFORM_FILES}
${SOURCE_FILES} ${SOURCE_PLATFORM_FILES}
)
################################# STATIC LIBS ##################################
# GLFW and GLAD
if(${SETTING_PLATFORM} EQUAL ${SETTING_PLATFORM_GLFW})
add_subdirectory(${CMAKE_SOURCE_DIR}/lib/glad)
target_link_libraries(${PROJECT_NAME} glad)
# GLFW
if(NOT glfw3_FOUND)
FetchContent_Declare(
glfw
GIT_REPOSITORY https://github.com/glfw/glfw
GIT_TAG 3.3.2
GIT_TAG 3.3.4
)
FetchContent_MakeAvailable(glfw)
endif()
target_link_libraries(${PROJECT_NAME} glfw)
endif()
# CGLM
if(NOT cglm_FOUND)
@ -55,5 +83,6 @@ if(NOT cglm_FOUND)
endif()
target_link_libraries(${PROJECT_NAME} cglm)
# OpenGL
find_package(OpenGL REQUIRED)
target_link_libraries(${PROJECT_NAME} OpenGL::GL)

17
config.h.in Normal file
View File

@ -0,0 +1,17 @@
// Copyright (c) 2021 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
# pragma once
// Platform Settings
#cmakedefine SETTING_PLATFORM_GLFW @SETTING_PLATFORM_GLFW@
#cmakedefine SETTING_PLATFORM @SETTING_PLATFORM@
// Game Settings
#cmakedefine SETTING_GAME_POKER @SETTING_GAME_POKER@
#cmakedefine SETTING_GAME_DAWN @SETTING_GAME_DAWN@
#cmakedefine SETTING_GAME @SETTING_GAME@
#cmakedefine SETTING_GAME_NAME "@SETTING_GAME_NAME@"

View File

@ -15,8 +15,6 @@
/** Describes the current game */
typedef struct {
char *name;
/** Engine for the game */
engine_t engine;

View File

@ -13,9 +13,6 @@
#include "../../vn/vnscene.h"
#include "pokerui.h"
/** Name of the Poker Game */
#define POKER_GAME_NAME "Dawn Poker Game"
typedef struct {
/** Poker Game State */
poker_t poker;

View File

@ -6,11 +6,15 @@
#pragma once
// Settings
#include "settings.h"
#include "config.h"
// Static Libs
#include <cglm/cglm.h>
#if SETTING_PLATFORM == SETTING_PLATFORM_GLFW
#include <glad/glad.h>
#endif
#include <stb_image.h>
#include <stb_truetype.h>

View File

@ -12,3 +12,9 @@
// Settings
#define SETTING_GAME SETTING_GAME_POKER
// Compiler setting fallbacks
#ifndef SETTING_PLATFORM
#error Missing platform setting from compiler.
#endif

View File

@ -75,7 +75,7 @@ int32_t main() {
inputBind(input, INPUT_ACCEPT, (inputsource_t)GLFW_KEY_SPACE);
// Update the window title.
glfwSetWindowTitle(window, GAME_STATE->name);
glfwSetWindowTitle(window, SETTING_GAME_NAME);
double time = 0;

View File

@ -9,9 +9,9 @@
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <dawn/dawn.h>
#include "../../display/render.h"
#include "../../game/game.h"
#include "../../input/input.h"
#include "../../src/display/render.h"
#include "../../src/game/game.h"
#include "../../src/input/input.h"
#define WINDOW_WIDTH_DEFAULT 1280
#define WINDOW_HEIGHT_DEFAULT WINDOW_WIDTH_DEFAULT/16*9

View File

@ -10,9 +10,6 @@
bool pokerGameInit(game_t *game) {
pokergame_t *pokerGame = &game->pokerGame;
// Init the game
game->name = POKER_GAME_NAME;
// Load the Assets
pokerGameAssetsInit(&pokerGame->assets);