[CMake] Use target oriented design for bmalloc
[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}/src"
45     "${CMAKE_CURRENT_SOURCE_DIR}/src/common/third_party/base"
46 )
47
48 set(ANGLE_DEFINITIONS
49     ANGLE_ENABLE_ESSL
50 )
51
52 set(ANGLE_SOURCES
53     ${libangle_common_sources}
54     ${angle_preprocessor_sources}
55     ${angle_translator_essl_sources}
56     ${angle_translator_glsl_sources}
57     ${angle_translator_sources}
58 )
59
60 set(ANGLEGLESv2_LIBRARIES
61     ANGLE
62 )
63
64 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
65
66 add_subdirectory(include)
67
68 add_library(ANGLEFramework INTERFACE)
69 add_dependencies(ANGLEFramework GLSLANGHeaders ANGLEHeaders)
70
71 if (USE_ANGLE_EGL)
72     add_library(ANGLE STATIC
73         ${ANGLE_SOURCES}
74         ${libangle_sources}
75         ${libangle_image_util_sources}
76         ${xxhash_sources}
77     )
78     target_include_directories(ANGLE PRIVATE ${ANGLE_PRIVATE_INCLUDE_DIRECTORIES})
79     target_compile_definitions(ANGLE PRIVATE
80         ${no_gl_prototypes}
81         LIBANGLE_IMPLEMENTATION
82     )
83     target_compile_definitions(ANGLE PUBLIC ${ANGLE_DEFINITIONS})
84
85     add_library(GLESv2 SHARED ${libglesv2_sources})
86     target_include_directories(GLESv2 PRIVATE ${ANGLE_PRIVATE_INCLUDE_DIRECTORIES})
87     target_compile_definitions(GLESv2 PRIVATE LIBGLESV2_IMPLEMENTATION)
88     target_link_libraries(GLESv2 ${ANGLEGLESv2_LIBRARIES})
89
90     add_library(EGL SHARED ${libegl_sources})
91     target_include_directories(EGL PRIVATE ${ANGLE_PRIVATE_INCLUDE_DIRECTORIES})
92     target_compile_definitions(EGL PRIVATE
93         ${gl_prototypes}
94         EGLAPI=
95     )
96     target_link_libraries(EGL GLESv2)
97
98     if (WIN32)
99         target_sources(GLESv2 PRIVATE src/libGLESv2/libGLESv2_autogen.def)
100         target_sources(EGL PRIVATE src/libEGL/libEGL.def)
101
102         # Output library names according to the .def
103         set_target_properties(GLESv2 PROPERTIES OUTPUT_NAME libGLESv2)
104         set_target_properties(EGL PROPERTIES OUTPUT_NAME libEGL)
105     endif ()
106
107     target_link_libraries(ANGLEFramework INTERFACE EGL GLESv2)
108     target_compile_definitions(ANGLEFramework INTERFACE ${gl_prototypes})
109 else ()
110     add_library(ANGLE STATIC ${ANGLE_SOURCES})
111     target_include_directories(ANGLE PRIVATE ${ANGLE_PRIVATE_INCLUDE_DIRECTORIES})
112     target_compile_definitions(ANGLE PRIVATE
113         ${ANGLE_DEFINITIONS}
114         ${no_gl_prototypes}
115         LIBANGLE_IMPLEMENTATION
116     )
117 endif ()
118
119 if (COMPILER_IS_GCC_OR_CLANG)
120     WEBKIT_ADD_TARGET_CXX_FLAGS(ANGLE -Wno-cast-align
121                                       -Wno-suggest-attribute=format
122                                       -Wno-type-limits
123                                       -Wno-undef
124                                       -Wno-unused-parameter)
125 endif ()
126
127 target_link_libraries(ANGLEFramework INTERFACE ANGLE)
128 target_include_directories(ANGLEFramework INTERFACE ${ANGLE_FRAMEWORK_HEADERS_DIR})
129
130 set_property(DIRECTORY . PROPERTY FOLDER "ANGLE")