2017-11-12 19:32:09 +01:00
|
|
|
# Function for building single example
|
|
|
|
|
function(buildExample EXAMPLE_NAME)
|
|
|
|
|
SET(EXAMPLE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/${EXAMPLE_NAME})
|
|
|
|
|
message(STATUS "Generating project file for example in ${EXAMPLE_FOLDER}")
|
|
|
|
|
# Main
|
|
|
|
|
file(GLOB SOURCE *.cpp ${BASE_HEADERS} ${EXAMPLE_FOLDER}/*.cpp)
|
|
|
|
|
SET(MAIN_CPP ${EXAMPLE_FOLDER}/${EXAMPLE_NAME}.cpp)
|
|
|
|
|
if(EXISTS ${EXAMPLE_FOLDER}/main.cpp)
|
|
|
|
|
SET(MAIN_CPP ${EXAMPLE_FOLDER}/main.cpp)
|
|
|
|
|
ENDIF()
|
2020-06-06 14:42:53 +02:00
|
|
|
if(EXISTS ${EXAMPLE_FOLDER}/${EXAMPLE_NAME}.h)
|
|
|
|
|
SET(MAIN_HEADER ${EXAMPLE_FOLDER}/${EXAMPLE_NAME}.h)
|
|
|
|
|
ENDIF()
|
2017-11-12 19:32:09 +01:00
|
|
|
# imgui example requires additional source files
|
|
|
|
|
IF(${EXAMPLE_NAME} STREQUAL "imgui")
|
|
|
|
|
file(GLOB ADD_SOURCE "../external/imgui/*.cpp")
|
|
|
|
|
SET(SOURCE ${SOURCE} ${ADD_SOURCE})
|
|
|
|
|
ENDIF()
|
2019-01-16 01:16:58 -07:00
|
|
|
# wayland requires additional source files
|
|
|
|
|
IF(USE_WAYLAND_WSI)
|
|
|
|
|
SET(SOURCE ${SOURCE} ${CMAKE_BINARY_DIR}/xdg-shell-client-protocol.h ${CMAKE_BINARY_DIR}/xdg-shell-protocol.c)
|
|
|
|
|
ENDIF()
|
2017-11-12 19:32:09 +01:00
|
|
|
# Add shaders
|
2023-05-13 14:55:18 +02:00
|
|
|
set(SHADER_DIR_GLSL "../shaders/glsl/${EXAMPLE_NAME}")
|
|
|
|
|
file(GLOB SHADERS_GLSL "${SHADER_DIR_GLSL}/*.vert" "${SHADER_DIR_GLSL}/*.frag" "${SHADER_DIR_GLSL}/*.comp" "${SHADER_DIR_GLSL}/*.geom" "${SHADER_DIR_GLSL}/*.tesc" "${SHADER_DIR_GLSL}/*.tese" "${SHADER_DIR_GLSL}/*.mesh" "${SHADER_DIR_GLSL}/*.task" "${SHADER_DIR_GLSL}/*.rgen" "${SHADER_DIR_GLSL}/*.rchit" "${SHADER_DIR_GLSL}/*.rmiss" "${SHADER_DIR_GLSL}/*.rcall" "${SHADER_DIR_GLSL}/*.rahit" "${SHADER_DIR_GLSL}/*.rint" "${SHADER_DIR_GLSL}/*.glsl")
|
|
|
|
|
set(SHADER_DIR_HLSL "../shaders/hlsl/${EXAMPLE_NAME}")
|
|
|
|
|
file(GLOB SHADERS_HLSL "${SHADER_DIR_HLSL}/*.vert" "${SHADER_DIR_HLSL}/*.frag" "${SHADER_DIR_HLSL}/*.comp" "${SHADER_DIR_HLSL}/*.geom" "${SHADER_DIR_HLSL}/*.tesc" "${SHADER_DIR_HLSL}/*.tese" "${SHADER_DIR_HLSL}/*.mesh" "${SHADER_DIR_HLSL}/*.task" "${SHADER_DIR_HLSL}/*.rgen" "${SHADER_DIR_HLSL}/*.rchit" "${SHADER_DIR_HLSL}/*.rmiss" "${SHADER_DIR_HLSL}/*.rcall" "${SHADER_DIR_HLSL}/*.rahit" "${SHADER_DIR_HLSL}/*.rint")
|
2020-06-05 21:11:28 +02:00
|
|
|
source_group("Shaders\\GLSL" FILES ${SHADERS_GLSL})
|
|
|
|
|
source_group("Shaders\\HLSL" FILES ${SHADERS_HLSL})
|
2020-07-04 14:20:45 +02:00
|
|
|
# Add optional readme / tutorial
|
|
|
|
|
file(GLOB README_FILES "${EXAMPLE_FOLDER}/*.md")
|
2017-11-12 19:32:09 +01:00
|
|
|
if(WIN32)
|
2020-07-04 14:20:45 +02:00
|
|
|
add_executable(${EXAMPLE_NAME} WIN32 ${MAIN_CPP} ${SOURCE} ${MAIN_HEADER} ${SHADERS_GLSL} ${SHADERS_HLSL} ${README_FILES})
|
2020-07-28 20:20:38 +02:00
|
|
|
target_link_libraries(${EXAMPLE_NAME} base ${Vulkan_LIBRARY} ${WINLIBS})
|
2017-11-12 19:32:09 +01:00
|
|
|
else(WIN32)
|
2020-07-04 14:20:45 +02:00
|
|
|
add_executable(${EXAMPLE_NAME} ${MAIN_CPP} ${SOURCE} ${MAIN_HEADER} ${SHADERS_GLSL} ${SHADERS_HLSL} ${README_FILES})
|
2017-11-12 19:32:09 +01:00
|
|
|
target_link_libraries(${EXAMPLE_NAME} base )
|
|
|
|
|
endif(WIN32)
|
|
|
|
|
|
2023-09-09 11:33:32 +02:00
|
|
|
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
2018-07-15 15:34:34 -07:00
|
|
|
set_target_properties(${EXAMPLE_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
2022-07-27 01:11:20 -04:00
|
|
|
if(${EXAMPLE_NAME} STREQUAL "texture3d")
|
2022-08-05 00:33:48 -04:00
|
|
|
if(APPLE)
|
|
|
|
|
# SRS - Use MacPorts paths as default since the same on x86 and Apple Silicon, can override for homebrew on cmake command line
|
|
|
|
|
if(NOT OpenMP_omp_LIBRARY AND EXISTS /opt/local/lib/libomp/libomp.dylib)
|
|
|
|
|
set(OpenMP_omp_LIBRARY /opt/local/lib/libomp/libomp.dylib)
|
|
|
|
|
endif()
|
|
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang\$")
|
|
|
|
|
set(OpenMP_C_FLAGS "-Xclang -fopenmp")
|
|
|
|
|
set(OpenMP_C_LIB_NAMES "omp")
|
|
|
|
|
if(NOT OpenMP_C_INCLUDE_DIR AND EXISTS /opt/local/include/libomp)
|
|
|
|
|
set(OpenMP_C_INCLUDE_DIR /opt/local/include/libomp)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang\$")
|
|
|
|
|
set(OpenMP_CXX_FLAGS "-Xclang -fopenmp")
|
|
|
|
|
set(OpenMP_CXX_LIB_NAMES "omp")
|
|
|
|
|
if(NOT OpenMP_CXX_INCLUDE_DIR AND EXISTS /opt/local/include/libomp)
|
|
|
|
|
set(OpenMP_CXX_INCLUDE_DIR /opt/local/include/libomp)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
find_package(OpenMP)
|
2022-07-27 01:11:20 -04:00
|
|
|
if(OpenMP_CXX_FOUND)
|
2023-07-15 10:44:22 +01:00
|
|
|
link_directories(${OpenMP_CXX_LIBRARY_DIRS})
|
2020-09-17 14:06:21 +02:00
|
|
|
endif()
|
2022-07-27 01:11:20 -04:00
|
|
|
endif()
|
2018-07-15 15:34:34 -07:00
|
|
|
|
2017-11-12 19:32:09 +01:00
|
|
|
if(RESOURCE_INSTALL_DIR)
|
|
|
|
|
install(TARGETS ${EXAMPLE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
|
|
|
endif()
|
|
|
|
|
endfunction(buildExample)
|
|
|
|
|
|
|
|
|
|
# Build all examples
|
|
|
|
|
function(buildExamples)
|
|
|
|
|
foreach(EXAMPLE ${EXAMPLES})
|
|
|
|
|
buildExample(${EXAMPLE})
|
|
|
|
|
endforeach(EXAMPLE)
|
|
|
|
|
endfunction(buildExamples)
|
|
|
|
|
|
|
|
|
|
set(EXAMPLES
|
|
|
|
|
bloom
|
|
|
|
|
computecloth
|
|
|
|
|
computecullandlod
|
|
|
|
|
computeheadless
|
|
|
|
|
computenbody
|
|
|
|
|
computeparticles
|
2019-05-11 12:41:46 +02:00
|
|
|
computeraytracing
|
2017-11-12 19:32:09 +01:00
|
|
|
computeshader
|
2018-09-05 18:16:28 +02:00
|
|
|
conditionalrender
|
2018-03-03 17:32:28 +01:00
|
|
|
conservativeraster
|
2023-12-22 12:04:50 +01:00
|
|
|
debugutils
|
2017-11-12 19:32:09 +01:00
|
|
|
deferred
|
|
|
|
|
deferredmultisampling
|
|
|
|
|
deferredshadows
|
2022-12-04 12:51:14 +01:00
|
|
|
descriptorbuffer
|
2020-12-16 10:40:23 +00:00
|
|
|
descriptorindexing
|
2018-04-08 13:12:16 +02:00
|
|
|
descriptorsets
|
2017-11-12 19:32:09 +01:00
|
|
|
displacement
|
|
|
|
|
distancefieldfonts
|
2021-11-06 19:45:22 +01:00
|
|
|
dynamicrendering
|
2022-10-02 15:46:26 +02:00
|
|
|
dynamicstate
|
|
|
|
|
dynamicuniformbuffer
|
2017-11-12 19:32:09 +01:00
|
|
|
gears
|
|
|
|
|
geometryshader
|
2020-07-04 14:20:45 +02:00
|
|
|
gltfloading
|
|
|
|
|
gltfscenerendering
|
2020-05-10 20:05:05 +02:00
|
|
|
gltfskinning
|
2022-04-03 18:22:53 +02:00
|
|
|
graphicspipelinelibrary
|
2017-11-12 19:32:09 +01:00
|
|
|
hdr
|
|
|
|
|
imgui
|
|
|
|
|
indirectdraw
|
2018-09-13 22:46:17 +02:00
|
|
|
inlineuniformblocks
|
2018-07-15 18:18:41 +02:00
|
|
|
inputattachments
|
2017-11-12 19:32:09 +01:00
|
|
|
instancing
|
2022-11-03 19:27:51 +01:00
|
|
|
meshshader
|
2017-11-12 19:32:09 +01:00
|
|
|
multisampling
|
|
|
|
|
multithreading
|
2018-06-02 09:05:19 +02:00
|
|
|
multiview
|
2020-08-15 17:59:02 +02:00
|
|
|
negativeviewportheight
|
2017-11-12 19:32:09 +01:00
|
|
|
occlusionquery
|
|
|
|
|
offscreen
|
2020-08-21 16:27:06 +09:00
|
|
|
oit
|
2017-11-12 19:32:09 +01:00
|
|
|
parallaxmapping
|
2023-07-16 16:03:29 +02:00
|
|
|
particlesystem
|
2017-11-12 19:32:09 +01:00
|
|
|
pbrbasic
|
|
|
|
|
pbribl
|
|
|
|
|
pbrtexture
|
|
|
|
|
pipelines
|
|
|
|
|
pipelinestatistics
|
|
|
|
|
pushconstants
|
2018-03-09 13:48:54 +01:00
|
|
|
pushdescriptors
|
2017-11-12 19:32:09 +01:00
|
|
|
radialblur
|
2020-11-23 12:25:49 +01:00
|
|
|
rayquery
|
|
|
|
|
raytracingbasic
|
|
|
|
|
raytracingcallable
|
2023-11-01 10:55:33 +01:00
|
|
|
raytracinggltf
|
2023-05-13 14:55:18 +02:00
|
|
|
raytracingintersection
|
2020-08-15 17:59:02 +02:00
|
|
|
raytracingreflections
|
2022-09-08 12:57:00 -06:00
|
|
|
raytracingsbtdata
|
2023-04-09 13:43:24 +02:00
|
|
|
raytracingshadows
|
|
|
|
|
raytracingtextures
|
2017-11-12 19:32:09 +01:00
|
|
|
renderheadless
|
|
|
|
|
screenshot
|
2023-04-22 18:49:34 +02:00
|
|
|
shaderobjects
|
2017-11-12 19:32:09 +01:00
|
|
|
shadowmapping
|
|
|
|
|
shadowmappingomni
|
2017-12-09 21:12:55 +01:00
|
|
|
shadowmappingcascade
|
2017-11-12 19:32:09 +01:00
|
|
|
specializationconstants
|
|
|
|
|
sphericalenvmapping
|
|
|
|
|
ssao
|
|
|
|
|
stencilbuffer
|
|
|
|
|
subpasses
|
|
|
|
|
terraintessellation
|
|
|
|
|
tessellation
|
|
|
|
|
textoverlay
|
|
|
|
|
texture
|
|
|
|
|
texture3d
|
|
|
|
|
texturearray
|
|
|
|
|
texturecubemap
|
2020-07-19 07:07:54 +02:00
|
|
|
texturecubemaparray
|
2017-11-12 19:32:09 +01:00
|
|
|
texturemipmapgen
|
|
|
|
|
texturesparseresidency
|
|
|
|
|
triangle
|
2020-09-01 21:51:06 +02:00
|
|
|
variablerateshading
|
2021-12-26 18:42:03 +01:00
|
|
|
vertexattributes
|
2017-11-12 19:32:09 +01:00
|
|
|
viewportarray
|
|
|
|
|
vulkanscene
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
buildExamples()
|