More CMake stuff

This commit is contained in:
2021-10-17 00:12:35 -07:00
parent 66c61a6633
commit 12df54b344
8 changed files with 97 additions and 26 deletions

View File

@ -31,4 +31,9 @@ target_sources(${PROJECT_NAME}
target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
)
# Sub
if(TARGET_TYPE STREQUAL game)
add_subdirectory(game)
endif()

View File

@ -36,14 +36,14 @@ assetbuffer_t * assetBufferOpen(char *assetName) {
// Get the directory based on the raw input by creating a new string.
FILE *fptr;
size_t lenAsset = strlen(assetName);// Get the length of asset
size_t lenPrefix = strlen(SETTING_ASSET_PREFIX);// Get the length of the prefix
size_t lenPrefix = strlen(ASSET_PREFIX);// Get the length of the prefix
// Create str to house both the prefix and asset, and null terminator
char *joined = malloc(lenAsset + lenPrefix + 1);
if(joined == NULL) return NULL;// Mem okay?
joined[0] = '\0';//Start at null
strcat(joined, SETTING_ASSET_PREFIX);//Add prefix
strcat(joined, ASSET_PREFIX);//Add prefix
strcat(joined, assetName);//Add body
printf("Opening up %s\n", joined);

View File

@ -13,6 +13,10 @@
#include "../script/scripter.h"
#include "xml.h"
#if !defined(ASSET_PREFIX)
#error Asset Prefix has not been defined.
#endif
/** Definition of an asset ready to be buffered */
typedef FILE assetbuffer_t;

28
src/game/CMakeLists.txt Normal file
View File

@ -0,0 +1,28 @@
# Copyright (c) 2021 Dominic Msters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Definitions
# Libraries
# Sources
file(GLOB GAME_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
file(GLOB GAME_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_GAME}/*.c)
file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_GAME}*.h)
target_sources(${PROJECT_NAME}
PRIVATE
${GAME_SOURCES}
${SOURCES}
${GAME_HEADERS}
${HEADERS}
)
# Includes
target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)