• 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    NonSemanticDebugPrintf.h)
66
67set(SPVREMAP_HEADERS
68    SPVRemapper.h
69    doc.h)
70
71add_library(SPIRV ${LIB_TYPE} ${SOURCES} ${HEADERS})
72set_property(TARGET SPIRV PROPERTY FOLDER glslang)
73set_property(TARGET SPIRV PROPERTY POSITION_INDEPENDENT_CODE ON)
74target_include_directories(SPIRV PUBLIC
75    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
76    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
77
78glslang_add_build_info_dependency(SPIRV)
79
80if (ENABLE_SPVREMAPPER)
81    add_library(SPVRemapper ${LIB_TYPE} ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
82    set_property(TARGET SPVRemapper PROPERTY FOLDER glslang)
83    set_property(TARGET SPVRemapper PROPERTY POSITION_INDEPENDENT_CODE ON)
84endif()
85
86if(WIN32 AND BUILD_SHARED_LIBS)
87    set_target_properties(SPIRV PROPERTIES PREFIX "")
88    if (ENABLE_SPVREMAPPER)
89        set_target_properties(SPVRemapper PROPERTIES PREFIX "")
90    endif()
91endif()
92
93if(ENABLE_OPT)
94    target_include_directories(SPIRV
95        PRIVATE ${spirv-tools_SOURCE_DIR}/include
96        PRIVATE ${spirv-tools_SOURCE_DIR}/source
97    )
98    target_link_libraries(SPIRV PRIVATE MachineIndependent SPIRV-Tools-opt)
99    target_include_directories(SPIRV PUBLIC
100        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>
101        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>)
102else()
103    target_link_libraries(SPIRV PRIVATE MachineIndependent)
104endif(ENABLE_OPT)
105
106if(WIN32)
107    source_group("Source" FILES ${SOURCES} ${HEADERS})
108    source_group("Source" FILES ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
109endif(WIN32)
110
111if(ENABLE_GLSLANG_INSTALL)
112    if(BUILD_SHARED_LIBS)
113        if (ENABLE_SPVREMAPPER)
114            install(TARGETS SPVRemapper EXPORT SPVRemapperTargets
115                    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
116                    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
117        endif()
118        install(TARGETS SPIRV EXPORT SPIRVTargets
119                ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
120                LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
121                RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
122    else()
123        if (ENABLE_SPVREMAPPER)
124            install(TARGETS SPVRemapper EXPORT SPVRemapperTargets
125                    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
126        endif()
127        install(TARGETS SPIRV EXPORT SPIRVTargets
128                ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
129    endif()
130
131    if (ENABLE_SPVREMAPPER)
132        install(EXPORT SPVRemapperTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
133    endif()
134
135    install(EXPORT SPIRVTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
136
137    install(FILES ${HEADERS} ${SPVREMAP_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang/SPIRV/)
138endif(ENABLE_GLSLANG_INSTALL)
139