Merge branch 'master' into separate-web-and-emscripten
[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 if(EMSCRIPTEN OR ENABLE_GLSLANG_WEB)
10     add_subdirectory(OSDependent/Web)
11 endif(EMSCRIPTEN OR ENABLE_GLSLANG_WEB)
12
13 set(SOURCES
14     MachineIndependent/glslang.m4
15     MachineIndependent/glslang.y
16     MachineIndependent/glslang_tab.cpp
17     MachineIndependent/attribute.cpp
18     MachineIndependent/Constant.cpp
19     MachineIndependent/iomapper.cpp
20     MachineIndependent/InfoSink.cpp
21     MachineIndependent/Initialize.cpp
22     MachineIndependent/IntermTraverse.cpp
23     MachineIndependent/Intermediate.cpp
24     MachineIndependent/ParseContextBase.cpp
25     MachineIndependent/ParseHelper.cpp
26     MachineIndependent/PoolAlloc.cpp
27     MachineIndependent/RemoveTree.cpp
28     MachineIndependent/Scan.cpp
29     MachineIndependent/ShaderLang.cpp
30     MachineIndependent/SymbolTable.cpp
31     MachineIndependent/Versions.cpp
32     MachineIndependent/intermOut.cpp
33     MachineIndependent/limits.cpp
34     MachineIndependent/linkValidate.cpp
35     MachineIndependent/parseConst.cpp
36     MachineIndependent/reflection.cpp
37     MachineIndependent/preprocessor/Pp.cpp
38     MachineIndependent/preprocessor/PpAtom.cpp
39     MachineIndependent/preprocessor/PpContext.cpp
40     MachineIndependent/preprocessor/PpScanner.cpp
41     MachineIndependent/preprocessor/PpTokens.cpp
42     MachineIndependent/propagateNoContraction.cpp
43     GenericCodeGen/CodeGen.cpp
44     GenericCodeGen/Link.cpp)
45
46 set(HEADERS
47     Public/ShaderLang.h
48     Include/arrays.h
49     Include/BaseTypes.h
50     Include/Common.h
51     Include/ConstantUnion.h
52     Include/InfoSink.h
53     Include/InitializeGlobals.h
54     Include/intermediate.h
55     Include/PoolAlloc.h
56     Include/ResourceLimits.h
57     Include/revision.h
58     Include/ShHandle.h
59     Include/Types.h
60     MachineIndependent/attribute.h
61     MachineIndependent/glslang_tab.cpp.h
62     MachineIndependent/gl_types.h
63     MachineIndependent/Initialize.h
64     MachineIndependent/iomapper.h
65     MachineIndependent/LiveTraverser.h
66     MachineIndependent/localintermediate.h
67     MachineIndependent/ParseHelper.h
68     MachineIndependent/reflection.h
69     MachineIndependent/RemoveTree.h
70     MachineIndependent/Scan.h
71     MachineIndependent/ScanContext.h
72     MachineIndependent/SymbolTable.h
73     MachineIndependent/Versions.h
74     MachineIndependent/parseVersions.h
75     MachineIndependent/propagateNoContraction.h
76     MachineIndependent/preprocessor/PpContext.h
77     MachineIndependent/preprocessor/PpTokens.h)
78
79 glslang_pch(SOURCES MachineIndependent/pch.cpp)
80
81 add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${SOURCES} ${HEADERS})
82 set_property(TARGET glslang PROPERTY FOLDER glslang)
83 set_property(TARGET glslang PROPERTY POSITION_INDEPENDENT_CODE ON)
84 target_link_libraries(glslang OGLCompiler OSDependent)
85 target_include_directories(glslang PUBLIC ..)
86
87 if(WIN32 AND BUILD_SHARED_LIBS)
88     set_target_properties(glslang PROPERTIES PREFIX "")
89 endif()
90
91 if(ENABLE_HLSL)
92     target_link_libraries(glslang HLSL)
93 endif()
94
95 if(WIN32)
96     source_group("Public" REGULAR_EXPRESSION "Public/*")
97     source_group("MachineIndependent" REGULAR_EXPRESSION "MachineIndependent/[^/]*")
98     source_group("Include" REGULAR_EXPRESSION "Include/[^/]*")
99     source_group("GenericCodeGen" REGULAR_EXPRESSION "GenericCodeGen/*")
100     source_group("MachineIndependent\\Preprocessor" REGULAR_EXPRESSION "MachineIndependent/preprocessor/*")
101 endif(WIN32)
102
103 if(ENABLE_GLSLANG_INSTALL)
104     if(BUILD_SHARED_LIBS)
105         install(TARGETS glslang
106                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
107                 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
108                 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
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)