Merge pull request #2310 from ben-clayton/license-checker
[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 Google 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
45 set(SOURCES StandAlone.cpp DirStackFileIncluder.h)
46
47 add_executable(glslangValidator ${SOURCES})
48 set_property(TARGET glslangValidator PROPERTY FOLDER tools)
49 glslang_set_link_args(glslangValidator)
50
51 set(LIBRARIES
52     glslang
53     SPIRV
54     glslang-default-resource-limits)
55
56 if(ENABLE_SPVREMAPPER)
57     set(LIBRARIES ${LIBRARIES} SPVRemapper)
58 endif()
59
60 if(WIN32)
61     set(LIBRARIES ${LIBRARIES} psapi)
62 elseif(UNIX)
63     if(NOT ANDROID)
64         set(LIBRARIES ${LIBRARIES} pthread)
65     endif()
66 endif(WIN32)
67
68 target_link_libraries(glslangValidator ${LIBRARIES})
69 target_include_directories(glslangValidator PUBLIC
70     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../External>
71     $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/External>)
72
73 if(ENABLE_SPVREMAPPER)
74     set(REMAPPER_SOURCES spirv-remap.cpp)
75     add_executable(spirv-remap ${REMAPPER_SOURCES})
76     set_property(TARGET spirv-remap PROPERTY FOLDER tools)
77     glslang_set_link_args(spirv-remap)
78     target_link_libraries(spirv-remap ${LIBRARIES})
79 endif()
80
81 if(WIN32)
82     source_group("Source" FILES ${SOURCES})
83 endif(WIN32)
84
85 if(ENABLE_GLSLANG_INSTALL)
86     install(TARGETS glslangValidator EXPORT glslangValidatorTargets
87             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
88     install(EXPORT glslangValidatorTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
89
90     if(ENABLE_SPVREMAPPER)
91         install(TARGETS spirv-remap EXPORT spirv-remapTargets
92             RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
93         install(EXPORT spirv-remapTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
94     endif()
95
96     if(BUILD_SHARED_LIBS)
97         install(TARGETS glslang-default-resource-limits EXPORT glslang-default-resource-limitsTargets
98                 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
99         install(EXPORT glslang-default-resource-limitsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
100     endif()
101 endif(ENABLE_GLSLANG_INSTALL)