Remove commit.h copying build steps
[WebKit-https.git] / Source / ThirdParty / ANGLE / CMakeLists.txt
1 include(Compiler.cmake)
2 include(GLESv2.cmake)
3
4 if (WIN32)
5     # FIXME: DX11 support will not compile if this preprocessor definition is set
6     # DirectX Documentation is setting that version to 0x700 but there is no
7     # corresponding value in sdkddkver.h
8     remove_definitions(-D_WIN32_WINNT=0x601 -DWINVER=0x601)
9 endif ()
10
11 set(no_gl_prototypes
12     GL_GLES_PROTOTYPES=0
13     EGL_EGL_PROTOTYPES=0
14 )
15
16 set(gl_prototypes
17     GL_GLES_PROTOTYPES=1
18     EGL_EGL_PROTOTYPES=1
19     GL_GLEXT_PROTOTYPES
20     EGL_EGLEXT_PROTOTYPES
21 )
22
23 # ANGLE makes a number of small static libraries that are then joined into a
24 # bigger library that is built shared. Rather than making the small libraries
25 # there will be a ANGLE whose sources are dependent on whether the library
26 # is being used as a compiler or as a GLES implementation.
27 #
28 # The corresponding gn targets are described below
29 #
30 # ANGLE (Compiler only)
31 # + angle_common
32 # + preprocessor
33 # + translator
34 #
35 # ANGLE (GLES)
36 # + ANGLE (Compiler only)
37 # + xxhash
38 # + angle_image_util
39 # + angle_system_utils (OS specific)
40 # + angle_(renderer) (Backend and OS specific)
41
42 set(ANGLE_PRIVATE_INCLUDE_DIRECTORIES
43     "${CMAKE_CURRENT_SOURCE_DIR}/include"
44     "${CMAKE_CURRENT_SOURCE_DIR}/include/KHR"
45     "${CMAKE_CURRENT_SOURCE_DIR}/src"
46     "${CMAKE_CURRENT_SOURCE_DIR}/src/common/third_party/base"
47     "${CMAKE_CURRENT_BINARY_DIR}/include"
48 )
49
50 set(ANGLE_DEFINITIONS
51     ANGLE_ENABLE_ESSL
52 )
53
54 set(ANGLE_SOURCES
55     ${libangle_common_sources}
56     ${angle_preprocessor_sources}
57     ${angle_translator_essl_sources}
58     ${angle_translator_glsl_sources}
59     ${angle_translator_sources}
60     ${libangle_capture_sources}
61 )
62
63 if (UNIX)
64     list(APPEND ANGLE_SOURCES ${angle_system_utils_sources_posix})
65     if (APPLE)
66         list(APPEND ANGLE_SOURCES ${angle_system_utils_sources_mac})
67     else()
68         list(APPEND ANGLE_SOURCES ${angle_system_utils_sources_linux})
69     endif()
70 endif()
71
72 if (WIN32)
73     list(APPEND ANGLE_SOURCES ${angle_system_utils_sources_win})
74 endif()
75
76 set(ANGLEGLESv2_LIBRARIES
77     ANGLE
78 )
79
80 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
81
82 add_subdirectory(include)
83
84 add_library(ANGLEFramework INTERFACE)
85 add_dependencies(ANGLEFramework GLSLANGHeaders ANGLEHeaders)
86
87 if (USE_ANGLE_EGL)
88     add_library(ANGLE STATIC
89         ${ANGLE_SOURCES}
90         ${libangle_sources}
91         ${libangle_image_util_sources}
92         ${xxhash_sources}
93     )
94     target_include_directories(ANGLE PRIVATE ${ANGLE_PRIVATE_INCLUDE_DIRECTORIES})
95     target_compile_definitions(ANGLE PRIVATE
96         ${no_gl_prototypes}
97         LIBANGLE_IMPLEMENTATION
98     )
99     target_compile_definitions(ANGLE PUBLIC ${ANGLE_DEFINITIONS})
100
101     add_library(GLESv2 SHARED
102         ${libglesv2_sources}
103     )
104     target_include_directories(GLESv2 PRIVATE ${ANGLE_PRIVATE_INCLUDE_DIRECTORIES})
105     target_compile_definitions(GLESv2 PRIVATE LIBGLESV2_IMPLEMENTATION)
106     target_link_libraries(GLESv2 ${ANGLEGLESv2_LIBRARIES})
107
108     add_library(EGL SHARED
109         ${libegl_sources}
110     )
111     target_include_directories(EGL PRIVATE ${ANGLE_PRIVATE_INCLUDE_DIRECTORIES})
112     target_compile_definitions(EGL PRIVATE
113         ${gl_prototypes}
114         EGLAPI=
115     )
116     target_link_libraries(EGL GLESv2)
117
118     if (WIN32)
119         target_sources(GLESv2 PRIVATE src/libGLESv2/libGLESv2_autogen.def)
120         target_sources(EGL PRIVATE src/libEGL/libEGL.def)
121
122         # Output library names according to the .def
123         set_target_properties(GLESv2 PROPERTIES OUTPUT_NAME libGLESv2)
124         set_target_properties(EGL PROPERTIES OUTPUT_NAME libEGL)
125     endif ()
126
127     target_link_libraries(ANGLEFramework INTERFACE EGL GLESv2)
128     target_compile_definitions(ANGLEFramework INTERFACE ${gl_prototypes})
129 else ()
130     add_library(ANGLE STATIC ${ANGLE_SOURCES})
131     target_include_directories(ANGLE PRIVATE ${ANGLE_PRIVATE_INCLUDE_DIRECTORIES})
132     target_compile_definitions(ANGLE PRIVATE
133         ${ANGLE_DEFINITIONS}
134         ${no_gl_prototypes}
135         LIBANGLE_IMPLEMENTATION
136     )
137 endif ()
138
139 if (COMPILER_IS_GCC_OR_CLANG)
140     WEBKIT_ADD_TARGET_CXX_FLAGS(ANGLE -Wno-cast-align
141                                       -Wno-suggest-attribute=format
142                                       -Wno-type-limits
143                                       -Wno-undef
144                                       -Wno-unused-parameter)
145 endif ()
146
147 target_link_libraries(ANGLEFramework INTERFACE ANGLE)
148 target_include_directories(ANGLEFramework INTERFACE ${ANGLE_FRAMEWORK_HEADERS_DIR})
149
150 set_property(DIRECTORY . PROPERTY FOLDER "ANGLE")