-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
84 lines (60 loc) · 2.67 KB
/
CMakeLists.txt
File metadata and controls
84 lines (60 loc) · 2.67 KB
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
cmake_minimum_required(VERSION 3.20)
project("foray")
# Include Compiler Config (sets c++ 20 and compiler flags)
include("cmakescripts/compilerconfig.cmake")
include("cmakescripts/compileshader.cmake")
# Gather sources
file(GLOB_RECURSE src "src/*.cpp")
add_library(${PROJECT_NAME} STATIC ${src} )
# Set strict mode for project only
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS ${STRICT_FLAGS})
# dependencies
find_package(Vulkan REQUIRED)
# manual dependency variables
set(THIRD_PARTY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party" CACHE PATH "Third party libraries directory")
include("cmakescripts/locatesdl2.cmake") # Find SDL either by find_package or as a fallback the included version
# link dependency libs
target_link_libraries(
${PROJECT_NAME}
PUBLIC ${Vulkan_LIBRARIES}
PUBLIC glm_static
PUBLIC vkbootstrap
PUBLIC vma
PUBLIC tinygltf
PUBLIC tinyexr
PUBLIC imgui
PUBLIC ${SDL2_LIBRARIES}
)
# include directories
include_directories(
PUBLIC ${Vulkan_INCLUDE_DIRS}
PUBLIC ${SDL2_INCLUDE_DIRS}
)
include_directories(SYSTEM
PUBLIC ${THIRD_PARTY_DIR}
)
# subdirectories
add_subdirectory("src/shaders")
# Set nonstrict mode for third party stuff
set_property(GLOBAL PROPERTY COMPILE_FLAGS ${NONSTRICT_FLAGS})
add_subdirectory("$CACHE{THIRD_PARTY_DIR}/vma")
add_subdirectory("$CACHE{THIRD_PARTY_DIR}/vkbootstrap")
add_subdirectory("$CACHE{THIRD_PARTY_DIR}/glm")
add_subdirectory("$CACHE{THIRD_PARTY_DIR}/tinygltf")
add_subdirectory("$CACHE{THIRD_PARTY_DIR}/tinyexr")
add_subdirectory("$CACHE{THIRD_PARTY_DIR}/imgui")
# Set cache entry to shader dir
set(FORAY_SHADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/shaders" CACHE PATH "Foray shader directory")
# Precompiled header for third party libraries
option(FORAY_PRECOMPILE_THIRDPARTY_HEADERS "Enables packing third party includes into a precompiled header. Helps a little with build times." ON)
if (FORAY_PRECOMPILE_THIRDPARTY_HEADERS)
target_precompile_headers(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/foray_precompile.hpp")
endif()
option(FORAY_CATCH_EXCEPTIONS "Sets exception catch mode: OFF = No central exceptions catcher. Aids live debugging, but won't print error message to console. ON = Catch exceptions centrally and log error message." OFF)
if (FORAY_CATCH_EXCEPTIONS)
target_compile_definitions(${PROJECT_NAME} PUBLIC "FORAY_CATCH_EXCEPTIONS=1")
endif()
option(FORAY_DISABLE_RT "Disables calls to RT features in areas which do not strictly need it, such as AS building in scene. For when you want to work on a device which does not support RT." OFF)
if (FORAY_DISABLE_RT)
target_compile_definitions(${PROJECT_NAME} PUBLIC "FORAY_DISABLE_RT=1")
endif()