summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorIndrajith K L2025-11-03 17:48:56 +0530
committerIndrajith K L2025-11-03 17:48:56 +0530
commit737214b71be8fe5fdf51155ad50bb064b3156bd3 (patch)
tree21a2713d03830b21ee2b3ffd919708b054728e40 /CMakeLists.txt
parent3afcbd32001fc2ab2dcee1553268dbb39dabf070 (diff)
downloadreilua-enhanced-737214b71be8fe5fdf51155ad50bb064b3156bd3.tar.gz
reilua-enhanced-737214b71be8fe5fdf51155ad50bb064b3156bd3.tar.bz2
reilua-enhanced-737214b71be8fe5fdf51155ad50bb064b3156bd3.zip
Add embedded assets, splash screens, and asset loading support
Features added: - Embedded main.lua and Lua files support (EMBED_MAIN option) - Embedded assets support (EMBED_ASSETS option) - Splash screens with dual logo display (always embedded) - Asset loading progress tracking API (BeginAssetLoading, UpdateAssetLoading, EndAssetLoading) - Custom font embedding for splash/loading screens - --log flag for Windows console control - --no-logo flag to skip splash screens in development - Python scripts for embedding (embed_lua.py, embed_assets.py, embed_logo.py, embed_font.py) - Documentation (EMBEDDING.md, ASSET_LOADING.md, SPLASH_SCREENS.md) This allows building single-executable releases with all Lua code and assets embedded.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt70
1 files changed, 70 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4cfba5b..2df11ad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,8 @@ option( LUAJIT "Use LuaJIT." off )
option( LUA_EVENTS "Enable Lua event callbacks (RL.event)." off )
option( DYNAMIC_SYMBOLS "Expose all dynamic symbols with rdynamic." off )
option( EXPOSE_API_SYMBOLS "Expose dynamic symbols only for get and push functions of variable types." off )
+option( EMBED_MAIN "Embed all Lua files from build directory into executable." off )
+option( EMBED_ASSETS "Embed all files from assets folder into executable." off )
enum_option( PLATFORM "Desktop;Desktop_SDL2;Desktop_SDL3;Web" "Platform to build for." )
@@ -25,7 +27,75 @@ endif()
file( GLOB SOURCES src/*.c )
+# Always embed logo files for splash screens
+set( LOGO_FILES
+ "${CMAKE_SOURCE_DIR}/logo/raylib_logo.png"
+ "${CMAKE_SOURCE_DIR}/logo/reilua_logo.png"
+)
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/embedded_logo.h
+ COMMAND python ${CMAKE_SOURCE_DIR}/embed_logo.py
+ ${CMAKE_CURRENT_BINARY_DIR}/embedded_logo.h
+ ${CMAKE_SOURCE_DIR}/logo/raylib_logo.png
+ ${CMAKE_SOURCE_DIR}/logo/reilua_logo.png
+ DEPENDS ${LOGO_FILES}
+ COMMENT "Embedding logo files for splash screens..."
+)
+list( APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/embedded_logo.h )
+set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DEMBED_LOGO" )
+
+# Always embed font file
+set( FONT_FILE "${CMAKE_SOURCE_DIR}/fonts/Oleaguid.ttf" )
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/embedded_font.h
+ COMMAND python ${CMAKE_SOURCE_DIR}/embed_font.py
+ ${CMAKE_CURRENT_BINARY_DIR}/embedded_font.h
+ ${CMAKE_SOURCE_DIR}/fonts/Oleaguid.ttf
+ DEPENDS ${FONT_FILE}
+ COMMENT "Embedding font file..."
+)
+list( APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/embedded_font.h )
+set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DEMBED_FONT" )
+
+include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
include_directories( include )
+
+# Embed Lua files if EMBED_MAIN is ON
+if( EMBED_MAIN )
+ file( GLOB LUA_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.lua" )
+ if( LUA_FILES )
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/embedded_main.h
+ COMMAND python ${CMAKE_SOURCE_DIR}/embed_lua.py ${CMAKE_CURRENT_BINARY_DIR}/embedded_main.h ${LUA_FILES}
+ DEPENDS ${LUA_FILES}
+ COMMENT "Embedding Lua files into executable..."
+ )
+ list( APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/embedded_main.h )
+ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DEMBED_MAIN" )
+ else()
+ message( WARNING "EMBED_MAIN is ON but no .lua files found in build directory!" )
+ endif()
+endif()
+
+# Embed asset files if EMBED_ASSETS is ON
+if( EMBED_ASSETS )
+ file( GLOB_RECURSE ASSET_FILES "${CMAKE_CURRENT_BINARY_DIR}/assets/*" )
+ if( ASSET_FILES )
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.h
+ COMMAND python ${CMAKE_SOURCE_DIR}/embed_assets.py ${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.h ${ASSET_FILES}
+ DEPENDS ${ASSET_FILES}
+ COMMENT "Embedding asset files into executable..."
+ )
+ list( APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/embedded_assets.h )
+ set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DEMBED_ASSETS" )
+ else()
+ message( WARNING "EMBED_ASSETS is ON but no files found in build/assets/ directory!" )
+ endif()
+endif()
+
add_executable( ${PROJECT_NAME} ${SOURCES} )
if( PLATFORM STREQUAL "Desktop" )