• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2020 The Khronos Group Inc.
2#
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9#    Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11#
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.
16#
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.
20#
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.
33
34set(SOURCES
35    GlslangToSpv.cpp
36    InReadableOrder.cpp
37    Logger.cpp
38    SpvBuilder.cpp
39    SpvPostProcess.cpp
40    doc.cpp
41    SpvTools.cpp
42    disassemble.cpp
43    CInterface/spirv_c_interface.cpp)
44
45set(SPVREMAP_SOURCES
46    SPVRemapper.cpp
47    doc.cpp)
48
49set(HEADERS
50    bitutils.h
51    spirv.hpp
52    GLSL.std.450.h
53    GLSL.ext.EXT.h
54    GLSL.ext.KHR.h
55    GlslangToSpv.h
56    hex_float.h
57    Logger.h
58    SpvBuilder.h
59    spvIR.h
60    doc.h
61    SpvTools.h
62    disassemble.h
63    GLSL.ext.AMD.h
64    GLSL.ext.NV.h
65    GLSL.ext.ARM.h
66    GLSL.ext.QCOM.h
67    NonSemanticDebugPrintf.h
68    NonSemanticShaderDebugInfo100.h)
69
70set(SPVREMAP_HEADERS
71    SPVRemapper.h
72    doc.h)
73
74set(PUBLIC_HEADERS
75    GlslangToSpv.h
76    disassemble.h
77    Logger.h
78    spirv.hpp
79    SPVRemapper.h)
80
81add_library(SPIRV ${LIB_TYPE} ${SOURCES} ${HEADERS})
82add_library(glslang::SPIRV ALIAS SPIRV)
83set_target_properties(SPIRV PROPERTIES
84    FOLDER glslang
85    POSITION_INDEPENDENT_CODE ON
86    VERSION   "${GLSLANG_VERSION}"
87    SOVERSION "${GLSLANG_VERSION_MAJOR}")
88target_include_directories(SPIRV PUBLIC
89    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
90    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
91
92glslang_add_build_info_dependency(SPIRV)
93
94if (ENABLE_SPVREMAPPER)
95    add_library(SPVRemapper ${LIB_TYPE} ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
96    add_library(glslang::SPVRemapper ALIAS SPVRemapper)
97    set_target_properties(SPVRemapper PROPERTIES
98        FOLDER glslang
99        POSITION_INDEPENDENT_CODE ON
100        VERSION   "${GLSLANG_VERSION}"
101        SOVERSION "${GLSLANG_VERSION_MAJOR}")
102endif()
103
104if(WIN32 AND BUILD_SHARED_LIBS)
105    set_target_properties(SPIRV PROPERTIES PREFIX "")
106    if (ENABLE_SPVREMAPPER)
107        set_target_properties(SPVRemapper PROPERTIES PREFIX "")
108    endif()
109endif()
110
111if(ENABLE_OPT)
112    target_link_libraries(SPIRV PRIVATE MachineIndependent PUBLIC SPIRV-Tools-opt)
113    target_include_directories(SPIRV PUBLIC
114        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>)
115else()
116    target_link_libraries(SPIRV PRIVATE MachineIndependent)
117endif()
118
119if(WIN32)
120    source_group("Source" FILES ${SOURCES} ${HEADERS})
121    source_group("Source" FILES ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
122endif()
123
124if(GLSLANG_ENABLE_INSTALL)
125    if (ENABLE_SPVREMAPPER)
126        install(TARGETS SPVRemapper EXPORT glslang-targets)
127    endif()
128
129    install(TARGETS SPIRV EXPORT glslang-targets)
130
131    install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang/SPIRV/)
132endif()
133