blob: 5ae12befc140158950e33a37a9f84c99e4ab65cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
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
)
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)
|