@@ -21,4 +21,58 @@ macro(GroupSources curdir dirLabel)
21
21
${PROJECT_SOURCE_DIR} /${curdir} /${child} )
22
22
endif ()
23
23
endforeach ()
24
+ endmacro ()
25
+
26
+ #####################################################################################
27
+ # Macro to add custom build for SPIR-V, with additional arbitrary glslangvalidator
28
+ # flags (run glslangvalidator --help for a list of possible flags).
29
+ # Inputs:
30
+ # _SOURCE can be more than one file (.vert + .frag)
31
+ # _OUTPUT is the .spv file, resulting from the linkage
32
+ # _FLAGS are the flags to add to the command line
33
+ # Outputs:
34
+ # SOURCE_LIST has _SOURCE appended to it
35
+ # OUTPUT_LIST has _OUTPUT appended to it
36
+ #
37
+ macro (_compile_GLSL_flags _SOURCE _OUTPUT _FLAGS SOURCE_LIST OUTPUT_LIST)
38
+ LIST (APPEND ${SOURCE_LIST} ${_SOURCE} )
39
+ LIST (APPEND ${OUTPUT_LIST} ${_OUTPUT} )
40
+ if (GLSLANGVALIDATOR)
41
+ set (_COMMAND ${GLSLANGVALIDATOR} ${_SOURCE} -o ${_OUTPUT} ${_FLAGS} )
42
+ add_custom_command (
43
+ OUTPUT ${CMAKE_CURRENT_SOURCE_DIR} /${_OUTPUT}
44
+ COMMAND echo ${_COMMAND}
45
+ COMMAND ${_COMMAND}
46
+ MAIN_DEPENDENCY ${_SOURCE}
47
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
48
+ )
49
+ else (GLSLANGVALIDATOR)
50
+ MESSAGE (WARNING "could not find GLSLANGVALIDATOR to compile shaders" )
51
+ endif (GLSLANGVALIDATOR)
52
+ endmacro ()
53
+
54
+ #####################################################################################
55
+ # Macro to add custom build for SPIR-V, with debug information (glslangvalidator's -g flag)
56
+ # Inputs:
57
+ # _SOURCE can be more than one file (.vert + .frag)
58
+ # _OUTPUT is the .spv file, resulting from the linkage
59
+ # Outputs:
60
+ # SOURCE_LIST has _SOURCE appended to it
61
+ # OUTPUT_LIST has _OUTPUT appended to it
62
+ #
63
+ macro (_compile_GLSL _SOURCE _OUTPUT SOURCE_LIST OUTPUT_LIST)
64
+ _compile_GLSL_flags(${_SOURCE} ${_OUTPUT} "-g" ${SOURCE_LIST} ${OUTPUT_LIST} )
65
+ endmacro ()
66
+
67
+ #####################################################################################
68
+ # Macro to add custom build for SPIR-V, without debug information
69
+ # Inputs:
70
+ # _SOURCE can be more than one file (.vert + .frag)
71
+ # _OUTPUT is the .spv file, resulting from the linkage
72
+ # Outputs:
73
+ # SOURCE_LIST has _SOURCE appended to it
74
+ # OUTPUT_LIST has _OUTPUT appended to it
75
+ #
76
+ macro (_compile_GLSL_no_debug_info _SOURCE _OUTPUT SOURCE_LIST OUTPUT_LIST)
77
+ _compile_GLSL_flags(${_SOURCE} ${_OUTPUT} "" ${SOURCE_LIST} ${OUTPUT_LIST} )
24
78
endmacro ()
0 commit comments