diff options
Diffstat (limited to 'cpp-timeplot/CMakeLists.txt')
| -rw-r--r-- | cpp-timeplot/CMakeLists.txt | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/cpp-timeplot/CMakeLists.txt b/cpp-timeplot/CMakeLists.txt new file mode 100644 index 0000000..58993dd --- /dev/null +++ b/cpp-timeplot/CMakeLists.txt @@ -0,0 +1,87 @@ +cmake_minimum_required(VERSION 3.20) +project(timeplot-cpp VERSION 0.1.0) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Find dependencies +find_package(PkgConfig REQUIRED) + +# GLFW for windowing +pkg_check_modules(GLFW REQUIRED glfw3) + +# Use precompiled Dawn from Chromium +option(USE_SYSTEM_DAWN "Use system-installed Dawn" OFF) + +if(USE_SYSTEM_DAWN) + find_package(dawn REQUIRED) +else() + # Download precompiled Dawn binaries + message(STATUS "Downloading precompiled Dawn...") + + set(DAWN_VERSION "6536") + set(DAWN_DIR "${CMAKE_BINARY_DIR}/dawn-prebuilt") + + if(NOT EXISTS "${DAWN_DIR}") + # Try to download from a prebuilt source + # Note: Dawn doesn't officially provide prebuilt binaries, so we'll build once and cache + # For now, let's use webgpu-distribution which provides prebuilt headers + include(FetchContent) + + # Fetch webgpu-distribution (lighter than full Dawn) + FetchContent_Declare( + webgpu-distribution + GIT_REPOSITORY https://github.com/eliemichel/WebGPU-distribution + GIT_TAG main + GIT_SHALLOW TRUE + ) + + FetchContent_MakeAvailable(webgpu-distribution) + + set(WEBGPU_BACKEND "WGPU" CACHE STRING "Backend to use") + + # Fetch webgpu-hpp (C++ wrapper) + FetchContent_Declare( + webgpu-hpp + GIT_REPOSITORY https://github.com/eliemichel/WebGPU-Cpp + GIT_TAG main + GIT_SHALLOW TRUE + ) + FetchContent_MakeAvailable(webgpu-hpp) + + # Fetch glfw3webgpu (GLFW-WebGPU integration) + FetchContent_Declare( + glfw3webgpu + GIT_REPOSITORY https://github.com/eliemichel/glfw3webgpu + GIT_TAG main + GIT_SHALLOW TRUE + ) + FetchContent_MakeAvailable(glfw3webgpu) + endif() +endif() + +# Source files +set(SOURCES + src/main.cpp + src/renderer.cpp + src/waterfall.cpp + src/webgpu_impl.cpp +) + +add_executable(timeplot ${SOURCES}) + +target_include_directories(timeplot PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${GLFW_INCLUDE_DIRS} +) + +target_link_libraries(timeplot PRIVATE + ${GLFW_LIBRARIES} + webgpu + glfw3webgpu +) + +# Copy shaders to build directory +file(GLOB SHADERS "${CMAKE_CURRENT_SOURCE_DIR}/shaders/*.wgsl") +file(COPY ${SHADERS} DESTINATION ${CMAKE_BINARY_DIR}/shaders) |
