1 # Copyright (C) 2020 The Khronos Group Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
9 # Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
12 # Redistributions in binary form must reproduce the above
13 # copyright notice, this list of conditions and the following
14 # disclaimer in the documentation and/or other materials provided
15 # with the distribution.
17 # Neither the name of The Khronos Group Inc. nor the names of its
18 # contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
35 add_subdirectory(OSDependent/Windows)
37 add_subdirectory(OSDependent/Unix)
39 message("unknown platform")
42 if(EMSCRIPTEN OR ENABLE_GLSLANG_JS)
43 # May be enabled on non-Emscripten builds for binary-size testing.
44 add_subdirectory(OSDependent/Web)
45 endif(EMSCRIPTEN OR ENABLE_GLSLANG_JS)
47 ################################################################################
49 ################################################################################
50 add_library(GenericCodeGen STATIC
51 GenericCodeGen/CodeGen.cpp
52 GenericCodeGen/Link.cpp)
53 set_property(TARGET GenericCodeGen PROPERTY POSITION_INDEPENDENT_CODE ON)
54 set_property(TARGET GenericCodeGen PROPERTY FOLDER glslang)
56 ################################################################################
58 ################################################################################
59 set(MACHINEINDEPENDENT_SOURCES
60 MachineIndependent/glslang.m4
61 MachineIndependent/glslang.y
62 MachineIndependent/glslang_tab.cpp
63 MachineIndependent/attribute.cpp
64 MachineIndependent/Constant.cpp
65 MachineIndependent/iomapper.cpp
66 MachineIndependent/InfoSink.cpp
67 MachineIndependent/Initialize.cpp
68 MachineIndependent/IntermTraverse.cpp
69 MachineIndependent/Intermediate.cpp
70 MachineIndependent/ParseContextBase.cpp
71 MachineIndependent/ParseHelper.cpp
72 MachineIndependent/PoolAlloc.cpp
73 MachineIndependent/RemoveTree.cpp
74 MachineIndependent/Scan.cpp
75 MachineIndependent/ShaderLang.cpp
76 MachineIndependent/SymbolTable.cpp
77 MachineIndependent/Versions.cpp
78 MachineIndependent/intermOut.cpp
79 MachineIndependent/limits.cpp
80 MachineIndependent/linkValidate.cpp
81 MachineIndependent/parseConst.cpp
82 MachineIndependent/reflection.cpp
83 MachineIndependent/preprocessor/Pp.cpp
84 MachineIndependent/preprocessor/PpAtom.cpp
85 MachineIndependent/preprocessor/PpContext.cpp
86 MachineIndependent/preprocessor/PpScanner.cpp
87 MachineIndependent/preprocessor/PpTokens.cpp
88 MachineIndependent/propagateNoContraction.cpp
91 set(MACHINEINDEPENDENT_HEADERS
92 MachineIndependent/attribute.h
93 MachineIndependent/glslang_tab.cpp.h
94 MachineIndependent/gl_types.h
95 MachineIndependent/Initialize.h
96 MachineIndependent/iomapper.h
97 MachineIndependent/LiveTraverser.h
98 MachineIndependent/localintermediate.h
99 MachineIndependent/ParseHelper.h
100 MachineIndependent/reflection.h
101 MachineIndependent/RemoveTree.h
102 MachineIndependent/Scan.h
103 MachineIndependent/ScanContext.h
104 MachineIndependent/SymbolTable.h
105 MachineIndependent/Versions.h
106 MachineIndependent/parseVersions.h
107 MachineIndependent/propagateNoContraction.h
108 MachineIndependent/preprocessor/PpContext.h
109 MachineIndependent/preprocessor/PpTokens.h
113 list(APPEND MACHINEINDEPENDENT_SOURCES
114 HLSL/hlslAttributes.cpp
115 HLSL/hlslParseHelper.cpp
116 HLSL/hlslScanContext.cpp
118 HLSL/hlslTokenStream.cpp
120 HLSL/hlslParseables.cpp)
122 list(APPEND MACHINEINDEPENDENT_HEADERS
123 HLSL/hlslAttributes.h
124 HLSL/hlslParseHelper.h
126 HLSL/hlslScanContext.h
128 HLSL/hlslTokenStream.h
130 HLSL/hlslParseables.h)
133 add_library(MachineIndependent STATIC ${MACHINEINDEPENDENT_SOURCES} ${MACHINEINDEPENDENT_HEADERS})
134 set_property(TARGET MachineIndependent PROPERTY POSITION_INDEPENDENT_CODE ON)
135 set_property(TARGET MachineIndependent PROPERTY FOLDER glslang)
136 glslang_pch(MachineIndependent MachineIndependent/pch.h)
138 target_link_libraries(MachineIndependent PRIVATE OGLCompiler OSDependent GenericCodeGen)
140 ################################################################################
142 ################################################################################
144 CInterface/glslang_c_interface.cpp)
151 Include/ConstantUnion.h
152 Include/glslang_c_interface.h
153 Include/glslang_c_shader_types.h
155 Include/InitializeGlobals.h
156 Include/intermediate.h
158 Include/ResourceLimits.h
163 add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${GLSLANG_SOURCES} ${GLSLANG_HEADERS})
164 set_property(TARGET glslang PROPERTY FOLDER glslang)
165 set_property(TARGET glslang PROPERTY POSITION_INDEPENDENT_CODE ON)
166 target_link_libraries(glslang PRIVATE OGLCompiler OSDependent MachineIndependent)
167 target_include_directories(glslang PUBLIC
168 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
169 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
171 glslang_only_export_explicit_symbols(glslang)
173 if(WIN32 AND BUILD_SHARED_LIBS)
174 set_target_properties(glslang PROPERTIES PREFIX "")
177 ################################################################################
179 ################################################################################
181 source_group("Public" REGULAR_EXPRESSION "Public/*")
182 source_group("MachineIndependent" REGULAR_EXPRESSION "MachineIndependent/[^/]*")
183 source_group("Include" REGULAR_EXPRESSION "Include/[^/]*")
184 source_group("GenericCodeGen" REGULAR_EXPRESSION "GenericCodeGen/*")
185 source_group("MachineIndependent\\Preprocessor" REGULAR_EXPRESSION "MachineIndependent/preprocessor/*")
186 source_group("HLSL" REGULAR_EXPRESSION "HLSL/*")
187 source_group("CInterface" REGULAR_EXPRESSION "CInterface/*")
190 ################################################################################
192 ################################################################################
193 if(ENABLE_GLSLANG_INSTALL)
194 if(BUILD_SHARED_LIBS)
195 install(TARGETS glslang
196 EXPORT glslangTargets
197 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
198 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
199 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
201 install(TARGETS glslang MachineIndependent GenericCodeGen
202 EXPORT glslangTargets
203 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
206 install(EXPORT glslangTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
210 ${MACHINEINDEPENDENT_HEADERS})
212 foreach(file ${ALL_HEADERS})
213 get_filename_component(dir ${file} DIRECTORY)
214 install(FILES ${file} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang/${dir})
216 endif(ENABLE_GLSLANG_INSTALL)