-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
72 lines (47 loc) · 1.87 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.27)
project(Innsmouth LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
include(cmake/ClangFormat.cmake)
include(cmake/Libraries.cmake)
FetchContent_MakeAvailable(glm)
FetchContent_MakeAvailable(volk)
FetchContent_MakeAvailable(imgui)
FetchContent_MakeAvailable(vulkan_memory_allocator)
FetchContent_MakeAvailable(spirv_reflect)
add_definitions(-DGLM_ENABLE_EXPERIMENTAL)
find_package(glfw3 REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-volatile")
set(CMAKE_BUILD_TYPE Debug)
add_definitions(-DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
add_subdirectory(innsmouth)
set(SHADER_FILES
${PROJECT_SOURCE_DIR}/shaders/sources/mesh/mesh.vert
${PROJECT_SOURCE_DIR}/shaders/sources/mesh/mesh.frag
${PROJECT_SOURCE_DIR}/shaders/sources/gui/gui.vert
${PROJECT_SOURCE_DIR}/shaders/sources/gui/gui.frag
${PROJECT_SOURCE_DIR}/shaders/sources/test/test.vert
${PROJECT_SOURCE_DIR}/shaders/sources/test/test.frag
${PROJECT_SOURCE_DIR}/shaders/sources/raytracing/canvas.vert
${PROJECT_SOURCE_DIR}/shaders/sources/raytracing/raytracing.frag
)
set(SHADER_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/shaders/spirv)
foreach(SHADER ${SHADER_FILES})
get_filename_component(SHADER_NAME ${SHADER} NAME)
set(SHADER_OUTPUT "${SHADER_OUTPUT_DIR}/${SHADER_NAME}.spv")
add_custom_command(
OUTPUT ${SHADER_OUTPUT}
COMMAND ${Vulkan_GLSLC_EXECUTABLE} -c --target-env=vulkan1.3 ${SHADER} -o ${SHADER_OUTPUT}
DEPENDS ${SHADER}
COMMENT "Compiling ${SHADER} to ${SHADER_OUTPUT}"
)
list(APPEND SPIRV_FILES ${SHADER_OUTPUT})
endforeach()
add_custom_target(shaders ALL DEPENDS ${SPIRV_FILES})
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
include(cmake/ClangFormat.cmake)
add_clang_format_target(format "build;external")
add_subdirectory(examples)
add_subdirectory(test)
endif()