Created
August 5, 2014 13:00
-
-
Save christophercrouzet/67de1b021e0c471c7c3b to your computer and use it in GitHub Desktop.
Command to format GLSL shaders with CMake for inclusion in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
separate_arguments(FILES) | |
foreach (file ${FILES}) | |
if (LOAD_SHADERS_DYNAMICALLY) | |
file( | |
COPY ${SOURCE_DIR}/${file} | |
DESTINATION ${DESTINATION_DIR} | |
) | |
else() | |
set(filename ${SOURCE_DIR}/${file}) | |
get_filename_component(name ${filename} NAME_WE) | |
get_filename_component(extension ${filename} EXT) | |
set(source "") | |
file(STRINGS ${filename} lines) | |
foreach (line ${lines}) | |
set(source "${source} \"${line}\\n\"\n") | |
endforeach() | |
file( | |
WRITE ${DESTINATION_DIR}/${file} | |
"static const GLchar *${name}ShaderSource[] = {\n" | |
"${source}" | |
"};\n" | |
) | |
endif() | |
endforeach() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment