diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-24 11:37:50 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-24 11:37:50 +0800 |
| commit | 61aa670237e2d51f7144322bf56b8ce3633c2db9 (patch) | |
| tree | 6f8fb7f7c2bd34f936f886fdf7d4fdb9e69d32e5 /examples | |
| parent | fb50c032959d0f21579e8a6e1a0ab7141c7fbb97 (diff) | |
declutter top level CMakeLists.txt (#5391)
* Split examples cmake desc
* declutter top level CMakeLists.txt
* fail if building tests without gfx
* Move llvm fetching to another cmake file
* Further split CMakeLists.txt
* Neaten llvm fetching
* Remove last premake remnant
* correct cross builds
* Neaten
* Neaten project organization in vs
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/CMakeLists.txt | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 000000000..ad2d6f319 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,91 @@ +function(example dir) + set(debug_dir ${CMAKE_CURRENT_BINARY_DIR}/${dir}) + + file( + GLOB asset_files + CONFIGURE_DEPENDS + "${dir}/*.slang" + "${dir}/*.jpg" + "${dir}/*.obj" + "${dir}/*.mtl" + "${dir}/*.h" + ) + + list(LENGTH asset_files asset_files_length) + if(asset_files_length GREATER 0) + set(copy_assets_target "${dir}-copy-assets") + + add_custom_target( + ${copy_assets_target} + COMMAND ${CMAKE_COMMAND} -E make_directory ${debug_dir} + COMMAND + ${CMAKE_COMMAND} -E copy_if_different ${asset_files} + ${debug_dir} + COMMENT "Copy example assets to ${debug_dir}" + ) + + set_target_properties( + ${copy_assets_target} + PROPERTIES FOLDER "examples/copy_assets" + ) + endif() + + slang_add_target( + ${dir} + EXECUTABLE + USE_FEWER_WARNINGS + LINK_WITH_PRIVATE + core + example-base + slang + gfx + gfx-util + platform + $<$<BOOL:${SLANG_ENABLE_CUDA}>:CUDA::cuda_driver> + EXTRA_COMPILE_DEFINITIONS_PRIVATE + $<$<BOOL:${SLANG_ENABLE_XLIB}>:SLANG_ENABLE_XLIB> + REQUIRED_BY all-examples + OPTIONAL_REQUIRES ${copy_assets_target} copy-prebuilt-binaries + FOLDER examples + DEBUG_DIR ${debug_dir} + ${ARGN} + ) +endfunction() + +if(SLANG_ENABLE_EXAMPLES) + # + # Examples + # + slang_add_target( + example-base + STATIC + LINK_WITH_PRIVATE + core + slang + gfx + platform + $<$<BOOL:${SLANG_ENABLE_CUDA}>:CUDA::cuda_driver> + FOLDER examples + ) + + add_custom_target( + all-examples + COMMENT "meta target which depends on all examples" + ) + set_target_properties(all-examples PROPERTIES FOLDER examples) + example(autodiff-texture WIN32_EXECUTABLE) + example(cpu-com-example) + example(cpu-hello-world) + example(gpu-printing) + example(hello-world LINK_WITH_PRIVATE Vulkan-Headers) + example(model-viewer WIN32_EXECUTABLE) + example(platform-test WIN32_EXECUTABLE) + example(ray-tracing WIN32_EXECUTABLE) + example(ray-tracing-pipeline WIN32_EXECUTABLE) + example(shader-object) + example(shader-toy WIN32_EXECUTABLE) + example(triangle WIN32_EXECUTABLE) + if(SLANG_ENABLE_AFTERMATH) + example(nv-aftermath-example WIN32_EXECUTABLE) + endif() +endif() |
