blob: 2b163e7f55c2b88162729db2947a0bd8f127984b [file] [log] [blame]
Ben Clayton1d212702020-07-01 15:43:36 +01001# 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 Claytoncb261e32020-07-03 12:21:01 +010017# Neither the name of The Khronos Group Inc. nor the names of its
Ben Clayton1d212702020-07-01 15:43:36 +010018# 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
amhagan035a3bb2021-09-01 11:33:21 -040034find_host_package(PythonInterp 3 REQUIRED)
35
36set(GLSLANG_INTRINSIC_H "${GLSLANG_GENERATED_INCLUDEDIR}/glslang/glsl_intrinsic_header.h")
David Neto36333d12021-10-19 17:32:52 -040037set(GLSLANG_INTRINSIC_PY "${CMAKE_CURRENT_SOURCE_DIR}/../gen_extension_headers.py")
38set(GLSLANG_INTRINSIC_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../glslang/ExtensionHeaders")
amhagan035a3bb2021-09-01 11:33:21 -040039
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
Lei Zhang414eb602016-03-04 16:22:34 -050050add_library(glslang-default-resource-limits
Travis Fortfd37e0c2020-03-06 10:06:47 -050051 ${CMAKE_CURRENT_SOURCE_DIR}/ResourceLimits.cpp
52 ${CMAKE_CURRENT_SOURCE_DIR}/resource_limits_c.cpp)
Rohith Chandran62060912017-07-04 10:53:45 -040053set_property(TARGET glslang-default-resource-limits PROPERTY FOLDER glslang)
54set_property(TARGET glslang-default-resource-limits PROPERTY POSITION_INDEPENDENT_CODE ON)
Andrew Woloszyndb0eaf92016-05-05 14:45:53 -040055
Lei Zhang414eb602016-03-04 16:22:34 -050056target_include_directories(glslang-default-resource-limits
David Duboisf57feff2019-10-21 21:31:44 -070057 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
58 PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>)
59
amhagan035a3bb2021-09-01 11:33:21 -040060set(SOURCES StandAlone.cpp DirStackFileIncluder.h ${GLSLANG_INTRINSIC_H})
John Kessenich140f3df2015-06-26 16:58:36 -060061
62add_executable(glslangValidator ${SOURCES})
Andrew Woloszyndb0eaf92016-05-05 14:45:53 -040063set_property(TARGET glslangValidator PROPERTY FOLDER tools)
David Netob37dc0e2016-06-02 14:37:24 -040064glslang_set_link_args(glslangValidator)
John Kessenich140f3df2015-06-26 16:58:36 -060065
66set(LIBRARIES
67 glslang
Lei Zhang414eb602016-03-04 16:22:34 -050068 SPIRV
69 glslang-default-resource-limits)
John Kessenich140f3df2015-06-26 16:58:36 -060070
Dan Sinclair04567eb2019-11-21 10:33:32 -050071if(ENABLE_SPVREMAPPER)
72 set(LIBRARIES ${LIBRARIES} SPVRemapper)
73endif()
74
John Kessenich140f3df2015-06-26 16:58:36 -060075if(WIN32)
76 set(LIBRARIES ${LIBRARIES} psapi)
77elseif(UNIX)
Andrew Woloszyn8b64fa52015-08-17 11:39:38 -040078 if(NOT ANDROID)
79 set(LIBRARIES ${LIBRARIES} pthread)
80 endif()
Nathaniel Cesarioc8ef4f82021-09-28 17:01:21 -060081endif()
John Kessenich140f3df2015-06-26 16:58:36 -060082
83target_link_libraries(glslangValidator ${LIBRARIES})
Dan Sinclair04567eb2019-11-21 10:33:32 -050084target_include_directories(glslangValidator PUBLIC
John Kesseniche01c8472019-11-22 06:24:38 -070085 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>
86 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>)
John Kessenich140f3df2015-06-26 16:58:36 -060087
pheonixc897c3b2020-11-02 13:40:50 -080088if(ENABLE_OPT)
89 target_include_directories(glslangValidator
90 PRIVATE ${spirv-tools_SOURCE_DIR}/include
91 )
Nathaniel Cesarioc8ef4f82021-09-28 17:01:21 -060092endif()
pheonixc897c3b2020-11-02 13:40:50 -080093
Dan Sinclair04567eb2019-11-21 10:33:32 -050094if(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()
John Kessenich140f3df2015-06-26 16:58:36 -0600101
102if(WIN32)
103 source_group("Source" FILES ${SOURCES})
Nathaniel Cesarioc8ef4f82021-09-28 17:01:21 -0600104endif()
John Kessenich140f3df2015-06-26 16:58:36 -0600105
d3x0r45933122017-07-04 06:01:09 -0700106if(ENABLE_GLSLANG_INSTALL)
James Rumbleab6d1492019-08-06 14:47:51 +0100107 install(TARGETS glslangValidator EXPORT glslangValidatorTargets
d3x0r45933122017-07-04 06:01:09 -0700108 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
John Kesseniche01c8472019-11-22 06:24:38 -0700109 install(EXPORT glslangValidatorTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
John Kessenich140f3df2015-06-26 16:58:36 -0600110
Dan Sinclair04567eb2019-11-21 10:33:32 -0500111 if(ENABLE_SPVREMAPPER)
112 install(TARGETS spirv-remap EXPORT spirv-remapTargets
d3x0r45933122017-07-04 06:01:09 -0700113 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
John Kesseniche01c8472019-11-22 06:24:38 -0700114 install(EXPORT spirv-remapTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
Dan Sinclair04567eb2019-11-21 10:33:32 -0500115 endif()
116
Krzysztof Pilchbb9746a2021-04-09 16:20:01 +0200117 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 Pilch3549cd62021-04-08 16:33:29 +0200126 install(EXPORT glslang-default-resource-limitsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
David Neto36333d12021-10-19 17:32:52 -0400127endif()