Updated the CMakeLists.txt

This commit is contained in:
ThatTanishqTak 2025-11-17 23:31:38 +00:00
parent 6de8bfa4ae
commit b0b336f987
2 changed files with 25 additions and 8 deletions

View file

@ -13,6 +13,13 @@ option(CLAY_INCLUDE_WIN32_GDI_EXAMPLES "Build Win32 GDI examples" OFF)
option(CLAY_INCLUDE_SOKOL_EXAMPLES "Build Sokol examples" OFF)
option(CLAY_INCLUDE_PLAYDATE_EXAMPLES "Build Playdate examples" OFF)
# Enable Vulkan demo by default when the Windows generator can see a Vulkan SDK installation.
set(CLAY_INCLUDE_VULKAN_DEMO_DEFAULT OFF)
if(WIN32 AND DEFINED ENV{VULKAN_SDK})
set(CLAY_INCLUDE_VULKAN_DEMO_DEFAULT ON)
endif()
option(CLAY_INCLUDE_VULKAN_DEMO "Build Vulkan demo (requires Vulkan SDK)" ${CLAY_INCLUDE_VULKAN_DEMO_DEFAULT})
message(STATUS "CLAY_INCLUDE_DEMOS: ${CLAY_INCLUDE_DEMOS}")
if(APPLE)
@ -44,6 +51,9 @@ if(CLAY_INCLUDE_ALL_EXAMPLES OR CLAY_INCLUDE_SOKOL_EXAMPLES)
add_subdirectory("examples/sokol-video-demo")
add_subdirectory("examples/sokol-corner-radius")
endif()
if(CLAY_INCLUDE_ALL_EXAMPLES OR CLAY_INCLUDE_VULAKN_EXAMPLES)
add_subdirectory("examples/vulkan-demo")
endif()
# Playdate example not included in ALL because users need to install the playdate SDK first which requires a license agreement
if(CLAY_INCLUDE_PLAYDATE_EXAMPLES)

View file

@ -8,6 +8,10 @@ include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
# GLFW is used only for window creation and Vulkan surface management in this demo.
# When other examples are enabled (e.g., raylib), GLFW may already be present via
# their dependencies. Guarding the population prevents duplicate target errors
# (CMP0002) while still reusing the existing GLFW target when available.
if(NOT TARGET glfw)
FetchContent_Declare(
glfw
GIT_REPOSITORY "https://github.com/glfw/glfw.git"
@ -16,6 +20,9 @@ FetchContent_Declare(
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(glfw)
else()
message(STATUS "Reusing existing GLFW target for Vulkan demo")
endif()
find_package(Vulkan REQUIRED)