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)
36 elseif(UNIX OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
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/SpirvIntrinsics.cpp
77 MachineIndependent/SymbolTable.cpp
78 MachineIndependent/Versions.cpp
79 MachineIndependent/intermOut.cpp
80 MachineIndependent/limits.cpp
81 MachineIndependent/linkValidate.cpp
82 MachineIndependent/parseConst.cpp
83 MachineIndependent/reflection.cpp
84 MachineIndependent/preprocessor/Pp.cpp
85 MachineIndependent/preprocessor/PpAtom.cpp
86 MachineIndependent/preprocessor/PpContext.cpp
87 MachineIndependent/preprocessor/PpScanner.cpp
88 MachineIndependent/preprocessor/PpTokens.cpp
89 MachineIndependent/propagateNoContraction.cpp
92 set(MACHINEINDEPENDENT_HEADERS
93 MachineIndependent/attribute.h
94 MachineIndependent/glslang_tab.cpp.h
95 MachineIndependent/gl_types.h
96 MachineIndependent/Initialize.h
97 MachineIndependent/iomapper.h
98 MachineIndependent/LiveTraverser.h
99 MachineIndependent/localintermediate.h
100 MachineIndependent/ParseHelper.h
101 MachineIndependent/reflection.h
102 MachineIndependent/RemoveTree.h
103 MachineIndependent/Scan.h
104 MachineIndependent/ScanContext.h
105 MachineIndependent/SymbolTable.h
106 MachineIndependent/Versions.h
107 MachineIndependent/parseVersions.h
108 MachineIndependent/propagateNoContraction.h
109 MachineIndependent/preprocessor/PpContext.h
110 MachineIndependent/preprocessor/PpTokens.h
114 list(APPEND MACHINEINDEPENDENT_SOURCES
115 HLSL/hlslAttributes.cpp
116 HLSL/hlslParseHelper.cpp
117 HLSL/hlslScanContext.cpp
119 HLSL/hlslTokenStream.cpp
121 HLSL/hlslParseables.cpp)
123 list(APPEND MACHINEINDEPENDENT_HEADERS
124 HLSL/hlslAttributes.h
125 HLSL/hlslParseHelper.h
127 HLSL/hlslScanContext.h
129 HLSL/hlslTokenStream.h
131 HLSL/hlslParseables.h)
134 add_library(MachineIndependent STATIC ${MACHINEINDEPENDENT_SOURCES} ${MACHINEINDEPENDENT_HEADERS})
135 set_property(TARGET MachineIndependent PROPERTY POSITION_INDEPENDENT_CODE ON)
136 set_property(TARGET MachineIndependent PROPERTY FOLDER glslang)
138 glslang_add_build_info_dependency(MachineIndependent)
140 glslang_pch(MachineIndependent MachineIndependent/pch.h)
142 target_link_libraries(MachineIndependent PRIVATE OGLCompiler OSDependent GenericCodeGen)
144 ################################################################################
146 ################################################################################
148 CInterface/glslang_c_interface.cpp)
155 Include/ConstantUnion.h
156 Include/glslang_c_interface.h
157 Include/glslang_c_shader_types.h
159 Include/InitializeGlobals.h
160 Include/intermediate.h
162 Include/ResourceLimits.h
164 Include/SpirvIntrinsics.h
167 add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${GLSLANG_SOURCES} ${GLSLANG_HEADERS})
168 set_target_properties(glslang PROPERTIES
170 POSITION_INDEPENDENT_CODE ON
171 VERSION "${GLSLANG_VERSION}"
172 SOVERSION "${GLSLANG_VERSION_MAJOR}")
173 target_link_libraries(glslang PRIVATE OGLCompiler OSDependent MachineIndependent)
174 target_include_directories(glslang PUBLIC
175 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
176 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
178 glslang_add_build_info_dependency(glslang)
180 glslang_only_export_explicit_symbols(glslang)
182 if(WIN32 AND BUILD_SHARED_LIBS)
183 set_target_properties(glslang PROPERTIES PREFIX "")
186 ################################################################################
188 ################################################################################
190 source_group("Public" REGULAR_EXPRESSION "Public/*")
191 source_group("MachineIndependent" REGULAR_EXPRESSION "MachineIndependent/[^/]*")
192 source_group("Include" REGULAR_EXPRESSION "Include/[^/]*")
193 source_group("GenericCodeGen" REGULAR_EXPRESSION "GenericCodeGen/*")
194 source_group("MachineIndependent\\Preprocessor" REGULAR_EXPRESSION "MachineIndependent/preprocessor/*")
195 source_group("HLSL" REGULAR_EXPRESSION "HLSL/*")
196 source_group("CInterface" REGULAR_EXPRESSION "CInterface/*")
199 ################################################################################
201 ################################################################################
202 if(ENABLE_GLSLANG_INSTALL)
203 if(BUILD_SHARED_LIBS)
204 install(TARGETS glslang
205 EXPORT glslangTargets
206 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
207 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
208 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
210 install(TARGETS glslang MachineIndependent GenericCodeGen
211 EXPORT glslangTargets
212 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
215 install(EXPORT glslangTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
219 ${MACHINEINDEPENDENT_HEADERS})
221 foreach(file ${ALL_HEADERS})
222 get_filename_component(dir ${file} DIRECTORY)
223 install(FILES ${file} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang/${dir})
226 install(FILES ${GLSLANG_BUILD_INFO_H} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang)
228 endif(ENABLE_GLSLANG_INSTALL)