-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
111 lines (93 loc) · 2.97 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
cmake_minimum_required(VERSION 3.0)
project(cranks-renderer C CXX)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
endif()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVK_PROTOTYPES")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES /EHsc /ZI")
# GLFW
set(GLFW_DIR third_party/glfw) # Set this to point to an up-to-date GLFW repo
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
option(GLFW_INSTALL "Generate installation target" OFF)
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
add_subdirectory(${GLFW_DIR} binary_dir EXCLUDE_FROM_ALL)
include_directories(${GLFW_DIR}/include)
# Dear ImGui
set(IMGUI_DIR third_party/imgui)
include_directories(${IMGUI_DIR} ${IMGUI_DIR}/backends ..)
# xc imgui source
file(GLOB IMGUI_CODE
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
${IMGUI_DIR}/backends/imgui_impl_vulkan.cpp
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_demo.cpp
${IMGUI_DIR}/imgui_tables.cpp
${IMGUI_DIR}/imgui_widgets.cpp
)
# imgui file dialog
set(IMGUI_FILE_DIALOG_DIR third_party/imgui_file_dialog)
include_directories(${IMGUI_FILE_DIALOG_DIR})
file(GLOB IMGUI_FILE_DIALOG_CODE
${IMGUI_FILE_DIALOG_DIR}/ImGuiFileDialog.cpp
)
# base64 source
file(GLOB BASE64_CODE
third_party/base64/base64.h
third_party/base64/base64.c
)
# Libraries
find_package(Vulkan REQUIRED)
#find_library(VULKAN_LIBRARY
#NAMES vulkan vulkan-1)
#set(LIBRARIES "glfw;${VULKAN_LIBRARY}")
set(LIBRARIES "glfw;Vulkan::Vulkan")
# Use vulkan headers from glfw:
include_directories(${GLFW_DIR}/deps)
# file(GLOB sources src/*.cpp)
# cranks-renderer code
file(GLOB PBR_CODE
src/main.cpp
src/renderer_ui.h
src/renderer_ui.cpp
src/gui_main.h
src/gui_main.cpp
src/vulkan/*.h
src/vulkan/*.cpp
src/core/*.h
src/core/*.cpp
src/shape/*.h
src/shape/*.cpp
src/tool/*.h
src/tool/*.cpp
src/texture/*.h
src/texture/*.cpp
src/light/*.h
src/light/*.cpp
src/integrator/*.h
src/integrator/*.cpp
src/base/*.h
src/base/*.cpp
)
# SOURCE_GROUP(PBR_CODE FILES ${PBR_CODE_FILES})
source_group(cranks-renderer src)
source_group(base src/base)
source_group(core src/core)
source_group(shape src/shape)
source_group(tool src/tool)
source_group(light src/light)
source_group(integrator src/integrator)
source_group(texture src/texture)
source_group(vulkan src/vulkan)
source_group(third_party/imgui ${IMGUI_DIR})
source_group(third_party/imgui_file_dialog ${IMGUI_FILE_DIALOG_DIR})
add_executable(cranks-renderer ${PBR_CODE} ${IMGUI_CODE} ${BASE64_CODE} ${IMGUI_FILE_DIALOG_CODE})
target_link_libraries(cranks-renderer ${LIBRARIES})
target_compile_definitions(cranks-renderer PUBLIC -DImTextureID=ImU64)
# c++ 20
target_compile_features(cranks-renderer PRIVATE cxx_std_20)
# linker generate debug info
target_link_options(cranks-renderer PUBLIC /DEBUG)