Merge pull request #2081 from kainino0x/split-emscripten-from-glslang.js
[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_JS)
10     # May be enabled on non-Emscripten builds for binary-size testing.
11     add_subdirectory(OSDependent/Web)
12 endif(EMSCRIPTEN OR ENABLE_GLSLANG_JS)
13
14 set(SOURCES
15     MachineIndependent/glslang.m4
16     MachineIndependent/glslang.y
17     MachineIndependent/glslang_tab.cpp
18     MachineIndependent/attribute.cpp
19     MachineIndependent/Constant.cpp
20     MachineIndependent/iomapper.cpp
21     MachineIndependent/InfoSink.cpp
22     MachineIndependent/Initialize.cpp
23     MachineIndependent/IntermTraverse.cpp
24     MachineIndependent/Intermediate.cpp
25     MachineIndependent/ParseContextBase.cpp
26     MachineIndependent/ParseHelper.cpp
27     MachineIndependent/PoolAlloc.cpp
28     MachineIndependent/RemoveTree.cpp
29     MachineIndependent/Scan.cpp
30     MachineIndependent/ShaderLang.cpp
31     MachineIndependent/SymbolTable.cpp
32     MachineIndependent/Versions.cpp
33     MachineIndependent/intermOut.cpp
34     MachineIndependent/limits.cpp
35     MachineIndependent/linkValidate.cpp
36     MachineIndependent/parseConst.cpp
37     MachineIndependent/reflection.cpp
38     MachineIndependent/preprocessor/Pp.cpp
39     MachineIndependent/preprocessor/PpAtom.cpp
40     MachineIndependent/preprocessor/PpContext.cpp
41     MachineIndependent/preprocessor/PpScanner.cpp
42     MachineIndependent/preprocessor/PpTokens.cpp
43     MachineIndependent/propagateNoContraction.cpp
44     GenericCodeGen/CodeGen.cpp
45     GenericCodeGen/Link.cpp
46     CInterface/glslang_c_interface.cpp)
47
48 set(HEADERS
49     Public/ShaderLang.h
50     Include/arrays.h
51     Include/BaseTypes.h
52     Include/Common.h
53     Include/ConstantUnion.h
54     Include/glslang_c_interface.h
55     Include/glslang_c_shader_types.h
56     Include/InfoSink.h
57     Include/InitializeGlobals.h
58     Include/intermediate.h
59     Include/PoolAlloc.h
60     Include/ResourceLimits.h
61     Include/revision.h
62     Include/ShHandle.h
63     Include/Types.h
64     MachineIndependent/attribute.h
65     MachineIndependent/glslang_tab.cpp.h
66     MachineIndependent/gl_types.h
67     MachineIndependent/Initialize.h
68     MachineIndependent/iomapper.h
69     MachineIndependent/LiveTraverser.h
70     MachineIndependent/localintermediate.h
71     MachineIndependent/ParseHelper.h
72     MachineIndependent/reflection.h
73     MachineIndependent/RemoveTree.h
74     MachineIndependent/Scan.h
75     MachineIndependent/ScanContext.h
76     MachineIndependent/SymbolTable.h
77     MachineIndependent/Versions.h
78     MachineIndependent/parseVersions.h
79     MachineIndependent/propagateNoContraction.h
80     MachineIndependent/preprocessor/PpContext.h
81     MachineIndependent/preprocessor/PpTokens.h)
82
83 glslang_pch(SOURCES MachineIndependent/pch.cpp)
84
85 add_library(glslang ${LIB_TYPE} ${BISON_GLSLParser_OUTPUT_SOURCE} ${SOURCES} ${HEADERS})
86 set_property(TARGET glslang PROPERTY FOLDER glslang)
87 set_property(TARGET glslang PROPERTY POSITION_INDEPENDENT_CODE ON)
88 target_link_libraries(glslang OGLCompiler OSDependent)
89 target_include_directories(glslang PUBLIC 
90     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
91     $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
92
93 if(WIN32 AND BUILD_SHARED_LIBS)
94     set_target_properties(glslang PROPERTIES PREFIX "")
95 endif()
96
97 if(ENABLE_HLSL)
98     target_link_libraries(glslang HLSL)
99 endif()
100
101 if(WIN32)
102     source_group("Public" REGULAR_EXPRESSION "Public/*")
103     source_group("MachineIndependent" REGULAR_EXPRESSION "MachineIndependent/[^/]*")
104     source_group("Include" REGULAR_EXPRESSION "Include/[^/]*")
105     source_group("GenericCodeGen" REGULAR_EXPRESSION "GenericCodeGen/*")
106     source_group("MachineIndependent\\Preprocessor" REGULAR_EXPRESSION "MachineIndependent/preprocessor/*")
107 endif(WIN32)
108
109 if(ENABLE_GLSLANG_INSTALL)
110     if(BUILD_SHARED_LIBS)
111         install(TARGETS glslang EXPORT glslangTargets
112                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
113                 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
114                 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
115     else()
116         install(TARGETS glslang EXPORT glslangTargets
117                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
118     endif()
119     install(EXPORT glslangTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
120 endif(ENABLE_GLSLANG_INSTALL)
121
122 if(ENABLE_GLSLANG_INSTALL)
123     foreach(file ${HEADERS})
124         get_filename_component(dir ${file} DIRECTORY)
125         install(FILES ${file} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang/${dir})
126     endforeach()
127 endif(ENABLE_GLSLANG_INSTALL)