I'm using glslc
to compile GLSL shaders with #include
s (not part of the core spec IIRC but supported in shaderc, which is the engine behind glslc
, distributed with the LunarG Vulkan SDK) into SPIR-V for Vulkan and GL 4.5. glslc
emits gcc-style depsfiles ([my_shader].[ext].d
) files containing dependency info.
My project is built with cmake/ninja/MSVC 2017.
Today, I use a cmake custom_command
to invoke glslc
when a shader has changed on disk, as a post-build step to my primary target. However, this doesn't catch the changes in included files (isn't at all aware of the .d files or their contents), so rebuilding shaders when an included glsl file is changed can trip up myself and other people on my team.
It looks like ninja can invoke arbitrary compilers, and since ninja knows how to handle the depsfiles, I should be able to coerce ninja into running glslc -- unsure about other build systems since right now we're standardized on ninja.
So how can I tell cmake to configure ninja to use glslc for a specific target? Or is there a paradigmatic way to get this done? It looks like a cmake pull request to add support for glslc as a compiler didn't make it in to cmake circa 2016, so whatever I do is going to be a workaround.