• 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
34find_host_package(PythonInterp 3 REQUIRED)
35
36set(GLSLANG_INTRINSIC_H          "${GLSLANG_GENERATED_INCLUDEDIR}/glslang/glsl_intrinsic_header.h")
37set(GLSLANG_INTRINSIC_PY         "${CMAKE_CURRENT_SOURCE_DIR}/../gen_extension_headers.py")
38set(GLSLANG_INTRINSIC_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../glslang/ExtensionHeaders")
39
40add_custom_command(
41    OUTPUT  ${GLSLANG_INTRINSIC_H}
42    COMMAND ${PYTHON_EXECUTABLE} "${GLSLANG_INTRINSIC_PY}"
43            "-i" ${GLSLANG_INTRINSIC_HEADER_DIR}
44            "-o" ${GLSLANG_INTRINSIC_H}
45    DEPENDS ${GLSLANG_INTRINSIC_PY}
46    COMMENT "Generating ${GLSLANG_INTRINSIC_H}")
47
48#add_custom_target(glslangValidator DEPENDS ${GLSLANG_INTRINSIC_H})
49
50add_library(glslang-default-resource-limits
51            ${CMAKE_CURRENT_SOURCE_DIR}/ResourceLimits.cpp
52            ${CMAKE_CURRENT_SOURCE_DIR}/resource_limits_c.cpp)
53set_property(TARGET glslang-default-resource-limits PROPERTY FOLDER glslang)
54set_property(TARGET glslang-default-resource-limits PROPERTY POSITION_INDEPENDENT_CODE ON)
55
56target_include_directories(glslang-default-resource-limits
57                           PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
58                           PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>)
59
60set(SOURCES StandAlone.cpp DirStackFileIncluder.h  ${GLSLANG_INTRINSIC_H})
61
62add_executable(glslangValidator ${SOURCES})
63set_property(TARGET glslangValidator PROPERTY FOLDER tools)
64glslang_set_link_args(glslangValidator)
65
66set(LIBRARIES
67    glslang
68    SPIRV
69    glslang-default-resource-limits)
70
71if(ENABLE_SPVREMAPPER)
72    set(LIBRARIES ${LIBRARIES} SPVRemapper)
73endif()
74
75if(WIN32)
76    set(LIBRARIES ${LIBRARIES} psapi)
77elseif(UNIX)
78    if(NOT ANDROID)
79        set(LIBRARIES ${LIBRARIES} pthread)
80    endif()
81endif()
82
83target_link_libraries(glslangValidator ${LIBRARIES})
84target_include_directories(glslangValidator PUBLIC
85    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>
86    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>)
87
88if(ENABLE_OPT)
89    target_include_directories(glslangValidator
90        PRIVATE ${spirv-tools_SOURCE_DIR}/include
91    )
92endif()
93
94if(ENABLE_SPVREMAPPER)
95    set(REMAPPER_SOURCES spirv-remap.cpp)
96    add_executable(spirv-remap ${REMAPPER_SOURCES})
97    set_property(TARGET spirv-remap PROPERTY FOLDER tools)
98    glslang_set_link_args(spirv-remap)
99    target_link_libraries(spirv-remap ${LIBRARIES})
100endif()
101
102if(WIN32)
103    source_group("Source" FILES ${SOURCES})
104endif()
105
106if(ENABLE_GLSLANG_INSTALL)
107    install(TARGETS glslangValidator EXPORT glslangValidatorTargets
108            RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
109    install(EXPORT glslangValidatorTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
110
111    if(ENABLE_SPVREMAPPER)
112        install(TARGETS spirv-remap EXPORT spirv-remapTargets
113            RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
114        install(EXPORT spirv-remapTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
115    endif()
116
117    if(BUILD_SHARED_LIBS)
118        install(TARGETS glslang-default-resource-limits EXPORT glslang-default-resource-limitsTargets
119                ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
120                LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
121                RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
122    else()
123        install(TARGETS glslang-default-resource-limits EXPORT glslang-default-resource-limitsTargets
124                ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
125    endif()
126    install(EXPORT glslang-default-resource-limitsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
127endif()
128