Ben Clayton | 1d21270 | 2020-07-01 15:43:36 +0100 | [diff] [blame] | 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 | # |
Ben Clayton | cb261e3 | 2020-07-03 12:21:01 +0100 | [diff] [blame] | 17 | # Neither the name of The Khronos Group Inc. nor the names of its |
Ben Clayton | 1d21270 | 2020-07-01 15:43:36 +0100 | [diff] [blame] | 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 | |
amhagan | 035a3bb | 2021-09-01 11:33:21 -0400 | [diff] [blame] | 34 | find_host_package(PythonInterp 3 REQUIRED) |
| 35 | |
| 36 | set(GLSLANG_INTRINSIC_H "${GLSLANG_GENERATED_INCLUDEDIR}/glslang/glsl_intrinsic_header.h") |
David Neto | 36333d1 | 2021-10-19 17:32:52 -0400 | [diff] [blame] | 37 | set(GLSLANG_INTRINSIC_PY "${CMAKE_CURRENT_SOURCE_DIR}/../gen_extension_headers.py") |
| 38 | set(GLSLANG_INTRINSIC_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../glslang/ExtensionHeaders") |
amhagan | 035a3bb | 2021-09-01 11:33:21 -0400 | [diff] [blame] | 39 | |
| 40 | add_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 | |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 50 | add_library(glslang-default-resource-limits |
Travis Fort | fd37e0c | 2020-03-06 10:06:47 -0500 | [diff] [blame] | 51 | ${CMAKE_CURRENT_SOURCE_DIR}/ResourceLimits.cpp |
| 52 | ${CMAKE_CURRENT_SOURCE_DIR}/resource_limits_c.cpp) |
Rohith Chandran | 6206091 | 2017-07-04 10:53:45 -0400 | [diff] [blame] | 53 | set_property(TARGET glslang-default-resource-limits PROPERTY FOLDER glslang) |
| 54 | set_property(TARGET glslang-default-resource-limits PROPERTY POSITION_INDEPENDENT_CODE ON) |
Andrew Woloszyn | db0eaf9 | 2016-05-05 14:45:53 -0400 | [diff] [blame] | 55 | |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 56 | target_include_directories(glslang-default-resource-limits |
David Dubois | f57feff | 2019-10-21 21:31:44 -0700 | [diff] [blame] | 57 | PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> |
| 58 | PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>) |
| 59 | |
amhagan | 035a3bb | 2021-09-01 11:33:21 -0400 | [diff] [blame] | 60 | set(SOURCES StandAlone.cpp DirStackFileIncluder.h ${GLSLANG_INTRINSIC_H}) |
John Kessenich | 140f3df | 2015-06-26 16:58:36 -0600 | [diff] [blame] | 61 | |
| 62 | add_executable(glslangValidator ${SOURCES}) |
Andrew Woloszyn | db0eaf9 | 2016-05-05 14:45:53 -0400 | [diff] [blame] | 63 | set_property(TARGET glslangValidator PROPERTY FOLDER tools) |
David Neto | b37dc0e | 2016-06-02 14:37:24 -0400 | [diff] [blame] | 64 | glslang_set_link_args(glslangValidator) |
John Kessenich | 140f3df | 2015-06-26 16:58:36 -0600 | [diff] [blame] | 65 | |
| 66 | set(LIBRARIES |
| 67 | glslang |
Lei Zhang | 414eb60 | 2016-03-04 16:22:34 -0500 | [diff] [blame] | 68 | SPIRV |
| 69 | glslang-default-resource-limits) |
John Kessenich | 140f3df | 2015-06-26 16:58:36 -0600 | [diff] [blame] | 70 | |
Dan Sinclair | 04567eb | 2019-11-21 10:33:32 -0500 | [diff] [blame] | 71 | if(ENABLE_SPVREMAPPER) |
| 72 | set(LIBRARIES ${LIBRARIES} SPVRemapper) |
| 73 | endif() |
| 74 | |
John Kessenich | 140f3df | 2015-06-26 16:58:36 -0600 | [diff] [blame] | 75 | if(WIN32) |
| 76 | set(LIBRARIES ${LIBRARIES} psapi) |
| 77 | elseif(UNIX) |
Andrew Woloszyn | 8b64fa5 | 2015-08-17 11:39:38 -0400 | [diff] [blame] | 78 | if(NOT ANDROID) |
| 79 | set(LIBRARIES ${LIBRARIES} pthread) |
| 80 | endif() |
Nathaniel Cesario | c8ef4f8 | 2021-09-28 17:01:21 -0600 | [diff] [blame] | 81 | endif() |
John Kessenich | 140f3df | 2015-06-26 16:58:36 -0600 | [diff] [blame] | 82 | |
| 83 | target_link_libraries(glslangValidator ${LIBRARIES}) |
Dan Sinclair | 04567eb | 2019-11-21 10:33:32 -0500 | [diff] [blame] | 84 | target_include_directories(glslangValidator PUBLIC |
John Kessenich | e01c847 | 2019-11-22 06:24:38 -0700 | [diff] [blame] | 85 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External> |
| 86 | $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>) |
John Kessenich | 140f3df | 2015-06-26 16:58:36 -0600 | [diff] [blame] | 87 | |
pheonix | c897c3b | 2020-11-02 13:40:50 -0800 | [diff] [blame] | 88 | if(ENABLE_OPT) |
| 89 | target_include_directories(glslangValidator |
| 90 | PRIVATE ${spirv-tools_SOURCE_DIR}/include |
| 91 | ) |
Nathaniel Cesario | c8ef4f8 | 2021-09-28 17:01:21 -0600 | [diff] [blame] | 92 | endif() |
pheonix | c897c3b | 2020-11-02 13:40:50 -0800 | [diff] [blame] | 93 | |
Dan Sinclair | 04567eb | 2019-11-21 10:33:32 -0500 | [diff] [blame] | 94 | if(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}) |
| 100 | endif() |
John Kessenich | 140f3df | 2015-06-26 16:58:36 -0600 | [diff] [blame] | 101 | |
| 102 | if(WIN32) |
| 103 | source_group("Source" FILES ${SOURCES}) |
Nathaniel Cesario | c8ef4f8 | 2021-09-28 17:01:21 -0600 | [diff] [blame] | 104 | endif() |
John Kessenich | 140f3df | 2015-06-26 16:58:36 -0600 | [diff] [blame] | 105 | |
d3x0r | 4593312 | 2017-07-04 06:01:09 -0700 | [diff] [blame] | 106 | if(ENABLE_GLSLANG_INSTALL) |
James Rumble | ab6d149 | 2019-08-06 14:47:51 +0100 | [diff] [blame] | 107 | install(TARGETS glslangValidator EXPORT glslangValidatorTargets |
d3x0r | 4593312 | 2017-07-04 06:01:09 -0700 | [diff] [blame] | 108 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
John Kessenich | e01c847 | 2019-11-22 06:24:38 -0700 | [diff] [blame] | 109 | install(EXPORT glslangValidatorTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) |
John Kessenich | 140f3df | 2015-06-26 16:58:36 -0600 | [diff] [blame] | 110 | |
Dan Sinclair | 04567eb | 2019-11-21 10:33:32 -0500 | [diff] [blame] | 111 | if(ENABLE_SPVREMAPPER) |
| 112 | install(TARGETS spirv-remap EXPORT spirv-remapTargets |
d3x0r | 4593312 | 2017-07-04 06:01:09 -0700 | [diff] [blame] | 113 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
John Kessenich | e01c847 | 2019-11-22 06:24:38 -0700 | [diff] [blame] | 114 | install(EXPORT spirv-remapTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) |
Dan Sinclair | 04567eb | 2019-11-21 10:33:32 -0500 | [diff] [blame] | 115 | endif() |
| 116 | |
Krzysztof Pilch | bb9746a | 2021-04-09 16:20:01 +0200 | [diff] [blame] | 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() |
Krzysztof Pilch | 3549cd6 | 2021-04-08 16:33:29 +0200 | [diff] [blame] | 126 | install(EXPORT glslang-default-resource-limitsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) |
David Neto | 36333d1 | 2021-10-19 17:32:52 -0400 | [diff] [blame] | 127 | endif() |