Fixed install for SPIRV, glslang, and hlsl when building shared libs
[platform/upstream/glslang.git] / glslang / CMakeLists.txt
1 if(WIN32)
2     add_subdirectory(OSDependent/Windows)
3 elseif(UNIX)
4     add_subdirectory(OSDependent/Unix)
5 else(WIN32)
6     message("unknown platform")
7 endif(WIN32)
8
9 set(SOURCES
10     MachineIndependent/glslang.y
11     MachineIndependent/glslang_tab.cpp
12     MachineIndependent/attribute.cpp
13     MachineIndependent/Constant.cpp
14     MachineIndependent/iomapper.cpp
15     MachineIndependent/InfoSink.cpp
16     MachineIndependent/Initialize.cpp
17     MachineIndependent/IntermTraverse.cpp
18     MachineIndependent/Intermediate.cpp
19     MachineIndependent/ParseContextBase.cpp
20     MachineIndependent/ParseHelper.cpp
21     MachineIndependent/PoolAlloc.cpp
22     MachineIndependent/RemoveTree.cpp
23     MachineIndependent/Scan.cpp
24     MachineIndependent/ShaderLang.cpp
25     MachineIndependent/SymbolTable.cpp
26     MachineIndependent/Versions.cpp
27     MachineIndependent/intermOut.cpp
28     MachineIndependent/limits.cpp
29     MachineIndependent/linkValidate.cpp
30     MachineIndependent/parseConst.cpp
31     MachineIndependent/reflection.cpp
32     MachineIndependent/preprocessor/Pp.cpp
33     MachineIndependent/preprocessor/PpAtom.cpp
34     MachineIndependent/preprocessor/PpContext.cpp
35     MachineIndependent/preprocessor/PpScanner.cpp
36     MachineIndependent/preprocessor/PpTokens.cpp
37     MachineIndependent/propagateNoContraction.cpp
38     GenericCodeGen/CodeGen.cpp
39     GenericCodeGen/Link.cpp)
40
41 set(HEADERS
42     Public/ShaderLang.h
43     Include/arrays.h
44     Include/BaseTypes.h
45     Include/Common.h
46     Include/ConstantUnion.h
47     Include/InfoSink.h
48     Include/InitializeGlobals.h
49     Include/intermediate.h
50     Include/PoolAlloc.h
51     Include/ResourceLimits.h
52     Include/revision.h
53     Include/ShHandle.h
54     Include/Types.h
55     MachineIndependent/attribute.h
56     MachineIndependent/glslang_tab.cpp.h
57     MachineIndependent/gl_types.h
58     MachineIndependent/Initialize.h
59     MachineIndependent/iomapper.h
60     MachineIndependent/LiveTraverser.h
61     MachineIndependent/localintermediate.h
62     MachineIndependent/ParseHelper.h
63     MachineIndependent/reflection.h
64     MachineIndependent/RemoveTree.h
65     MachineIndependent/Scan.h
66     MachineIndependent/ScanContext.h
67     MachineIndependent/SymbolTable.h
68     MachineIndependent/Versions.h
69     MachineIndependent/parseVersions.h
70     MachineIndependent/propagateNoContraction.h
71     MachineIndependent/preprocessor/PpContext.h
72     MachineIndependent/preprocessor/PpTokens.h)
73
74 # This might be useful for making grammar changes:
75 #
76 # find_package(BISON)
77 # add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/MachineIndependent/glslang_tab.cpp ${CMAKE_CURRENT_SOURCE_DIR}/MachineIndependent/glslang_tab.cpp.h
78 #                    COMMAND ${BISON_EXECUTABLE} --defines=${CMAKE_CURRENT_SOURCE_DIR}/MachineIndependent/glslang_tab.cpp.h -t ${CMAKE_CURRENT_SOURCE_DIR}/MachineIndependent/glslang.y -o ${CMAKE_CURRENT_SOURCE_DIR}/MachineIndependent/glslang_tab.cpp
79 #                    MAIN_DEPENDENCY MachineIndependent/glslang.y
80 #                    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
81 # set(BISON_GLSLParser_OUTPUT_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/MachineIndependent/glslang_tab.cpp)
82
83 add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${SOURCES} ${HEADERS})
84 set_property(TARGET glslang PROPERTY FOLDER glslang)
85 set_property(TARGET glslang PROPERTY POSITION_INDEPENDENT_CODE ON)
86 target_link_libraries(glslang OGLCompiler OSDependent)
87
88 if(WIN32 AND BUILD_SHARED_LIBS)
89     set_target_properties(glslang PROPERTIES PREFIX "")
90 endif()
91
92 if(ENABLE_HLSL)
93     target_link_libraries(glslang HLSL)
94 endif()
95
96 if(WIN32)
97     source_group("Public" REGULAR_EXPRESSION "Public/*")
98     source_group("MachineIndependent" REGULAR_EXPRESSION "MachineIndependent/[^/]*")
99     source_group("Include" REGULAR_EXPRESSION "Include/[^/]*")
100     source_group("GenericCodeGen" REGULAR_EXPRESSION "GenericCodeGen/*")
101     source_group("MachineIndependent\\Preprocessor" REGULAR_EXPRESSION "MachineIndependent/preprocessor/*")
102 endif(WIN32)
103
104 if(ENABLE_GLSLANG_INSTALL)
105     if(BUILD_SHARED_LIBS)
106         install(TARGETS glslang
107                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
108                 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
109     else()
110         install(TARGETS glslang
111                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
112     endif()
113 endif(ENABLE_GLSLANG_INSTALL)
114
115 if(ENABLE_GLSLANG_INSTALL)
116     foreach(file ${HEADERS})
117         get_filename_component(dir ${file} DIRECTORY)
118         install(FILES ${file} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang/${dir})
119     endforeach()
120 endif(ENABLE_GLSLANG_INSTALL)