-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
92 lines (74 loc) · 2.07 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
cmake_minimum_required(VERSION 3.18)
project(vulkan-playground LANGUAGES CXX)
find_package(Vulkan REQUIRED FATAL_ERROR)
find_package(glfw3 REQUIRED FATAL_ERROR)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_subdirectory(dep)
add_executable(${CMAKE_PROJECT_NAME})
target_sources(${CMAKE_PROJECT_NAME}
PRIVATE
"src/stb_image.h"
"src/tiny_obj_loader.h"
#"src/ui.hpp"
#"src/ui.cpp"
"src/device.hpp"
"src/device.cpp"
"src/swapchain.hpp"
"src/swapchain.cpp"
"src/debug.hpp"
"src/debug.cpp"
"src/window.hpp"
"src/window.cpp"
"src/utils.hpp"
"src/utils.cpp"
"src/camera.hpp"
"src/camera.cpp"
"src/events.hpp"
"src/events.cpp"
"src/main.cpp"
)
file(GLOB_RECURSE GLSL_SOURCE_FILES "shaders/*.frag" "shaders/*.vert")
target_sources(${CMAKE_PROJECT_NAME}
PRIVATE
${GLSL_SOURCE_FILES}
)
source_group("Shaders" FILES ${GLSL_SOURCE_FILES})
target_include_directories(${CMAKE_PROJECT_NAME}
PRIVATE
${Vulkan_INCLUDE_DIRS}
)
target_link_libraries(${CMAKE_PROJECT_NAME}
PRIVATE
${Vulkan_LIBRARIES}
glfw
imgui
)
target_compile_definitions(${CMAKE_PROJECT_NAME}
PRIVATE
GLFW_INCLUDE_VULKAN
STB_IMAGE_IMPLEMENTATION
TINYOBJLOADER_IMPLEMENTATION
GLM_ENABLE_EXPERIMENTAL
GLM_FORCE_RADIANS
GLM_FORCE_DEPTH_ZERO_TO_ONE
)
set(GLSL_VALIDATOR "glslangValidator")
foreach(GLSL ${GLSL_SOURCE_FILES})
get_filename_component(FILE_NAME ${GLSL} NAME)
set(SPIRV "${PROJECT_BINARY_DIR}/shaders/${FILE_NAME}.spv")
add_custom_command(
OUTPUT ${SPIRV}
COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/shaders/"
COMMAND ${GLSL_VALIDATOR} -V ${GLSL} -o ${SPIRV}
DEPENDS ${GLSL}
)
list(APPEND SPIRV_BINARY_FILES ${SPIRV})
endforeach()
add_custom_target(shaders DEPENDS ${SPIRV_BINARY_FILES})
add_dependencies(${CMAKE_PROJECT_NAME} shaders)
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:vulkan-playground>/resources/"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/resources/" "$<TARGET_FILE_DIR:vulkan-playground>/resources/"
)