Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 40 additions & 25 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#
# Helper function to set up a Slang example target
# Handles common boilerplate for all examples: asset copying, main wrapper selection, and target creation
#
function(example dir)
cmake_parse_arguments(ARG "WIN32_EXECUTABLE" "" "" ${ARGN})

set(debug_dir ${CMAKE_CURRENT_BINARY_DIR}/${dir})
set(debug_dir ${CMAKE_CURRENT_BINARY_DIR})

file(
GLOB asset_files
CONFIGURE_DEPENDS
"${dir}/*.slang"
"${dir}/*.jpg"
"${dir}/*.obj"
"${dir}/*.mtl"
"${dir}/*.h"
"./*.slang"
"./*.jpg"
"./*.obj"
"./*.mtl"
"./*.h"
)

list(LENGTH asset_files asset_files_length)
Expand Down Expand Up @@ -49,7 +53,7 @@ function(example dir)
endif()

slang_add_target(
${dir}
.
EXECUTABLE
USE_FEWER_WARNINGS
LINK_WITH_PRIVATE
Expand All @@ -74,7 +78,7 @@ endfunction()

if(SLANG_ENABLE_EXAMPLES AND SLANG_ENABLE_SLANG_RHI)
#
# Examples
# Shared libraries for examples
#
slang_add_target(
example-base
Expand All @@ -92,31 +96,42 @@ if(SLANG_ENABLE_EXAMPLES AND SLANG_ENABLE_SLANG_RHI)
slang_add_target(example-winmain STATIC FOLDER examples EXCLUDE_FROM_ALL)
slang_add_target(stacktrace-windows STATIC FOLDER examples EXCLUDE_FROM_ALL)

#
# Meta target that depends on all 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(reflection-api)
example(reflection-parameter-blocks LINK_WITH_PRIVATE Vulkan-Headers)
example(shader-object)
example(shader-toy WIN32_EXECUTABLE)
example(triangle WIN32_EXECUTABLE)

#
# Add individual examples as subdirectories
#
add_subdirectory(autodiff-texture)
add_subdirectory(cpu-com-example)
add_subdirectory(cpu-hello-world)
add_subdirectory(gpu-printing)
add_subdirectory(hello-world)
add_subdirectory(model-viewer)
add_subdirectory(platform-test)
add_subdirectory(ray-tracing)
add_subdirectory(ray-tracing-pipeline)
add_subdirectory(reflection-api)
add_subdirectory(reflection-parameter-blocks)
add_subdirectory(shader-object)
add_subdirectory(shader-toy)
add_subdirectory(triangle)

#
# Conditional examples
#
if(SLANG_ENABLE_AFTERMATH)
example(nv-aftermath-example WIN32_EXECUTABLE)
add_subdirectory(nv-aftermath-example)
endif()

if(SLANG_ENABLE_SLANG_RHI)
example(mlp-training LINK_WITH_PRIVATE slang-rhi)
example(mlp-training-coopvec LINK_WITH_PRIVATE slang-rhi)
add_subdirectory(mlp-training)
add_subdirectory(mlp-training-coopvec)
endif()
endif()
1 change: 1 addition & 0 deletions examples/autodiff-texture/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(autodiff-texture WIN32_EXECUTABLE)
1 change: 1 addition & 0 deletions examples/cpu-com-example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(cpu-com-example)
1 change: 1 addition & 0 deletions examples/cpu-hello-world/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(cpu-hello-world)
1 change: 1 addition & 0 deletions examples/gpu-printing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(gpu-printing)
1 change: 1 addition & 0 deletions examples/hello-world/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(hello-world LINK_WITH_PRIVATE Vulkan-Headers)
1 change: 1 addition & 0 deletions examples/mlp-training-coopvec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(mlp-training-coopvec LINK_WITH_PRIVATE slang-rhi)
1 change: 1 addition & 0 deletions examples/mlp-training/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(mlp-training LINK_WITH_PRIVATE slang-rhi)
1 change: 1 addition & 0 deletions examples/model-viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(model-viewer WIN32_EXECUTABLE)
1 change: 1 addition & 0 deletions examples/nv-aftermath-example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(nv-aftermath-example WIN32_EXECUTABLE)
1 change: 1 addition & 0 deletions examples/platform-test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(platform-test WIN32_EXECUTABLE)
1 change: 1 addition & 0 deletions examples/ray-tracing-pipeline/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(ray-tracing-pipeline WIN32_EXECUTABLE)
1 change: 1 addition & 0 deletions examples/ray-tracing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(ray-tracing WIN32_EXECUTABLE)
1 change: 1 addition & 0 deletions examples/reflection-api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(reflection-api)
1 change: 1 addition & 0 deletions examples/reflection-parameter-blocks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(reflection-parameter-blocks LINK_WITH_PRIVATE Vulkan-Headers)
1 change: 1 addition & 0 deletions examples/shader-object/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(shader-object)
1 change: 1 addition & 0 deletions examples/shader-toy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(shader-toy WIN32_EXECUTABLE)
1 change: 1 addition & 0 deletions examples/triangle/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example(triangle WIN32_EXECUTABLE)