Source browser

CMakeLists.txt

Read the complete file below or download its original bytes. Line numbers provide stable links to a declaration or processing step.

File fingerprint
1cmake_minimum_required(VERSION 3.12) # Require CMake features used by the shader generation helper.
2project(shdr VERSION 1.0.0 LANGUAGES CXX) # Set the package version and enable C++ targets.
3include(cmake/shdr.cmake) # Load the native shader build helper or CMake argument parser.
4
5option(SHDR_BUILD_EXAMPLES "Build the dual CPU/GPU pipeline examples" ON) # Expose this optional group of examples or validation targets.
6option(SHDR_BUILD_TESTS "Build runtime and language compatibility tests" ON) # Expose this optional group of examples or validation targets.
7option(SHDR_BUILD_GPU "Enable optional EGL contexts for GPU examples/tests" ON) # Expose this optional group of examples or validation targets.
8
9set(CMAKE_CXX_STANDARD 11) # Set CMAKE_CXX_STANDARD for the following build configuration.
10set(CMAKE_CXX_STANDARD_REQUIRED ON) # Set CMAKE_CXX_STANDARD_REQUIRED for the following build configuration.
11set(CMAKE_CXX_EXTENSIONS OFF) # Set CMAKE_CXX_EXTENSIONS for the following build configuration.
12
13# The core header provides CPU execution, externally managed GL devices and an executor.
14find_package(Threads REQUIRED) # Locate the dependency needed by this build feature.
15add_library(shdr INTERFACE) # Declare the header library, optional backend or dynamic example module.
16add_library(shdr::shdr ALIAS shdr) # Declare the header library, optional backend or dynamic example module.
17target_compile_features(shdr INTERFACE cxx_std_11) # Require the C++11 language features used by the public header.
18target_link_libraries(shdr INTERFACE Threads::Threads) # Propagate the selected header, thread, EGL or module dependencies.
19target_include_directories(shdr INTERFACE # Expose the header location to build and installed consumers.
20    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> # Select the correct dependency path for build or installed consumers.
21    $<INSTALL_INTERFACE:include>) # Select the correct dependency path for build or installed consumers.
22
23if(SHDR_BUILD_TESTS) # Enable this block only when its build condition holds.
24    enable_testing() # Allow the configured executable checks to run through CTest.
25endif() # Finish this conditional build block.
26
27# Enable EGL specifically for applications that use the headless backend.
28if(SHDR_BUILD_GPU) # Enable this block only when its build condition holds.
29    find_path(SHDR_EGL_INCLUDE_DIR EGL/egl.h) # Locate the optional EGL development headers.
30    find_library(SHDR_EGL_LIBRARY NAMES EGL) # Locate the optional EGL runtime library.
31    if(SHDR_EGL_INCLUDE_DIR AND SHDR_EGL_LIBRARY) # Enable this block only when its build condition holds.
32        set(SHDR_HAVE_EGL TRUE) # Set SHDR_HAVE_EGL for the following build configuration.
33        add_library(shdr_egl INTERFACE) # Declare the header library, optional backend or dynamic example module.
34        add_library(shdr::egl ALIAS shdr_egl) # Declare the header library, optional backend or dynamic example module.
35        set_target_properties(shdr_egl PROPERTIES EXPORT_NAME egl) # Set the target export name, visibility or generated source behavior.
36        target_compile_definitions(shdr_egl INTERFACE SHDR_ENABLE_EGL=1) # Provide the optional backend, module path or fixture path to this application.
37        target_include_directories(shdr_egl INTERFACE # Expose the header location to build and installed consumers.
38            $<BUILD_INTERFACE:${SHDR_EGL_INCLUDE_DIR}>) # Select the correct dependency path for build or installed consumers.
39        target_link_libraries(shdr_egl INTERFACE shdr::shdr # Propagate the selected header, thread, EGL or module dependencies.
40            $<BUILD_INTERFACE:${SHDR_EGL_LIBRARY}> $<INSTALL_INTERFACE:EGL>) # Select the correct dependency path for build or installed consumers.
41        message(STATUS "EGL found: GPU examples and tests enabled") # Explain the dependency choice or reject an inconsistent target configuration.
42    else() # Handle the alternative installation or dependency case.
43        message(STATUS "Building CPU examples and tests. GPU targets require EGL development files") # Explain the dependency choice or reject an inconsistent target configuration.
44    endif() # Finish this conditional build block.
45endif() # Finish this conditional build block.
46
47function(shdr_example target source) # Define this reusable target configuration operation.
48    add_executable(${target} ${source}) # Build this example, test or shader export executable.
49    target_link_libraries(${target} PRIVATE shdr::shdr) # Propagate the selected header, thread, EGL or module dependencies.
50    if(SHDR_HAVE_EGL) # Enable this block only when its build condition holds.
51        target_compile_definitions(${target} PRIVATE SHDR_HAVE_EGL=1) # Provide the optional backend, module path or fixture path to this application.
52        target_link_libraries(${target} PRIVATE shdr::egl) # Propagate the selected header, thread, EGL or module dependencies.
53    endif() # Finish this conditional build block.
54    if(SHDR_BUILD_TESTS) # Enable this block only when its build condition holds.
55        add_test(NAME ${target}_cpu COMMAND ${target}) # Register this executable or validation script with CTest.
56        if(SHDR_HAVE_EGL) # Enable this block only when its build condition holds.
57            foreach(profile es31 es32 gl43 gl45 gl46) # Apply these settings to each selected profile, shader or target.
58                add_test(NAME ${target}_${profile} COMMAND ${target} --gpu ${profile}) # Register this executable or validation script with CTest.
59                set_tests_properties(${target}_${profile} PROPERTIES SKIP_RETURN_CODE 77) # Apply this target or validation configuration.
60            endforeach() # Finish configuring the selected items.
61        endif() # Finish this conditional build block.
62    endif() # Finish this conditional build block.
63endfunction() # Finish this target configuration operation.
64
65function(shdr_check_standard target) # Define this reusable target configuration operation.
66    if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") # Enable this block only when its build condition holds.
67        target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic -pedantic-errors) # Check portable C++ syntax and useful compiler warnings.
68    endif() # Finish this conditional build block.
69endfunction() # Finish this target configuration operation.
70
71if(SHDR_BUILD_EXAMPLES) # Enable this block only when its build condition holds.
72    shdr_example(example_pipeline examples/pipeline.cpp) # Apply this target or validation configuration.
73    shdr_example(example_images examples/images.cpp) # Apply this target or validation configuration.
74    shdr_example(example_hybrid examples/hybrid.cpp) # Apply this target or validation configuration.
75    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/async.cpp") # Enable this block only when its build condition holds.
76        shdr_example(example_async examples/async.cpp) # Apply this target or validation configuration.
77        shdr_target_shaders(example_async PRIVATE SOURCES examples/shaders/affine.cpp) # Apply this target or validation configuration.
78    endif() # Finish this conditional build block.
79    foreach(target example_pipeline example_hybrid) # Apply these settings to each selected profile, shader or target.
80        shdr_target_shaders(${target} PRIVATE SOURCES # Apply this target or validation configuration.
81            examples/shaders/affine.cpp examples/shaders/clamp.cpp examples/shaders/sum.cpp) # Compile these native shader stages into this target.
82    endforeach() # Finish configuring the selected items.
83    shdr_target_shaders(example_images PRIVATE SOURCES # Apply this target or validation configuration.
84        examples/shaders/buffer_to_image.cpp examples/shaders/blur.cpp examples/shaders/image_to_buffer.cpp) # Compile these native shader stages into this target.
85    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/spectral.cpp") # Enable this block only when its build condition holds.
86        shdr_example(example_spectral examples/spectral.cpp) # Apply this target or validation configuration.
87        shdr_target_shaders(example_spectral PRIVATE SOURCES # Apply this target or validation configuration.
88            examples/shaders/convolution2d.cpp examples/shaders/convolution3d.cpp # Compile these native shader stages into this target.
89            examples/shaders/dft_rows.cpp examples/shaders/dft_columns.cpp) # Compile these native shader stages into this target.
90    endif() # Finish this conditional build block.
91    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/vision.cpp") # Enable this block only when its build condition holds.
92        shdr_example(example_vision examples/vision.cpp) # Apply this target or validation configuration.
93        shdr_target_shaders(example_vision PRIVATE SOURCES # Apply this target or validation configuration.
94            examples/shaders/gaussian_horizontal.cpp examples/shaders/gaussian_vertical.cpp # Compile these native shader stages into this target.
95            examples/shaders/sobel.cpp examples/shaders/harris_tensor.cpp # Compile these native shader stages into this target.
96            examples/shaders/harris_response.cpp examples/shaders/nonmax.cpp) # Compile these native shader stages into this target.
97    endif() # Finish this conditional build block.
98    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/imaging.cpp") # Enable this block only when its build condition holds.
99        shdr_example(example_imaging examples/imaging.cpp) # Apply this target or validation configuration.
100        shdr_target_shaders(example_imaging PRIVATE SOURCES # Apply this target or validation configuration.
101            examples/shaders/bayer_unpack.cpp examples/shaders/debayer.cpp # Compile these native shader stages into this target.
102            examples/shaders/luminance.cpp examples/shaders/rle_count.cpp # Compile these native shader stages into this target.
103            examples/shaders/rle_offsets.cpp examples/shaders/rle_encode.cpp # Compile these native shader stages into this target.
104            examples/shaders/rle_decode.cpp) # Compile these native shader stages into this target.
105    endif() # Finish this conditional build block.
106    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/evt3.cpp") # Enable this block only when its build condition holds.
107        shdr_example(example_evt3 examples/evt3.cpp) # Apply this target or validation configuration.
108        shdr_target_shaders(example_evt3 PRIVATE SOURCES # Apply this target or validation configuration.
109            examples/shaders/evt3_summary.cpp examples/shaders/evt3_seed.cpp # Compile these native shader stages into this target.
110            examples/shaders/evt3_emit.cpp examples/shaders/evt3_reset.cpp # Compile these native shader stages into this target.
111            examples/shaders/evt3_flow.cpp # Compile these native shader stages into this target.
112            examples/shaders/rle_offsets.cpp) # Compile these native shader stages into this target.
113    endif() # Finish this conditional build block.
114    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/neural.cpp") # Enable this block only when its build condition holds.
115        shdr_example(example_neural examples/neural.cpp) # Apply this target or validation configuration.
116        shdr_target_shaders(example_neural PRIVATE SOURCES # Apply this target or validation configuration.
117            examples/shaders/ann_infer.cpp examples/shaders/ann_gradient.cpp # Compile these native shader stages into this target.
118            examples/shaders/nn_sgd.cpp examples/shaders/nn_binary_loss.cpp) # Compile these native shader stages into this target.
119    endif() # Finish this conditional build block.
120    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/cnn.cpp") # Enable this block only when its build condition holds.
121        shdr_example(example_cnn examples/cnn.cpp) # Apply this target or validation configuration.
122        shdr_target_shaders(example_cnn PRIVATE SOURCES # Apply this target or validation configuration.
123            examples/shaders/cnn_infer.cpp examples/shaders/cnn_gradient.cpp # Compile these native shader stages into this target.
124            examples/shaders/nn_sgd.cpp examples/shaders/nn_binary_loss.cpp) # Compile these native shader stages into this target.
125    endif() # Finish this conditional build block.
126    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/transformer.cpp") # Enable this block only when its build condition holds.
127        shdr_example(example_transformer examples/transformer.cpp) # Apply this target or validation configuration.
128        shdr_target_shaders(example_transformer PRIVATE SOURCES # Apply this target or validation configuration.
129            examples/shaders/transformer_infer.cpp examples/shaders/transformer_gradient.cpp # Compile these native shader stages into this target.
130            examples/shaders/nn_sgd.cpp) # Compile these native shader stages into this target.
131    endif() # Finish this conditional build block.
132    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/signal.cpp") # Enable this block only when its build condition holds.
133        shdr_example(example_signal examples/signal.cpp) # Apply this target or validation configuration.
134        shdr_target_shaders(example_signal PRIVATE SOURCES # Apply this target or validation configuration.
135            examples/shaders/fft_bit_reverse.cpp examples/shaders/fft_butterfly.cpp # Compile these native shader stages into this target.
136            examples/shaders/signal_window.cpp examples/shaders/signal_frequency_mask.cpp # Compile these native shader stages into this target.
137            examples/shaders/signal_fir.cpp examples/shaders/signal_biquad.cpp) # Compile these native shader stages into this target.
138    endif() # Finish this conditional build block.
139
140    # The dynamically loaded plugin embeds the very same shader source compiled as C++.
141    if(UNIX) # Enable this block only when its build condition holds.
142        add_library(shdr_example_plugin SHARED examples/plugin.cpp) # Declare the header library, optional backend or dynamic example module.
143        target_link_libraries(shdr_example_plugin PRIVATE shdr::shdr) # Propagate the selected header, thread, EGL or module dependencies.
144        shdr_target_shaders(shdr_example_plugin PRIVATE SOURCES examples/shaders/affine.cpp) # Apply this target or validation configuration.
145        set_target_properties(shdr_example_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) # Set the target export name, visibility or generated source behavior.
146        shdr_example(example_dynamic examples/dynamic.cpp) # Apply this target or validation configuration.
147        shdr_target_shaders(example_dynamic PRIVATE SOURCES # Apply this target or validation configuration.
148            examples/shaders/clamp.cpp examples/shaders/sum.cpp) # Compile these native shader stages into this target.
149        target_link_libraries(example_dynamic PRIVATE ${CMAKE_DL_LIBS}) # Propagate the selected header, thread, EGL or module dependencies.
150        target_compile_definitions(example_dynamic PRIVATE # Provide the optional backend, module path or fixture path to this application.
151            SHDR_PLUGIN_PATH="$<TARGET_FILE:shdr_example_plugin>") # Provide the built module path for the dynamic loader example.
152        add_dependencies(example_dynamic shdr_example_plugin) # Build the dynamically loaded module before its application.
153    endif() # Finish this conditional build block.
154endif() # Finish this conditional build block.
155
156if(SHDR_BUILD_TESTS) # Enable this block only when its build condition holds.
157    add_executable(test_runtime tests/test_runtime.cpp) # Build this example, test or shader export executable.
158    target_link_libraries(test_runtime PRIVATE shdr::shdr) # Propagate the selected header, thread, EGL or module dependencies.
159    shdr_target_shaders(test_runtime PRIVATE SOURCES examples/shaders/affine.cpp # Apply this target or validation configuration.
160        examples/shaders/buffer_to_image.cpp examples/shaders/blur.cpp examples/shaders/image_to_buffer.cpp) # Compile these native shader stages into this target.
161    add_test(NAME runtime_cpu COMMAND test_runtime) # Register this executable or validation script with CTest.
162    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_async.cpp") # Enable this block only when its build condition holds.
163        add_executable(test_async tests/test_async.cpp) # Build this example, test or shader export executable.
164        target_link_libraries(test_async PRIVATE shdr::shdr) # Propagate the selected header, thread, EGL or module dependencies.
165        shdr_target_shaders(test_async PRIVATE SOURCES examples/shaders/affine.cpp) # Apply this target or validation configuration.
166        add_test(NAME async_cpu COMMAND test_async) # Register this executable or validation script with CTest.
167    endif() # Finish this conditional build block.
168    if(SHDR_HAVE_EGL) # Enable this block only when its build condition holds.
169        add_executable(test_gpu tests/test_gpu.cpp) # Build this example, test or shader export executable.
170        target_link_libraries(test_gpu PRIVATE shdr::egl) # Propagate the selected header, thread, EGL or module dependencies.
171        target_compile_definitions(test_gpu PRIVATE SHDR_HAVE_EGL=1) # Provide the optional backend, module path or fixture path to this application.
172        shdr_target_shaders(test_gpu PRIVATE SOURCES # Apply this target or validation configuration.
173            examples/shaders/affine.cpp examples/shaders/scalar_images.cpp # Compile these native shader stages into this target.
174            examples/shaders/rgba_float_image.cpp examples/shaders/rgba_int_image.cpp # Compile these native shader stages into this target.
175            examples/shaders/rgba_uint_image.cpp) # Compile these native shader stages into this target.
176        foreach(profile es31 es32 gl43 gl45 gl46) # Apply these settings to each selected profile, shader or target.
177            add_test(NAME runtime_${profile} COMMAND test_gpu --gpu ${profile}) # Register this executable or validation script with CTest.
178            set_tests_properties(runtime_${profile} PROPERTIES SKIP_RETURN_CODE 77) # Apply this target or validation configuration.
179        endforeach() # Finish configuring the selected items.
180    endif() # Finish this conditional build block.
181    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_math_gpu.cpp") # Enable this block only when its build condition holds.
182        shdr_example(test_math_gpu tests/test_math_gpu.cpp) # Apply this target or validation configuration.
183        shdr_target_shaders(test_math_gpu PRIVATE SOURCES examples/shaders/math.cpp) # Apply this target or validation configuration.
184    endif() # Finish this conditional build block.
185    if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_math.cpp") # Enable this block only when its build condition holds.
186        add_executable(test_math tests/test_math.cpp) # Build this example, test or shader export executable.
187        target_link_libraries(test_math PRIVATE shdr::shdr) # Propagate the selected header, thread, EGL or module dependencies.
188        add_test(NAME math_cpu COMMAND test_math) # Register this executable or validation script with CTest.
189    endif() # Finish this conditional build block.
190endif() # Finish this conditional build block.
191
192# Offline validation covers every example shader and every GLSL output profile.
193add_executable(export_shader examples/export_shader.cpp) # Build this example, test or shader export executable.
194target_link_libraries(export_shader PRIVATE shdr::shdr) # Propagate the selected header, thread, EGL or module dependencies.
195file(GLOB SHDR_EXAMPLE_SHADERS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/examples/shaders/*.cpp") # Collect shader inputs or create the installed package configuration.
196shdr_target_shaders(export_shader PRIVATE SOURCES ${SHDR_EXAMPLE_SHADERS}) # Apply this target or validation configuration.
197if(SHDR_BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/benchmark.cpp") # Enable this block only when its build condition holds.
198    shdr_example(example_benchmark examples/benchmark.cpp) # Apply this target or validation configuration.
199    shdr_target_shaders(example_benchmark PRIVATE SOURCES ${SHDR_EXAMPLE_SHADERS}) # Apply this target or validation configuration.
200    if(TARGET shdr_example_plugin) # Enable this block only when its build condition holds.
201        target_link_libraries(example_benchmark PRIVATE ${CMAKE_DL_LIBS}) # Propagate the selected header, thread, EGL or module dependencies.
202        target_compile_definitions(example_benchmark PRIVATE # Provide the optional backend, module path or fixture path to this application.
203            SHDR_PLUGIN_PATH="$<TARGET_FILE:shdr_example_plugin>") # Provide the built module path for the dynamic loader example.
204        add_dependencies(example_benchmark shdr_example_plugin) # Build the dynamically loaded module before its application.
205    endif() # Finish this conditional build block.
206endif() # Finish this conditional build block.
207if(SHDR_BUILD_EXAMPLES AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/real_data.cpp") # Enable this block only when its build condition holds.
208    shdr_example(example_real_data examples/real_data.cpp) # Apply this target or validation configuration.
209    shdr_target_shaders(example_real_data PRIVATE SOURCES ${SHDR_EXAMPLE_SHADERS}) # Apply this target or validation configuration.
210    target_compile_definitions(example_real_data PRIVATE # Provide the optional backend, module path or fixture path to this application.
211        SHDR_EXAMPLE_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/examples/data") # Locate the public example fixtures from the generated executable.
212    if(TARGET shdr_example_plugin) # Enable this block only when its build condition holds.
213        target_link_libraries(example_real_data PRIVATE ${CMAKE_DL_LIBS}) # Propagate the selected header, thread, EGL or module dependencies.
214        target_compile_definitions(example_real_data PRIVATE # Provide the optional backend, module path or fixture path to this application.
215            SHDR_PLUGIN_PATH="$<TARGET_FILE:shdr_example_plugin>") # Provide the built module path for the dynamic loader example.
216        add_dependencies(example_real_data shdr_example_plugin) # Build the dynamically loaded module before its application.
217    endif() # Finish this conditional build block.
218endif() # Finish this conditional build block.
219find_package(Python3 COMPONENTS Interpreter QUIET) # Locate the dependency needed by this build feature.
220find_program(SHDR_GLSLANG_VALIDATOR glslangValidator) # Locate the standalone GLSL compiler when it is available.
221if(Python3_Interpreter_FOUND AND SHDR_GLSLANG_VALIDATOR) # Enable this block only when its build condition holds.
222    set(SHDR_GLSL_VALIDATION_COMMAND ${Python3_EXECUTABLE} # Set SHDR_GLSL_VALIDATION_COMMAND for the following build configuration.
223        ${CMAKE_CURRENT_SOURCE_DIR}/scripts/validate_glsl.py # Supply these files, target properties or command arguments.
224        --exporter $<TARGET_FILE:export_shader> # Supply this explicit tool option.
225        --validator ${SHDR_GLSLANG_VALIDATOR} # Supply this explicit tool option.
226        --source-dir ${CMAKE_CURRENT_SOURCE_DIR}) # Supply this explicit tool option.
227    add_custom_target(validate_glsl COMMAND ${SHDR_GLSL_VALIDATION_COMMAND} # Expose this validation or documentation command as a build target.
228        DEPENDS export_shader VERBATIM) # Regenerate when one of these source dependencies changes.
229    add_custom_target(verify_public_shaders # Expose this validation or documentation command as a build target.
230        COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/verify_public_shaders.py # Run this tool with the arguments continued below.
231            --cache ${CMAKE_CURRENT_BINARY_DIR}/public-shaders # Supply this explicit tool option.
232            --output ${CMAKE_CURRENT_BINARY_DIR}/public-shader-results.html # Write a complete report that opens in a browser.
233            --cxx ${CMAKE_CXX_COMPILER} --glslang ${SHDR_GLSLANG_VALIDATOR} # Supply this explicit tool option.
234        VERBATIM) # Preserve each command argument exactly when invoking the tool.
235    if(SHDR_BUILD_TESTS) # Enable this block only when its build condition holds.
236        add_test(NAME glsl_compilation COMMAND ${SHDR_GLSL_VALIDATION_COMMAND}) # Register this executable or validation script with CTest.
237    endif() # Finish this conditional build block.
238endif() # Finish this conditional build block.
239
240if(Python3_Interpreter_FOUND) # Enable this block only when its build condition holds.
241    if(SHDR_BUILD_TESTS) # Enable this block only when its build condition holds.
242        add_test(NAME header_is_current COMMAND ${Python3_EXECUTABLE} # Register this executable or validation script with CTest.
243            ${CMAKE_CURRENT_SOURCE_DIR}/scripts/amalgamate.py --check) # Supply these files, target properties or command arguments.
244        add_test(NAME fixture_integrity COMMAND ${Python3_EXECUTABLE} # Verify the bundled public fixtures against their recorded hashes.
245            ${CMAKE_CURRENT_SOURCE_DIR}/scripts/prepare_datasets.py --verify) # Verify each recorded fixture size and SHA-256 digest.
246        set(SHDR_FRONTEND_TEST_ARGS --cxx ${CMAKE_CXX_COMPILER}) # Set SHDR_FRONTEND_TEST_ARGS for the following build configuration.
247        if(SHDR_GLSLANG_VALIDATOR) # Enable this block only when its build condition holds.
248            list(APPEND SHDR_FRONTEND_TEST_ARGS --glslang ${SHDR_GLSLANG_VALIDATOR}) # Add these optional arguments or targets to the configured list.
249        endif() # Finish this conditional build block.
250        add_test(NAME shader_frontend COMMAND ${Python3_EXECUTABLE} # Register this executable or validation script with CTest.
251            ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_shader_compiler.py ${SHDR_FRONTEND_TEST_ARGS}) # Supply these files, target properties or command arguments.
252        if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_transformer.py") # Enable this block only when its build condition holds.
253            add_test(NAME transformer_shaders_are_current COMMAND ${Python3_EXECUTABLE} # Register this executable or validation script with CTest.
254                ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_transformer.py --check) # Supply these files, target properties or command arguments.
255        endif() # Finish this conditional build block.
256    endif() # Finish this conditional build block.
257    add_custom_target(generate_docs # Expose this validation or documentation command as a build target.
258        COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_api.py # Refresh the header's browsable API reference.
259        COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_sources.py # Refresh the example and build-tool source browsers.
260        COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/highlight_docs.py --site ${CMAKE_CURRENT_SOURCE_DIR}/docs # Color maintained code excerpts with local static HTML and CSS.
261        COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_docs.py # Check the generated site's local links and document structure.
262        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM) # Supply these files, target properties or command arguments.
263    add_custom_target(check_docs # Check local pages, links and assets throughout the static site.
264        COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_docs.py # Validate local links, fragment targets and document structure.
265        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} VERBATIM) # Resolve the published assets from this source checkout.
266endif() # Finish this conditional build block.
267
268foreach(target example_pipeline example_images example_hybrid example_dynamic # Apply these settings to each selected profile, shader or target.
269               example_spectral example_vision example_imaging example_benchmark example_async example_evt3 # Supply these files, target properties or command arguments.
270               example_neural example_cnn example_transformer # Supply these files, target properties or command arguments.
271               example_signal example_real_data # Check both synthetic signal and public dataset examples with strict C++11 flags.
272               shdr_example_plugin test_runtime test_gpu test_math test_math_gpu test_async export_shader) # Supply these files, target properties or command arguments.
273    if(TARGET ${target}) # Enable this block only when its build condition holds.
274        shdr_check_standard(${target}) # Apply this target or validation configuration.
275    endif() # Finish this conditional build block.
276endforeach() # Finish configuring the selected items.
277
278include(GNUInstallDirs) # Load the native shader build helper or CMake argument parser.
279include(CMakePackageConfigHelpers) # Generate a version file understood by installed find_package consumers.
280write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/shdrConfigVersion.cmake" # Put package version checks beside the generated configuration.
281    VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion) # Accept this release and compatible requested versions within major version one.
282install(FILES shdr.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) # Install the public header, helper or exported CMake package files.
283install(TARGETS shdr EXPORT shdrTargets) # Install the public header, helper or exported CMake package files.
284if(TARGET shdr_egl) # Enable this block only when its build condition holds.
285    install(TARGETS shdr_egl EXPORT shdrTargets) # Install the public header, helper or exported CMake package files.
286endif() # Finish this conditional build block.
287install(EXPORT shdrTargets NAMESPACE shdr:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/shdr) # Install the public header, helper or exported CMake package files.
288file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/shdrConfig.cmake" # Collect shader inputs or create the installed package configuration.
289    "include(CMakeFindDependencyMacro)\nfind_dependency(Threads)\ninclude(\"\${CMAKE_CURRENT_LIST_DIR}/shdrTargets.cmake\")\ninclude(\"\${CMAKE_CURRENT_LIST_DIR}/shdr.cmake\")\nif(TARGET shdr::egl)\n  find_path(SHDR_PACKAGE_EGL_INCLUDE_DIR EGL/egl.h)\n  find_library(SHDR_PACKAGE_EGL_LIBRARY NAMES EGL)\n  if(SHDR_PACKAGE_EGL_INCLUDE_DIR AND SHDR_PACKAGE_EGL_LIBRARY)\n    set_property(TARGET shdr::egl APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES \"\${SHDR_PACKAGE_EGL_INCLUDE_DIR}\")\n    set_property(TARGET shdr::egl PROPERTY INTERFACE_LINK_LIBRARIES \"shdr::shdr;\${SHDR_PACKAGE_EGL_LIBRARY}\")\n  endif()\nendif()\n") # Supply these files, target properties or command arguments.
290install(FILES "${CMAKE_CURRENT_BINARY_DIR}/shdrConfig.cmake" # Install the public header, helper or exported CMake package files.
291    "${CMAKE_CURRENT_BINARY_DIR}/shdrConfigVersion.cmake" # Let find_package require a compatible version of the installed library.
292    cmake/shdr.cmake scripts/compile_shader.py # Supply these files, target properties or command arguments.
293    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/shdr) # Supply these files, target properties or command arguments.