7
0
mirror of https://gitlab.com/raylibtemplates/rt.git synced 2026-06-28 03:06:18 -04:00

Remove xxd build step from CMakeLists.txt

Asset headers should be in the repository instead of built now
This commit is contained in:
Maple Redleaf
2025-12-19 11:10:51 -06:00
parent b1f494c5d8
commit 093eb8388f
4 changed files with 14 additions and 42 deletions

4
.gitignore vendored
View File

@@ -1,4 +1,2 @@
build/*
build-web/*
data/*
build*/*
.cache/*

View File

@@ -24,50 +24,13 @@ endif()
# Our Project
add_executable(${PROJECT_NAME})
# Generate header files from assets using xxd
file(GLOB_RECURSE ASSET_FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/*)
set(DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
set(GENERATED_HEADERS "")
foreach(ASSET_FILE ${ASSET_FILES})
file(RELATIVE_PATH REL_PATH
${CMAKE_CURRENT_SOURCE_DIR}/assets
${ASSET_FILE}
)
get_filename_component(FILE_NAME ${ASSET_FILE} NAME)
get_filename_component(SUB_DIR ${REL_PATH} DIRECTORY)
set(OUTPUT_DIR ${DATA_DIR}/${SUB_DIR})
file(MAKE_DIRECTORY ${OUTPUT_DIR})
set(OUTPUT_FILE ${OUTPUT_DIR}/${FILE_NAME}.h)
get_filename_component(ASSET_DIR ${ASSET_FILE} DIRECTORY)
add_custom_command(
OUTPUT ${OUTPUT_FILE}
COMMAND xxd -i ${FILE_NAME} ${OUTPUT_FILE}
DEPENDS ${ASSET_FILE}
WORKING_DIRECTORY ${ASSET_DIR}
COMMENT "Embedding ${REL_PATH}"
VERBATIM
)
list(APPEND GENERATED_HEADERS ${OUTPUT_FILE})
endforeach()
# Add source files
file(GLOB_RECURSE PROJECTSOURCES "src/*.c" "src/*.cpp")
target_sources(${PROJECT_NAME} PRIVATE ${PROJECTSOURCES})
# Add generated headers
target_sources(${PROJECT_NAME} PRIVATE ${GENERATED_HEADERS})
# Include directories
target_include_directories(${PROJECT_NAME} PRIVATE
${DATA_DIR}
"data"
${raylib_INCLUDE_DIRS}
)

12
data/cube.png.h Normal file
View File

@@ -0,0 +1,12 @@
unsigned char assets_cube_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08,
0x08, 0x06, 0x00, 0x00, 0x00, 0xc4, 0x0f, 0xbe, 0x8b, 0x00, 0x00, 0x00,
0x2b, 0x49, 0x44, 0x41, 0x54, 0x18, 0x57, 0x63, 0x64, 0x60, 0x60, 0xf8,
0xcf, 0x80, 0x07, 0x30, 0x82, 0x14, 0xd4, 0x33, 0x30, 0x30, 0x34, 0x60,
0xc1, 0x20, 0x49, 0xb0, 0x02, 0x90, 0x11, 0xe8, 0x92, 0x20, 0xdc, 0x38,
0x98, 0x4c, 0x80, 0xfb, 0x09, 0x0b, 0x00, 0x00, 0x41, 0x79, 0x1d, 0x01,
0xd9, 0xf2, 0x1b, 0x87, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
0xae, 0x42, 0x60, 0x82, 0x00, 0x00
};
unsigned int assets_cube_png_len = 102;

View File

@@ -1,7 +1,6 @@
#include "../data/cube.png.h"
#include "raylib.h"
#include <cmath>
#include <raylib-cpp.hpp>
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>