forked from LukasBanana/XShaderCompiler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
277 lines (213 loc) · 8.57 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# === CMake lists for the XShaderCompiler - (09/10/2014) ===
cmake_minimum_required(VERSION 2.8)
project(XShaderCompiler)
# === Build path ===
set(BUILD_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/build")
set(INSTALL_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/install" CACHE PATH "Installation directory" FORCE)
macro(XSC_OUTPUT_PATHS TARGET_PROJECT)
set_target_properties(
${TARGET_PROJECT}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${BUILD_OUTPUT_PATH}"
LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_PATH}"
RUNTIME_OUTPUT_DIRECTORY "${BUILD_OUTPUT_PATH}"
)
endmacro()
# === Options ===
# Main
option(XSC_BUILD_SHELL "Build XShaderCompiler shell 'xsc'" ON)
option(XSC_BUILD_DEBUGGER "Build XShaderCompiler debugger 'xsc_debugger' (requires wxWidgets library)" OFF)
option(XSC_BUILD_TESTS "Build all test applications" OFF)
option(XSC_SHARED_LIB "Build XShaderCompiler as a shared library instead of a static library" OFF)
# Wrappers
option(XSC_BUILD_WRAPPER_C "Build C wrapper (ISO C99)" OFF)
option(XSC_BUILD_WRAPPER_CSHARP "Build C# wrapper" OFF)
# Specials
option(XSC_ENABLE_EASTER_EGGS "Enables little easter eggs" OFF)
option(XSC_ENABLE_POST_VALIDATION "Enables the post validation in presettings with 'glslangValidator'" OFF)
option(XSC_ENABLE_LANGUAGE_EXT "Enables a few language extensions (e.g. 'space' attribute for stronger type system)" OFF)
option(XSC_ENABLE_SPIRV "Enables all SPIR-V related features (experimental; requires submodule in 'external/SPIR-V')" OFF)
#set(XSC_REPORT_LANGUAGE "EN" CACHE STRING "Language of the report output (supported values: 'EN')")
# === Preprocessor definitions ===
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
if(XSC_SHARED_LIB)
add_definitions(-DXSC_SHARED_LIB)
endif()
if(XSC_ENABLE_EASTER_EGGS)
add_definitions(-DXSC_ENABLE_EASTER_EGGS)
endif()
if(XSC_ENABLE_POST_VALIDATION)
add_definitions(-DXSC_ENABLE_POST_VALIDATION)
endif()
if(XSC_ENABLE_LANGUAGE_EXT)
add_definitions(-DXSC_ENABLE_LANGUAGE_EXT)
endif()
if(XSC_ENABLE_SPIRV)
add_definitions(-DXSC_ENABLE_SPIRV)
endif()
# === Global files ===
file(GLOB FilesInc ${PROJECT_SOURCE_DIR}/inc/Xsc/*.*)
file(GLOB FilesIncC ${PROJECT_SOURCE_DIR}/inc/XscC/*.*)
file(GLOB FilesSrcCompiler ${PROJECT_SOURCE_DIR}/src/Compiler/*.*)
file(GLOB FilesSrcCompilerAST ${PROJECT_SOURCE_DIR}/src/Compiler/AST/*.*)
file(GLOB FilesSrcCompilerASTVisitor ${PROJECT_SOURCE_DIR}/src/Compiler/AST/Visitor/*.*)
file(GLOB FilesSrcCompilerFrontend ${PROJECT_SOURCE_DIR}/src/Compiler/Frontend/*.*)
file(GLOB FilesSrcCompilerFrontendHLSL ${PROJECT_SOURCE_DIR}/src/Compiler/Frontend/HLSL/*.*)
file(GLOB FilesSrcCompilerFrontendGLSL ${PROJECT_SOURCE_DIR}/src/Compiler/Frontend/GLSL/*.*)
file(GLOB FilesSrcCompilerBackend ${PROJECT_SOURCE_DIR}/src/Compiler/Backend/*.*)
file(GLOB FilesSrcCompilerBackendGLSL ${PROJECT_SOURCE_DIR}/src/Compiler/Backend/GLSL/*.*)
file(GLOB FilesSrcCompilerReport ${PROJECT_SOURCE_DIR}/src/Compiler/Report/*.*)
file(GLOB FilesSrcCompilerCFG ${PROJECT_SOURCE_DIR}/src/Compiler/CFG/*.*)
file(GLOB FilesSrcShell ${PROJECT_SOURCE_DIR}/src/Shell/*.*)
file(GLOB FilesSrcDebugger ${PROJECT_SOURCE_DIR}/src/Debugger/*.*)
file(GLOB FilesSrcWrapperC ${PROJECT_SOURCE_DIR}/src/Wrapper/C/*.*)
#file(GLOB FilesSrcWrapperCSharp ${PROJECT_SOURCE_DIR}/src/Wrapper/CSharp/*.*)
set(FilesTest ${PROJECT_SOURCE_DIR}/test)
if(WIN32)
file(GLOB FilesSrcCompilerPlatform ${PROJECT_SOURCE_DIR}/src/Compiler/Platform/Win32/*.*)
else()
file(GLOB FilesSrcCompilerPlatform ${PROJECT_SOURCE_DIR}/src/Compiler/Platform/Unix/*.*)
endif()
set(
FilesCompilerAll
${FilesInc}
${FilesSrcCompiler}
${FilesSrcCompilerAST}
${FilesSrcCompilerASTVisitor}
${FilesSrcCompilerPlatform}
${FilesSrcCompilerFrontend}
${FilesSrcCompilerFrontendHLSL}
${FilesSrcCompilerFrontendGLSL}
${FilesSrcCompilerBackend}
${FilesSrcCompilerBackendGLSL}
${FilesSrcCompilerReport}
)
if(XSC_ENABLE_SPIRV)
set(FilesCompilerAll ${FilesCompilerAll} ${FilesSrcCompilerCFG})
endif()
# === Source group folders ===
source_group("inc\\Xsc" FILES ${FilesInc})
source_group("inc\\XscC" FILES ${FilesIncC})
source_group("src" FILES ${FilesSrcCompiler} ${FilesSrcShell} ${FilesSrcDebugger})
source_group("src\\AST" FILES ${FilesSrcCompilerAST})
source_group("src\\AST\\Visitor" FILES ${FilesSrcCompilerASTVisitor})
source_group("src\\Platform" FILES ${FilesSrcCompilerPlatform})
source_group("src\\Frontend" FILES ${FilesSrcCompilerFrontend})
source_group("src\\Frontend\\HLSL" FILES ${FilesSrcCompilerFrontendHLSL})
source_group("src\\Frontend\\GLSL" FILES ${FilesSrcCompilerFrontendGLSL})
source_group("src\\Backend" FILES ${FilesSrcCompilerBackend})
source_group("src\\Backend\\GLSL" FILES ${FilesSrcCompilerBackendGLSL})
source_group("src\\Report" FILES ${FilesSrcCompilerReport})
if(XSC_ENABLE_SPIRV)
source_group("src\\CFG" FILES ${FilesSrcCompilerCFG})
endif()
# === Include directories ===
include_directories("${PROJECT_SOURCE_DIR}/inc")
include_directories("${PROJECT_SOURCE_DIR}/src/Compiler")
include_directories("${PROJECT_SOURCE_DIR}/src/Compiler/AST")
include_directories("${PROJECT_SOURCE_DIR}/src/Compiler/AST/Visitor")
include_directories("${PROJECT_SOURCE_DIR}/src/Compiler/Frontend")
include_directories("${PROJECT_SOURCE_DIR}/src/Compiler/Frontend/HLSL")
include_directories("${PROJECT_SOURCE_DIR}/src/Compiler/Frontend/GLSL")
include_directories("${PROJECT_SOURCE_DIR}/src/Compiler/Backend")
include_directories("${PROJECT_SOURCE_DIR}/src/Compiler/Backend/GLSL")
include_directories("${PROJECT_SOURCE_DIR}/src/Compiler/Report")
if(XSC_ENABLE_SPIRV)
include_directories("${PROJECT_SOURCE_DIR}/src/Compiler/CFG")
include_directories("${PROJECT_SOURCE_DIR}/external/SPIR-V/include")
endif()
# === Executable ===
# Library core
if(XSC_SHARED_LIB)
add_library(xsc_core SHARED ${FilesCompilerAll})
else()
add_library(xsc_core STATIC ${FilesCompilerAll})
endif()
XSC_OUTPUT_PATHS(xsc_core)
set_target_properties(xsc_core PROPERTIES LINKER_LANGUAGE CXX)
target_compile_features(xsc_core PRIVATE cxx_range_for)
set(XSC_INSTALL_TARGETS "xsc_core")
# Shell application
if(XSC_BUILD_SHELL)
add_executable(xsc ${FilesSrcShell})
XSC_OUTPUT_PATHS(xsc)
set_target_properties(xsc PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(xsc xsc_core)
target_compile_features(xsc PRIVATE cxx_range_for)
set(XSC_INSTALL_TARGETS ${XSC_INSTALL_TARGETS} "xsc")
endif()
# Debugger UI aplication
if(XSC_BUILD_DEBUGGER)
if(WIN32)
add_executable(xsc_debugger WIN32 ${FilesSrcDebugger} "${PROJECT_SOURCE_DIR}/src/Debugger/Resources.rc")
else()
add_executable(xsc_debugger ${FilesSrcDebugger})
endif()
XSC_OUTPUT_PATHS(xsc_debugger)
set_target_properties(xsc_debugger PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(xsc_debugger xsc_core)
target_compile_features(xsc_debugger PRIVATE cxx_range_for)
# wxWidgets Libs
find_package(wxWidgets REQUIRED adv aui base core stc propgrid richtext html xml scintilla)
if(wxWidgets_FOUND)
message("Found wxWidgets library")
include_directories(${wxWidgets_INCLUDE_DIRS})
target_link_libraries(xsc_debugger ${wxWidgets_LIBRARIES})
else(wxWidgets_FOUND)
message(SEND_ERROR "Missing wxWidgets library")
endif(wxWidgets_FOUND)
set(XSC_INSTALL_TARGETS ${XSC_INSTALL_TARGETS} "xsc_debugger")
endif()
# C wrapper
if(XSC_BUILD_WRAPPER_C)
if(XSC_SHARED_LIB)
add_library(xsc_core_c SHARED ${FilesSrcWrapperC})
else()
add_library(xsc_core_c STATIC ${FilesSrcWrapperC})
endif()
XSC_OUTPUT_PATHS(xsc_core_c)
set_target_properties(xsc_core_c PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(xsc_core_c xsc_core)
target_compile_features(xsc_core_c PRIVATE cxx_range_for)
set(XSC_INSTALL_TARGETS ${XSC_INSTALL_TARGETS} "xsc_core_c")
endif()
# C# wrapper
if(WIN32 AND XSC_BUILD_WRAPPER_CSHARP)
add_subdirectory(src/Wrapper/CSharp)
endif()
if(XSC_BUILD_TESTS)
# Test C wrapper
if(XSC_BUILD_WRAPPER_C)
add_executable(XscTest_CWrapper "${FilesTest}/XscTest_CWrapper.c")
XSC_OUTPUT_PATHS(XscTest_CWrapper)
set_target_properties(XscTest_CWrapper PROPERTIES LINKER_LANGUAGE C)
target_link_libraries(XscTest_CWrapper xsc_core_c)
endif()
endif()
# === Show summary ===
message("~~~ Build Summary ~~~")
if(XSC_SHARED_LIB)
message("Build Core: xsc_core (SHARED)")
else()
message("Build Core: xsc_core (STATIC)")
endif()
if(XSC_BUILD_SHELL)
message("Build Shell: xsc")
endif()
if(XSC_BUILD_DEBUGGER)
message("Build Debugger: xsc_debugger")
endif()
if(XSC_BUILD_WRAPPER_C)
message("Build C Wrapper: xsc_core_c")
endif()
if(XSC_BUILD_WRAPPER_CSHARP)
message("Build C# Wrapper: xsc_core_csharp")
endif()
if(XSC_ENABLE_SPIRV)
message("Include SPIR-V (Experimental)")
endif()
# === Installation Rules ===
install(
TARGETS ${XSC_INSTALL_TARGETS}
DESTINATION ${INSTALL_OUTPUT_PATH}
)