-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
136 lines (109 loc) · 4.66 KB
/
CMakeLists.txt
File metadata and controls
136 lines (109 loc) · 4.66 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
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
cmake_minimum_required (VERSION 3.10)
if(NOT DILIGENT_CORE_FOUND)
message(FATAL_ERROR "DiligentCore module is not found. Please add DiligentCore module to the project before DiligentFX module.")
endif()
if(NOT DILIGENT_TOOLS_FOUND)
message(FATAL_ERROR "DiligentTools module is not found. Please add DiligentTools module to the project before DiligentFX module.")
endif()
set(DILIGENT_FX_FOUND TRUE CACHE INTERNAL "DiligentFX module is found")
include(BuildUtils.cmake)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
project(DiligentFX CXX)
file(GLOB_RECURSE SHADERS LIST_DIRECTORIES false Shaders/*.*)
add_library(DiligentFX STATIC README.md ${SHADERS})
file(RELATIVE_PATH DILIGENT_FX_DIR "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS OR PLATFORM_LINUX OR PLATFORM_MACOS OR PLATFORM_IOS OR PLATFORM_TVOS OR PLATFORM_WEB)
option(DILIGENT_INSTALL_FX "Install DiligentFX module headers and libraries" ON)
else()
set(DILIGENT_INSTALL_FX OFF)
endif()
target_link_libraries(DiligentFX
PRIVATE
Diligent-BuildSettings
PUBLIC
Diligent-GraphicsEngine
Diligent-GraphicsTools
Diligent-AssetLoader
Diligent-TextureLoader
Diligent-Imgui
)
if (TARGET Diligent-HLSL2GLSLConverterLib)
target_compile_definitions(DiligentFX PRIVATE HLSL2GLSL_CONVERTER_SUPPORTED=1)
endif()
set_common_target_properties(DiligentFX)
target_include_directories(DiligentFX
PUBLIC
.
)
add_subdirectory(Utilities)
add_subdirectory(Components)
add_subdirectory(PostProcess)
add_subdirectory(PBR)
if(DILIGENT_USD_PATH)
add_subdirectory(Hydrogent)
endif()
add_subdirectory(Tests)
get_target_property(SOURCE DiligentFX SOURCES)
foreach(FILE ${SOURCE})
# Get the directory of the source file
get_filename_component(PARENT_DIR "${FILE}" DIRECTORY)
# Remove common directory prefix to make the group
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" GROUP "${PARENT_DIR}")
# Make sure we are using windows slashes
string(REPLACE "/" "\\" GROUP "${GROUP}")
source_group("${GROUP}" FILES "${FILE}")
endforeach()
# Convert shaders to headers and generate master header with the list of all files
set(SHADER_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/shaders_inc)
file(MAKE_DIRECTORY ${SHADER_OUTPUT_DIR})
target_include_directories(DiligentFX PRIVATE ${SHADER_OUTPUT_DIR})
set(SHADERS_LIST_FILE ${SHADER_OUTPUT_DIR}/shaders_list.h)
convert_shaders_to_headers("${SHADERS}" ${SHADER_OUTPUT_DIR} ${SHADERS_LIST_FILE} SHADERS_INC_LIST)
target_sources(DiligentFX PRIVATE
# A target created in the same directory (CMakeLists.txt file) that specifies any output of the
# custom command as a source file is given a rule to generate the file using the command at build time.
${SHADERS_INC_LIST}
${SHADERS_LIST_FILE}
)
source_group("generated" FILES
${SHADERS_LIST_FILE}
${SHADERS_INC_LIST}
)
if(DILIGENT_INSTALL_FX)
install(TARGETS DiligentFX
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_FX_DIR}/$<CONFIG>"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${DILIGENT_FX_DIR}/$<CONFIG>"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${DILIGENT_FX_DIR}/$<CONFIG>"
)
install(DIRECTORY PostProcess/EpipolarLightScattering/interface
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${DILIGENT_FX_DIR}/PostProcess/EpipolarLightScattering"
)
install(DIRECTORY PostProcess/TemporalAntiAliasing/interface
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${DILIGENT_FX_DIR}/PostProcess/TemporalAntiAliasing"
)
install(DIRECTORY PostProcess/ScreenSpaceReflection/interface
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${DILIGENT_FX_DIR}/PostProcess/ScreenSpaceReflection"
)
install(DIRECTORY PostProcess/ScreenSpaceAmbientOcclusion/interface
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${DILIGENT_FX_DIR}/PostProcess/ScreenSpaceAmbientOcclusion"
)
install(DIRECTORY PostProcess/Bloom/interface
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${DILIGENT_FX_DIR}/PostProcess/Bloom"
)
install(DIRECTORY Components/interface
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${DILIGENT_FX_DIR}/Components"
)
install(DIRECTORY PBR/interface
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${DILIGENT_FX_DIR}/PBR"
)
install(DIRECTORY Shaders
DESTINATION "."
FILES_MATCHING PATTERN "public/*.*"
PATTERN "private" EXCLUDE
)
endif()
set_target_properties(DiligentFX PROPERTIES
FOLDER DiligentFX
)
# Create a custom target to run source code formatting validation command
add_format_validation_target(DiligentFX "${CMAKE_CURRENT_SOURCE_DIR}" DiligentFX)