This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
107 lines (84 loc) · 3.26 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
cmake_minimum_required(VERSION 3.8)
project(vsm_vk)
############################################################
# paths
############################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_BINARY_DIR "${CMAKE_SOURCE_DIR}/build/${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}/${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(SCRIPT_DIR ${CMAKE_SOURCE_DIR}/script)
set(TEXTURE_DIR ${CMAKE_SOURCE_DIR}/data/textures)
set(MODEL_DIR ${CMAKE_SOURCE_DIR}/data/models)
############################################################
# flags
############################################################
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 11)
############################################################
# Vulkan loader
############################################################
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_WIN32_KHR")
else (WIN32)
message(FATAL_ERROR "unimplemented platform")
endif (WIN32)
# find the static Vulkan loader lib
find_package(Vulkan REQUIRED)
message(STATUS "dependency Vulkan_LIBRARY: ${Vulkan_LIBRARY}")
message(STATUS "dependency Vulkan_INCLUDE_DIR: ${Vulkan_INCLUDE_DIR}")
find_program(GLSLANG_VALIDATOR
NAMES glslangValidator
HINTS "${VULKAN_SDK}/Bin"
)
message(STATUS "dependency GLSLANG_VALIDATOR: ${GLSLANG_VALIDATOR}")
############################################################
# other dependencies
############################################################
# python3
set(PYTHON3_EXECUTABLE_DIR "C:/msys64/usr/bin" CACHE dependencies "python3 executable directory")
find_program(PYTHON3_EXECUTABLE REQUIRED
NAMES python3
HINTS "${PYTHON3_EXECUTABLE_DIR}"
)
message(STATUS "dependency PYTHON3_EXECUTABLE: ${PYTHON3_EXECUTABLE}")
# assimp
add_subdirectory(extern/assimp EXCLUDE_FROM_ALL)
############################################################
# include headers
############################################################
include_directories(
${Vulkan_INCLUDE_DIR}
extern/glm
extern/gli
extern/assimp/include
${CMAKE_CACHEFILE_DIR}/extern/assimp/include
base
)
############################################################
# definitions
############################################################
add_definitions(
-DGLM_FORCE_RADIANS
-DGLM_FORCE_DEPTH_ZERO_TO_ONE
-D_CRT_SECURE_NO_WARNINGS
-DNOMINMAX
-DTEXTURE_DIR="${TEXTURE_DIR}"
-DMODEL_DIR="${MODEL_DIR}"
-DENABLE_VULKAN_RENDERDOC_CAPTURE
)
############################################################
# macros
############################################################
macro(glsl_to_spirv src dst)
add_custom_command(OUTPUT ${src}.h
COMMAND ${PYTHON3_EXECUTABLE} ${SCRIPT_DIR}/glsl-to-spirv ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${dst}/${src}.h ${GLSLANG_VALIDATOR}
DEPENDS ${SCRIPT_DIR}/glsl-to-spirv ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${GLSLANG_VALIDATOR}
)
endmacro()
############################################################
# targets
############################################################
add_subdirectory(base)
add_subdirectory(shadow)