Custom languages (and some ways of using built-in ones like Java) do not work with Visual Studio generators
I've implemented basic support for GLSL as a custom language into a project according to https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/CMakeAddNewLanguage.txt. It uses glslc
to compile GLSL source to SPIRV 'object files', and copies those into a directory to create a 'shared module' as that seemed like the most sensible analogue. This works perfectly when creating a GLSL library using the Ninja Multi-Config generator. However, when using the Visual Studio generators, the SPIRV object files are never created. This is still the case if I use any other kind of library.
Whether or not this works, I'd at least expect it to be consistent between Ninja and Visual Studio when both are running a native build on Windows.
It seems like CMake's relying on Visual Studio dealing with things automatically like it would with C++, instead of adding the compilation and 'link' commands as build events like it would with other generators. The Java support appears to work around this by having the add_jar
command wrap the creation of the target, and implicitly add custom commands, but with non-VS generators, you can also make a .jar
with
cmake_minimum_required(VERSION 3.20)
find_package(Java REQUIRED)
project(CMakeJavaTest Java)
add_library(CMakeJavaTest STATIC CMakeJavaTest.java)
which produces CMakeJavaTest.jar
. This working when it does, and not working when it doesn't is consistent with my custom GLSL integration