diff options
| author | 3gg <3gg@shellblade.net> | 2025-06-27 10:18:39 -0700 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-06-27 10:18:39 -0700 |
| commit | bd57f345ed9dbed1d81683e48199626de2ea9044 (patch) | |
| tree | 4221f2f2a7ad2244d2e93052bd68187ec91b8ea9 /cmake | |
| parent | 9a82ce0083437a4f9f58108b2c23b957d2249ad8 (diff) | |
Restructure project
Diffstat (limited to 'cmake')
| -rw-r--r-- | cmake/shader.txt | 5 | ||||
| -rw-r--r-- | cmake/txt2c.txt | 44 |
2 files changed, 49 insertions, 0 deletions
diff --git a/cmake/shader.txt b/cmake/shader.txt new file mode 100644 index 0000000..8273f4d --- /dev/null +++ b/cmake/shader.txt | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | include(cmake/txt2c.txt) | ||
| 2 | |||
| 3 | macro(add_shader_library) | ||
| 4 | txt2c(${ARGN}) | ||
| 5 | endmacro() | ||
diff --git a/cmake/txt2c.txt b/cmake/txt2c.txt new file mode 100644 index 0000000..0cb11a9 --- /dev/null +++ b/cmake/txt2c.txt | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | function(txt2c target) | ||
| 2 | set(BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${target}") | ||
| 3 | file(MAKE_DIRECTORY ${BUILD_DIR}) | ||
| 4 | message(${BUILD_DIR}) | ||
| 5 | |||
| 6 | set(TEXT_FILES) | ||
| 7 | set(SOURCE_FILES) | ||
| 8 | set(INCLUDE_DIRECTORIES) | ||
| 9 | foreach(filepath IN ITEMS ${ARGN}) | ||
| 10 | set(textfile "${CMAKE_CURRENT_SOURCE_DIR}/${filepath}") | ||
| 11 | list(APPEND TEXT_FILES ${textfile}) | ||
| 12 | |||
| 13 | set(srcfile "${BUILD_DIR}/${filepath}.c") | ||
| 14 | list(APPEND SOURCE_FILES ${srcfile}) | ||
| 15 | |||
| 16 | get_filename_component(include_dir ${srcfile} DIRECTORY) | ||
| 17 | list(APPEND INCLUDE_DIRECTORIES ${include_dir}) | ||
| 18 | endforeach() | ||
| 19 | |||
| 20 | foreach(filepath IN ITEMS ${TEXT_FILES}) | ||
| 21 | message(${filepath}) | ||
| 22 | endforeach() | ||
| 23 | |||
| 24 | foreach(filepath IN ITEMS ${SOURCE_FILES}) | ||
| 25 | message(${filepath}) | ||
| 26 | endforeach() | ||
| 27 | |||
| 28 | foreach(filepath IN ITEMS ${INCLUDE_DIRECTORIES}) | ||
| 29 | message(${filepath}) | ||
| 30 | endforeach() | ||
| 31 | |||
| 32 | add_custom_command(OUTPUT ${SOURCE_FILES} | ||
| 33 | COMMAND "${PROJECT_SOURCE_DIR}/bin/txt2c.py" ${TEXT_FILES} ${SOURCE_FILES} | ||
| 34 | WORKING_DIRECTORY ${BUILD_DIR} | ||
| 35 | DEPENDS ${ARGN} | ||
| 36 | COMMENT "Generating ${target}") | ||
| 37 | |||
| 38 | add_library(${target} | ||
| 39 | ${SOURCE_FILES}) | ||
| 40 | |||
| 41 | target_include_directories(${target} PUBLIC | ||
| 42 | ${BUILD_DIR} | ||
| 43 | ${INCLUDE_DIRECTORIES}) | ||
| 44 | endfunction() | ||
