@@ -320,6 +320,7 @@ nfx_embed_resources(
320320 NAMESPACE <namespace>
321321 REGISTRY_NAME <registry_name>
322322 [PATTERN pattern1 pattern2 ...]
323+ [RECURSE]
323324)
324325```
325326
@@ -330,6 +331,7 @@ nfx_embed_resources(
330331- ` NAMESPACE ` - C++ namespace (supports nested namespaces like ` my::app::resources ` )
331332- ` REGISTRY_NAME ` - Name for generated files (creates ` <name>.h ` and ` <name>.cpp ` )
332333- ` PATTERN ` - Optional file glob patterns (default: ` * ` for all files)
334+ - ` RECURSE ` - Optional flag to enable recursive subdirectory scanning
333335
334336** Generated Functions:**
335337
@@ -359,12 +361,37 @@ nfx_embed_resources(
359361```
360362
361363This will:
362- 1 . Scan ` ${CMAKE_SOURCE_DIR}/assets ` for files matching the patterns
364+ 1 . Scan ` ${CMAKE_SOURCE_DIR}/assets ` for files matching the patterns (current directory only)
3633652 . Generate ` assets.h ` and ` assets.cpp ` in ` ${CMAKE_BINARY_DIR}/generated `
3643663 . Create ` myapp::assets::all() ` and ` myapp::assets::find() ` functions
3653674 . Add generated files to the ` myapp ` target
3663685 . Include directory automatically added so you can ` #include <assets.h> `
367369
370+ ** Example with Recursive Scanning:**
371+
372+ ``` cmake
373+ nfx_embed_resources(
374+ TARGET myapp
375+ RESOURCE_DIR "${CMAKE_SOURCE_DIR}/assets"
376+ OUTPUT_DIR "${CMAKE_BINARY_DIR}/generated"
377+ NAMESPACE "myapp::assets"
378+ REGISTRY_NAME "assets"
379+ PATTERN "*.json" "*.xml" "*.png"
380+ RECURSE # Scan subdirectories recursively
381+ )
382+ ```
383+
384+ With ` RECURSE ` , resources in subdirectories are named with their relative paths:
385+ - ` assets/config.json ` → resource name: ` "config.json" `
386+ - ` assets/shaders/vertex.glsl ` → resource name: ` "shaders/vertex.glsl" `
387+ - ` assets/textures/ui/icon.png ` → resource name: ` "textures/ui/icon.png" `
388+
389+ ``` cpp
390+ // Find resources by their relative paths
391+ auto * shader = myapp::assets::find(" shaders/vertex.glsl" );
392+ auto * icon = myapp::assets::find(" textures/ui/icon.png" );
393+ ```
394+
368395## Project Structure
369396
370397```
@@ -466,13 +493,17 @@ nfx_embed_resources(
466493 NAMESPACE "myapp::shaders"
467494 REGISTRY_NAME "shaders"
468495 PATTERN "*.glsl" "*.hlsl"
496+ RECURSE # Include shaders from subdirectories
469497)
470498```
471499
472500Then include the appropriate headers:
473501``` cpp
474502#include < config.h> // Includes nfx::Resource, provides myapp::config::find()
475503#include < shaders.h> // Includes nfx::Resource, provides myapp::shaders::find()
504+
505+ // Access shader with subdirectory path
506+ auto * vertShader = myapp::shaders::find(" pbr/vertex.glsl" );
476507```
477508
478509### Custom Resource Registry
@@ -515,4 +546,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
515546
516547---
517548
518- _Updated on January 22 , 2026_
549+ _Updated on January 25 , 2026_
0 commit comments