• 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    NonSemanticDebugPrintf.h
67    NonSemanticShaderDebugInfo100.h)
68
69set(SPVREMAP_HEADERS
70    SPVRemapper.h
71    doc.h)
72
73set(PUBLIC_HEADERS
74    GlslangToSpv.h
75    disassemble.h
76    Logger.h
77    spirv.hpp
78    SPVRemapper.h)
79
80add_library(SPIRV ${LIB_TYPE} ${SOURCES} ${HEADERS})
81set_target_properties(SPIRV PROPERTIES
82    FOLDER glslang
83    POSITION_INDEPENDENT_CODE ON
84    VERSION   "${GLSLANG_VERSION}"
85    SOVERSION "${GLSLANG_VERSION_MAJOR}")
86target_include_directories(SPIRV PUBLIC
87    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
88    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
89
90glslang_add_build_info_dependency(SPIRV)
91
92if (ENABLE_SPVREMAPPER)
93    add_library(SPVRemapper ${LIB_TYPE} ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
94    set_target_properties(SPVRemapper PROPERTIES
95        FOLDER glslang
96        POSITION_INDEPENDENT_CODE ON
97        VERSION   "${GLSLANG_VERSION}"
98        SOVERSION "${GLSLANG_VERSION_MAJOR}")
99endif()
100
101if(WIN32 AND BUILD_SHARED_LIBS)
102    set_target_properties(SPIRV PROPERTIES PREFIX "")
103    if (ENABLE_SPVREMAPPER)
104        set_target_properties(SPVRemapper PROPERTIES PREFIX "")
105    endif()
106endif()
107
108if(ENABLE_OPT)
109    target_link_libraries(SPIRV PRIVATE MachineIndependent PUBLIC SPIRV-Tools-opt)
110    target_include_directories(SPIRV PUBLIC
111        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>)
112else()
113    target_link_libraries(SPIRV PRIVATE MachineIndependent)
114endif()
115
116if(WIN32)
117    source_group("Source" FILES ${SOURCES} ${HEADERS})
118    source_group("Source" FILES ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
119endif()
120
121if(PROJECT_IS_TOP_LEVEL)
122    if (ENABLE_SPVREMAPPER)
123        install(TARGETS SPVRemapper EXPORT glslang-targets)
124    endif()
125
126    install(TARGETS SPIRV EXPORT glslang-targets)
127
128    # Backward compatibility
129    if (ENABLE_SPVREMAPPER)
130        file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/SPVRemapperTargets.cmake" "
131            message(WARNING \"Using `SPVRemapperTargets.cmake` is deprecated: use `find_package(glslang)` to find glslang CMake targets.\")
132
133            if (NOT TARGET glslang::SPVRemapper)
134                include(\"${CMAKE_INSTALL_FULL_LIBDIR}/cmake/${PROJECT_NAME}/glslang-targets.cmake\")
135            endif()
136
137            add_library(SPVRemapper ALIAS glslang::SPVRemapper)
138        ")
139        install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SPVRemapperTargets.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
140    endif()
141
142    file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/SPIRVTargets.cmake" "
143        message(WARNING \"Using `SPIRVTargets.cmake` is deprecated: use `find_package(glslang)` to find glslang CMake targets.\")
144
145        if (NOT TARGET glslang::SPIRV)
146            include(\"${CMAKE_INSTALL_FULL_LIBDIR}/cmake/${PROJECT_NAME}/glslang-targets.cmake\")
147        endif()
148
149        add_library(SPIRV ALIAS glslang::SPIRV)
150    ")
151    install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SPIRVTargets.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
152
153    install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang/SPIRV/)
154endif()
155