From b0b336f98790b0697901fcd73dbc690b900c0539 Mon Sep 17 00:00:00 2001 From: ThatTanishqTak Date: Mon, 17 Nov 2025 23:31:38 +0000 Subject: [PATCH] Updated the CMakeLists.txt --- CMakeLists.txt | 10 ++++++++++ examples/vulkan-demo/CMakeLists.txt | 23 +++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 191b2f7..d23b65e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/examples/vulkan-demo/CMakeLists.txt b/examples/vulkan-demo/CMakeLists.txt index d2cfd90..192fac5 100644 --- a/examples/vulkan-demo/CMakeLists.txt +++ b/examples/vulkan-demo/CMakeLists.txt @@ -8,14 +8,21 @@ include(FetchContent) set(FETCHCONTENT_QUIET FALSE) # GLFW is used only for window creation and Vulkan surface management in this demo. -FetchContent_Declare( - glfw - GIT_REPOSITORY "https://github.com/glfw/glfw.git" - GIT_TAG "3.4" - GIT_PROGRESS TRUE - GIT_SHALLOW TRUE -) -FetchContent_MakeAvailable(glfw) +# 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" + GIT_TAG "3.4" + GIT_PROGRESS TRUE + GIT_SHALLOW TRUE + ) + FetchContent_MakeAvailable(glfw) +else() + message(STATUS "Reusing existing GLFW target for Vulkan demo") +endif() find_package(Vulkan REQUIRED)