-
Notifications
You must be signed in to change notification settings - Fork 143
/
CMakeLists.txt
218 lines (186 loc) · 8.96 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
cmake_minimum_required(VERSION 2.8)
project(hlsl2glslfork)
set(CMAKE_SUPPRESS_REGENERATION TRUE)
set(HEADER_FILES
hlslang/Include/BaseTypes.h
hlslang/Include/Common.h
hlslang/Include/InfoSink.h
hlslang/Include/InitializeGlobals.h
hlslang/Include/InitializeParseContext.h
hlslang/Include/intermediate.h
hlslang/Include/PoolAlloc.h
hlslang/Include/Types.h
hlslang/MachineIndependent/SymbolTable.h
)
source_group("Header Files" FILES ${HEADER_FILES})
set(GLSL_CODE_GEN_FILES
hlslang/GLSLCodeGen/glslCommon.cpp
hlslang/GLSLCodeGen/glslCommon.h
hlslang/GLSLCodeGen/glslFunction.cpp
hlslang/GLSLCodeGen/glslFunction.h
hlslang/GLSLCodeGen/glslOutput.cpp
hlslang/GLSLCodeGen/glslOutput.h
hlslang/GLSLCodeGen/glslStruct.cpp
hlslang/GLSLCodeGen/glslStruct.h
hlslang/GLSLCodeGen/glslSymbol.cpp
hlslang/GLSLCodeGen/glslSymbol.h
hlslang/GLSLCodeGen/hlslCrossCompiler.cpp
hlslang/GLSLCodeGen/hlslCrossCompiler.h
hlslang/GLSLCodeGen/hlslLinker.cpp
hlslang/GLSLCodeGen/hlslLinker.h
hlslang/GLSLCodeGen/hlslSupportLib.cpp
hlslang/GLSLCodeGen/hlslSupportLib.h
hlslang/GLSLCodeGen/propagateMutable.cpp
hlslang/GLSLCodeGen/propagateMutable.h
hlslang/GLSLCodeGen/typeSamplers.cpp
hlslang/GLSLCodeGen/typeSamplers.h
)
source_group("GLSL Code Gen" FILES ${GLSL_CODE_GEN_FILES})
set(INCLUDE_FILES
include
)
source_group("include" FILES ${INCLUDE_FILES})
set(MACHINE_INDEPENDENT_FILES
hlslang/MachineIndependent/HLSL2GLSL.cpp
hlslang/MachineIndependent/hlslang.l
hlslang/MachineIndependent/hlslang.y
hlslang/MachineIndependent/InfoSink.cpp
hlslang/MachineIndependent/Initialize.cpp
hlslang/MachineIndependent/Initialize.h
hlslang/MachineIndependent/Intermediate.cpp
hlslang/MachineIndependent/intermOut.cpp
hlslang/MachineIndependent/IntermTraverse.cpp
hlslang/MachineIndependent/localintermediate.h
#hlslang/MachineIndependent/parseConst.cpp
hlslang/MachineIndependent/ParseHelper.cpp
hlslang/MachineIndependent/ParseHelper.h
hlslang/MachineIndependent/PoolAlloc.cpp
hlslang/MachineIndependent/RemoveTree.cpp
hlslang/MachineIndependent/RemoveTree.h
hlslang/MachineIndependent/SymbolTable.cpp
hlslang/MachineIndependent/SymbolTable.h
hlslang/MachineIndependent/ConstantFolding.cpp
)
source_group("Machine Independent" FILES ${MACHINE_INDEPENDENT_FILES})
set(MACHINE_INDEPENDENT_CPP_FILES
hlslang/MachineIndependent/preprocessor/mojoshader_common.cpp
hlslang/MachineIndependent/preprocessor/mojoshader_internal.h
hlslang/MachineIndependent/preprocessor/mojoshader_lexer.cpp
hlslang/MachineIndependent/preprocessor/mojoshader_preprocessor.cpp
hlslang/MachineIndependent/preprocessor/mojoshader.cpp
hlslang/MachineIndependent/preprocessor/mojoshader.h
hlslang/MachineIndependent/preprocessor/sourceloc.cpp
hlslang/MachineIndependent/preprocessor/sourceloc.h
)
source_group("Machine Independent\\CPP" FILES ${MACHINE_INDEPENDENT_CPP_FILES})
if (WIN32)
EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E write_regv \"${hkey}\" \"${dir}\"")
endif ()
set(MACHINE_INDEPENDENT_GENERATED_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/hlslang/MachineIndependent/Gen_hlslang.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hlslang/MachineIndependent/hlslang_tab.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hlslang/MachineIndependent/hlslang_tab.h
)
SET_SOURCE_FILES_PROPERTIES(${MACHINE_INDEPENDENT_GENERATED_SOURCE_FILES} PROPERTIES
GENERATED 1
)
source_group("Machine Independent\\Generated Source" FILES ${MACHINE_INDEPENDENT_GENERATED_SOURCE_FILES})
# Add system specific settings
if (WIN32)
set(OSDEPENDENT_FILES
hlslang/OSDependent/Windows/main.cpp
hlslang/OSDependent/Windows/osinclude.h
hlslang/OSDependent/Windows/ossource.cpp
)
source_group("OSDependent\\Windows" FILES ${OSDEPENDENT_FILES})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/hlslang/OSDependent/Windows)
add_custom_command(OUTPUT hlslang/MachineIndependent/Gen_hlslang_tab.cpp hlslang/MachineIndependent/hlslang_tab.h
COMMAND set ARGS "BISON_SIMPLE=../../tools/bison.simple"
COMMAND set ARGS "BISON_HAIRY=../../tools/bison.simple"
COMMAND ../../tools/bison.exe ARGS -d -t -v hlslang.y
COMMAND copy ARGS /y hlslang_tab.c Gen_hlslang_tab.cpp
COMMAND del ARGS hlslang_tab.c
COMMAND del ARGS hlslang.output
MAIN_DEPENDENCY hlslang/MachineIndependent/hlslang.y
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/hlslang/MachineIndependent
COMMENT "Executing Bison on hlslang.y"
)
add_custom_command(OUTPUT hlslang/MachineIndependent/Gen_hlslang.cpp
COMMAND ../../tools/flex.exe ARGS hlslang.l
MAIN_DEPENDENCY hlslang/MachineIndependent/hlslang.l
DEPENDS hlslang/MachineIndependent/hlslang_tab.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/hlslang/MachineIndependent
COMMENT "Executing flex on hlslang.l"
)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D\"_HAS_ITERATOR_DEBUGGING=0\" /D\"_SECURE_SCL=0\" /D\"_CRT_SECURE_NO_WARNINGS\"")
SET(TEST_LIBS opengl32.lib)
elseif (APPLE)
set(OSDEPENDENT_FILES
hlslang/OSDependent/Mac/osinclude.h
hlslang/OSDependent/Mac/ossource.cpp
)
source_group("OSDependent\\Mac" FILES ${OSDEPENDENT_FILES})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/hlslang/OSDependent/Mac)
add_custom_command(OUTPUT hlslang/MachineIndependent/Gen_hlslang_tab.cpp hlslang/MachineIndependent/hlslang_tab.h
COMMAND set ARGS "BISON_SIMPLE=../../tools/bison.simple"
COMMAND set ARGS "BISON_HAIRY=../../tools/bison.simple"
COMMAND bison ARGS -o hlslang_tab.cpp -d -t -v hlslang.y
COMMAND mv hlslang_tab.hpp hlslang_tab.h
MAIN_DEPENDENCY hlslang/MachineIndependent/hlslang.y
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/hlslang/MachineIndependent
COMMENT "Executing Bison on hlslang.y"
)
add_custom_command(OUTPUT hlslang/MachineIndependent/Gen_hlslang.cpp
COMMAND flex ARGS hlslang.l
MAIN_DEPENDENCY hlslang/MachineIndependent/hlslang.l
DEPENDS hlslang/MachineIndependent/hlslang_tab.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/hlslang/MachineIndependent
COMMENT "Executing flex on hlslang.l"
)
FIND_LIBRARY(OPENGL_LIBRARY OpenGL)
FIND_LIBRARY(COCOA_LIBRARY Cocoa)
SET(TEST_LIBS ${OPENGL_LIBRARY} ${COCOA_LIBRARY})
elseif (UNIX)
set(OSDEPENDENT_FILES
hlslang/OSDependent/Linux/osinclude.h
hlslang/OSDependent/Linux/ossource.cpp
)
source_group("OSDependent\\Linux" FILES ${OSDEPENDENT_FILES})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/hlslang/OSDependent/Linux)
add_custom_command(OUTPUT hlslang/MachineIndependent/hlslang_tab.cpp hlslang/MachineIndependent/hlslang_tab.h
COMMAND set ARGS "BISON_SIMPLE=../../tools/bison.simple"
COMMAND set ARGS "BISON_HAIRY=../../tools/bison.simple"
COMMAND bison ARGS -o hlslang_tab.cpp -d -t -v hlslang.y
COMMAND mv hlslang_tab.hpp hlslang_tab.h
MAIN_DEPENDENCY hlslang/MachineIndependent/hlslang.y
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/hlslang/MachineIndependent
COMMENT "Executing Bison on hlslang.y"
)
add_custom_command(OUTPUT hlslang/MachineIndependent/Gen_hlslang.cpp
COMMAND flex ARGS hlslang.l
MAIN_DEPENDENCY hlslang/MachineIndependent/hlslang.l
DEPENDS hlslang/MachineIndependent/hlslang_tab.h
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/hlslang/MachineIndependent
COMMENT "Executing flex on hlslang.l"
)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
SET(TEST_LIBS GL glut GLEW pthread)
endif ()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/hlslang
${CMAKE_CURRENT_SOURCE_DIR}/hlslang/MachineIndependent
)
add_library(hlsl2glsl
${HEADER_FILES}
${GLSL_CODE_GEN_FILES}
${INCLUDE_FILES}
${MACHINE_INDEPENDENT_FILES}
${MACHINE_INDEPENDENT_CPP_FILES}
${OSDEPENDENT_FILES}
${MACHINE_INDEPENDENT_GENERATED_SOURCE_FILES}
)
include_directories(
${INCLUDE_FILES}
)
add_executable(hlsl2glsltest tests/hlsl2glsltest/hlsl2glsltest.cpp)
target_link_libraries(hlsl2glsltest hlsl2glsl ${TEST_LIBS})