forked from ConfettiFX/The-Forge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
180 lines (156 loc) · 4.83 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
cmake_minimum_required(VERSION 3.12.4)
get_directory_property(hasParent PARENT_DIRECTORY)
if(NOT hasParent)
option(unittests "unittests" OFF)
get_filename_component(_PARENT_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
set_property(GLOBAL PROPERTY GLOBAL_FETCHDEPS_BASE ${_PARENT_DIR}/al2o3 )
include(FetchContent)
FetchContent_Declare( al2o3 GIT_REPOSITORY https://github.com/DeanoC/al2o3 GIT_TAG master )
FetchContent_GetProperties(al2o3)
if(NOT al2o3_POPULATED)
FetchContent_Populate(al2o3)
add_subdirectory(${al2o3_SOURCE_DIR} ${al2o3_BINARY_DIR})
endif()
INIT_AL2O3(${CMAKE_CURRENT_SOURCE_DIR})
endif ()
#set(USE_D3D12 TRUE)
#set(USE_VULKAN TRUE)
#set(USE_D3D11 TRUE)
# windows supports USE_VULKAN, USE_D3D11 and USE_D3D12
# defaults to USE_D3D12
if (WIN32)
if(NOT USE_VULKAN AND NOT USE_D3D11)
set(USE_D3D12 TRUE)
endif()
if(USE_VULKAN)
find_package(Vulkan REQUIRED)
endif()
endif()
# TODO vulkan on metal support
if( APPLE)
set(USE_METAL TRUE)
set(USE_VULKAN FALSE)
endif()
SET_MIN_VERSIONS()
set(LibName gfx_theforge)
project(${LibName})
set(Deps
al2o3_platform
al2o3_memory
tiny_imageformat
)
set(Interface
enums.h
resourceloader.h
resourceloaders_structs.h
shaderreflection.h
structs.h
theforge.h
)
set(Src
theforge.cpp
OS/Core/Atomics.h
OS/Core/Compiler.h
OS/Core/DLL.h
OS/Core/RingBuffer.h
OS/Core/ThreadSystem.cpp
OS/Core/ThreadSystem.h
OS/Core/Timer.cpp
OS/Image/Image.cpp
OS/Image/Image.h
OS/Interfaces/ILog.h
OS/Interfaces/IMemory.h
OS/Interfaces/IOperatingSystem.h
OS/Interfaces/IProfiler.h
OS/Interfaces/IThread.h
OS/Interfaces/ITime.h
OS/Math/MathTypes.h
Renderer/CommonShaderReflection.cpp
Renderer/GpuProfiler.cpp
Renderer/GpuProfiler.h
Renderer/IRay.h
Renderer/IRenderer.h
Renderer/IShaderReflection.h
Renderer/ResourceLoader.cpp
Renderer/ResourceLoader.h
ThirdParty/OpenSource/EASTL/allocator_forge.cpp
ThirdParty/OpenSource/EASTL/assert.cpp
ThirdParty/OpenSource/EASTL/hashtable.cpp
ThirdParty/OpenSource/EASTL/numeric_limits.cpp
ThirdParty/OpenSource/EASTL/red_black_tree.cpp
ThirdParty/OpenSource/EASTL/string.cpp
ThirdParty/OpenSource/EASTL/thread_support.cpp
ThirdParty/OpenSource/EASTL/EAStdC/EASprintf.cpp
)
if (WIN32)
if(USE_D3D11)
list(APPEND Src Renderer/Direct3D11/Direct3D11.cpp)
list(APPEND Src Renderer/Direct3D11/Direct3D11Raytracing.cpp)
list(APPEND Src Renderer/Direct3D11/Direct3D11ShaderReflection.cpp)
endif()
if(USE_D3D12)
list(APPEND Src Renderer/Direct3D12/Direct3D12.cpp)
list(APPEND Src Renderer/Direct3D12/Direct3D12Hooks.cpp)
list(APPEND Src Renderer/Direct3D12/Direct3D12Hooks.h)
list(APPEND Src Renderer/Direct3D12/Direct3D12MemoryAllocator.cpp)
list(APPEND Src Renderer/Direct3D12/Direct3D12MemoryAllocator.h)
list(APPEND Src Renderer/Direct3D12/Direct3D12Raytracing.cpp)
list(APPEND Src Renderer/Direct3D12/Direct3D12ShaderReflection.cpp)
endif()
list(APPEND Src OS/Windows/WindowsThread.cpp)
list(APPEND Src OS/Windows/WindowsTime.cpp)
endif ()
if(USE_VULKAN)
list(APPEND Src Renderer/Vulkan/Vulkan.cpp)
list(APPEND Src Renderer/Vulkan/VulkanRaytracing.cpp)
list(APPEND Src Renderer/Vulkan/VulkanShaderReflection.cpp)
list(APPEND Src Renderer/Vulkan/VulkanCapsBuilder.h)
list(APPEND Src Tools/SpirvTools/SpirvTools.cpp)
list(APPEND Src Tools/SpirvTools/SpirvTools.h)
endif()
if (APPLE)
if( USE_METAL )
list(APPEND Src Renderer/Metal/MetalMemoryAllocator.h)
list(APPEND Src Renderer/Metal/MetalCapBuilder.h)
list(APPEND Src Renderer/Metal/MetalRaytracing.mm)
list(APPEND Src Renderer/Metal/MetalRenderer.mm)
list(APPEND Src Renderer/Metal/MetalShaderReflection.mm)
endif()
list(APPEND Src OS/Darwin/DarwinThread.cpp)
list(APPEND Src OS/Darwin/DarwinTime.cpp)
endif ()
ADD_LIB(${LibName} "${Interface}" "${Src}" "${Deps}")
if(USE_VULKAN)
add_compile_definitions(${LibName} VULKAN)
target_include_directories(${LibName} PRIVATE Vulkan::Vulkan)
target_link_libraries(${LibName} PRIVATE Vulkan::Vulkan)
endif()
if (APPLE)
add_compile_definitions(${LibName} METAL)
target_compile_options(${LibName} PRIVATE -fobjc-arc -ObjC++)
target_link_libraries(${LibName} PRIVATE
stdc++
objc
"-framework Foundation"
"-framework Cocoa"
"-framework IOKit"
"-framework Metal"
"-framework MetalKit"
"-framework MetalPerformanceShaders"
"-framework QuartzCore"
)
endif ()
if(WIN32)
if(USE_D3D12)
target_compile_definitions(${LibName} PRIVATE DIRECT3D12)
endif()
if(USE_D3D11)
target_compile_definitions(${LibName} PRIVATE DIRECT3D11)
endif()
target_link_libraries(${LibName} PRIVATE
winmm
${CMAKE_CURRENT_SOURCE_DIR}/src/ThirdParty/OpenSource/winpixeventruntime/bin/WinPixEventRuntime.lib)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/ThirdParty/OpenSource/winpixeventruntime/bin/WinPixEventRuntime.dll
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/WinPixEventRuntime.dll COPYONLY)
endif()