Removed condition for glslang-default-resource-limits instalation.
[platform/upstream/glslang.git] / StandAlone / CMakeLists.txt
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
34 add_library(glslang-default-resource-limits
35             ${CMAKE_CURRENT_SOURCE_DIR}/ResourceLimits.cpp
36             ${CMAKE_CURRENT_SOURCE_DIR}/resource_limits_c.cpp)
37 set_property(TARGET glslang-default-resource-limits PROPERTY FOLDER glslang)
38 set_property(TARGET glslang-default-resource-limits PROPERTY POSITION_INDEPENDENT_CODE ON)
39
40 target_include_directories(glslang-default-resource-limits
41                            PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
42                            PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>)
43
44 set(SOURCES StandAlone.cpp DirStackFileIncluder.h)
45
46 add_executable(glslangValidator ${SOURCES})
47 set_property(TARGET glslangValidator PROPERTY FOLDER tools)
48 glslang_set_link_args(glslangValidator)
49
50 set(LIBRARIES
51     glslang
52     SPIRV
53     glslang-default-resource-limits)
54
55 if(ENABLE_SPVREMAPPER)
56     set(LIBRARIES ${LIBRARIES} SPVRemapper)
57 endif()
58
59 if(WIN32)
60     set(LIBRARIES ${LIBRARIES} psapi)
61 elseif(UNIX)
62     if(NOT ANDROID)
63         set(LIBRARIES ${LIBRARIES} pthread)
64     endif()
65 endif(WIN32)
66
67 target_link_libraries(glslangValidator ${LIBRARIES})
68 target_include_directories(glslangValidator PUBLIC
69     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>
70     $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>)
71
72 if(ENABLE_OPT)
73     target_include_directories(glslangValidator
74         PRIVATE ${spirv-tools_SOURCE_DIR}/include
75     )
76 endif(ENABLE_OPT)
77
78 if(ENABLE_SPVREMAPPER)
79     set(REMAPPER_SOURCES spirv-remap.cpp)
80     add_executable(spirv-remap ${REMAPPER_SOURCES})
81     set_property(TARGET spirv-remap PROPERTY FOLDER tools)
82     glslang_set_link_args(spirv-remap)
83     target_link_libraries(spirv-remap ${LIBRARIES})
84 endif()
85
86 if(WIN32)
87     source_group("Source" FILES ${SOURCES})
88 endif(WIN32)
89
90 if(ENABLE_GLSLANG_INSTALL)
91     install(TARGETS glslangValidator EXPORT glslangValidatorTargets
92             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
93     install(EXPORT glslangValidatorTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
94
95     if(ENABLE_SPVREMAPPER)
96         install(TARGETS spirv-remap EXPORT spirv-remapTargets
97             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
98         install(EXPORT spirv-remapTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
99     endif()
100
101     install(TARGETS glslang-default-resource-limits EXPORT glslang-default-resource-limitsTargets
102             LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
103     install(EXPORT glslang-default-resource-limitsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
104 endif(ENABLE_GLSLANG_INSTALL)