1+ cmake_minimum_required (VERSION 3.13 )
2+
13if (PLATFORM_WIN32 OR PLATFORM_LINUX)
2- cmake_minimum_required (VERSION 3.13 )
34 option (DILIGENT_INSTALL_SAMPLES "Enable installation of samples and tutorials" ON )
4- elseif (PLATFORM_WEB)
5- cmake_minimum_required (VERSION 3.13 )
65else ()
7- cmake_minimum_required (VERSION 3.10 )
86 set (DILIGENT_INSTALL_SAMPLES OFF )
97endif ()
108
119option (DILIGENT_BUILD_SAMPLE_BASE_ONLY "Build only SampleBase project" OFF )
1210option (DILIGENT_EMSCRIPTEN_INCLUDE_COI_SERVICE_WORKER "Include cross-origin isolation service worker in each emscripten build" OFF )
1311
14- function (add_sample_app APP_NAME IDE_FOLDER SOURCE INCLUDE SHADERS ASSETS )
15-
16- set_source_files_properties (${SHADERS} PROPERTIES VS_TOOL_OVERRIDE "None" )
17- set (ALL_ASSETS ${ASSETS} ${SHADERS} )
18- add_target_platform_app (${APP_NAME} "${SOURCE} " "${INCLUDE} " "${ALL_ASSETS} " )
19-
20- set_source_files_properties (${ALL_ASSETS} PROPERTIES
12+ # Adds a sample application target.
13+ #
14+ # Parameters:
15+ # APP_NAME - Name of the application
16+ # SOURCES - List of source files
17+ # INCLUDES - List of include directories
18+ # SHADERS - List of shader files
19+ # ASSETS - List of asset files
20+ # IDE_FOLDER - Optional folder name for IDE
21+ #
22+ # Example:
23+ #
24+ # add_sample_app(Tutorial03_Texturing
25+ # IDE_FOLDER
26+ # DiligentSamples/Tutorials
27+ # SOURCES
28+ # src/Tutorial03_Texturing.cpp
29+ # INCLUDES
30+ # src/Tutorial03_Texturing.hpp
31+ # SHADERS
32+ # assets/cube.vsh
33+ # assets/cube.psh
34+ # ASSETS
35+ # assets/DGLogo.png
36+ # )
37+ #
38+ function (add_sample_app APP_NAME )
39+
40+ set (options)
41+ set (oneValueArgs IDE_FOLDER)
42+ set (multiValueArgs SOURCES INCLUDES SHADERS ASSETS)
43+ cmake_parse_arguments (PARSE_ARGV 1 arg "${options} " "${oneValueArgs} " "${multiValueArgs} " )
44+
45+ set_source_files_properties (${arg_SHADERS} PROPERTIES VS_TOOL_OVERRIDE "None" )
46+ set (ALL_ASSETS ${arg_ASSETS} ${arg_SHADERS} )
47+ add_target_platform_app (${APP_NAME} "${arg_SOURCES} " "${arg_INCLUDES} " "${ALL_ASSETS} " )
48+
49+ set_source_files_properties (${ALL_ASSETS} PROPERTIES
2150 VS_DEPLOYMENT_LOCATION "."
22- MACOSX_PACKAGE_LOCATION "Resources"
51+ MACOSX_PACKAGE_LOCATION "Resources"
2352 )
2453
2554 if (PLATFORM_WIN32)
@@ -34,7 +63,7 @@ function(add_sample_app APP_NAME IDE_FOLDER SOURCE INCLUDE SHADERS ASSETS)
3463 endif ()
3564
3665 target_include_directories (${APP_NAME}
37- PRIVATE
66+ PRIVATE
3867 src
3968 )
4069
@@ -54,12 +83,14 @@ function(add_sample_app APP_NAME IDE_FOLDER SOURCE INCLUDE SHADERS ASSETS)
5483 target_compile_options (${APP_NAME} PRIVATE /wd4201 )
5584 endif ()
5685
57- set_target_properties (${APP_NAME} PROPERTIES
58- FOLDER ${IDE_FOLDER}
59- )
86+ if (arg_IDE_FOLDER)
87+ set_target_properties (${APP_NAME} PROPERTIES
88+ FOLDER ${arg_IDE_FOLDER}
89+ )
90+ endif ()
6091
61- source_group ("src" FILES ${SOURCE } ${INCLUDE } )
62- source_group ("assets" FILES ${ALL_ASSETS} )
92+ source_group ("src" FILES ${arg_SOURCES } ${arg_INCLUDES } )
93+ source_group ("assets" FILES ${ALL_ASSETS} )
6394
6495 target_sources (${APP_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR} /readme.md" )
6596 set_source_files_properties (
@@ -94,7 +125,7 @@ function(add_sample_app APP_NAME IDE_FOLDER SOURCE INCLUDE SHADERS ASSETS)
94125
95126 foreach (EXCLUDE_DIR IN LISTS EXCLUDE_DIRECTORIES)
96127 target_link_options (${APP_NAME} PRIVATE "SHELL: --exclude-file=${PROJECT_SOURCE_DIR} /assets/models/${EXCLUDE_DIR} " )
97- endforeach ()
128+ endforeach ()
98129 endif ()
99130 append_sample_base_emscripten_source (${APP_NAME} )
100131 endif ()
0 commit comments