Consolidate the way WTF_USE_PTHREADS is enabled
[WebKit-https.git] / Source / cmake / OptionsBlackBerry.cmake
1 set(PROJECT_VERSION_MAJOR 0)
2 set(PROJECT_VERSION_MINOR 1)
3 set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
4
5 set(DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}-${PROJECT_VERSION})
6
7 add_definitions(-DDATA_DIR="${DATA_DIR}")
8
9 add_definitions(-DWEBCORE_NAVIGATOR_VENDOR="Research In Motion, Ltd.")
10 add_definitions(-DBUILDING_BLACKBERRY__)
11 add_definitions(-DBUILD_WEBKIT)
12
13 # Workaround for now so that SK_DEBUG isn't defined in SkPreConfig.h
14 add_definitions(-DSK_RELEASE)
15
16 # TODO: Make this build-time configurable
17 set(WTF_USE_OPENTYPE_SANITIZER 1)
18 add_definitions(-DWTF_USE_OPENTYPE_SANITIZER=1)
19
20 if (SHARED_CORE)
21     add_definitions(-DWTF_USE_EXPORT_MACROS=1)
22 endif ()
23
24 if (ENABLE_GLES2)
25     set(WTF_USE_ACCELERATED_COMPOSITING 1)
26     add_definitions(-DWTF_USE_ACCELERATED_COMPOSITING=1)
27     add_definitions(-DBLACKBERRY_PLATFORM_GRAPHICS_EGL=1)
28     add_definitions(-DBLACKBERRY_PLATFORM_GRAPHICS_GLES2=1)
29     add_definitions(-DBLACKBERRY_PLATFORM_GRAPHICS_DRAWING_SURFACE=1)
30     add_definitions(-DBLACKBERRY_PLATFORM_EXPORT_WEBDOM=1)
31     add_definitions(-DWTF_USE_ARENA_ALLOC_ALIGNMENT_INTEGER=1)
32 endif ()
33
34 if (ADDITIONAL_SYSTEM_INCLUDE_PATH)
35     set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-Wp,-isystem")
36     set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-Wp,-isystem")
37     foreach (directory ${ADDITIONAL_SYSTEM_INCLUDE_PATH})
38         include_directories(SYSTEM ${directory})
39     endforeach ()
40     if (ENABLE_WEBGL)
41         include_directories(SYSTEM ${THIRDPARTY_DIR}/ANGLE/include) #As system so as to be lower-priority than actual system headers
42     endif ()
43 endif ()
44
45 if (PUBLIC_BUILD)
46     message("*** PUBLIC BUILD ***")
47 else (PUBLIC_BUILD)
48     message("*** DRT is ENABLED ***")
49 endif ()
50
51 add_definitions(-D__QNXNTO__)
52 add_definitions(-D_FILE_OFFSET_BITS=64)
53 add_definitions(-D_LARGEFILE64_SOURCE)
54
55 # Find a library only in the staging directory (which is the CMAKE_INSTALL_PATH)
56 # TODO: CMAKE_INSTALL_PATH may not be staging directory.
57 macro(FIND_STAGING_LIBRARY _var _libname)
58     find_library(${_var} ${_libname}
59         PATHS "${CMAKE_LIBRARY_PATH}"
60         ENV "QNX_TARGET"
61         PATH_SUFFIXES "${CMAKE_SYSTEM_PROCESSOR}/usr/lib" "${CMAKE_SYSTEM_PROCESSOR}/lib"
62         NO_DEFAULT_PATH)
63 endmacro()
64
65 macro(FIND_STAGING_STATIC_LIBRARY _var _libname)
66   set(${_var} "-Bstatic -l${_libname} -Bdynamic" CACHE STRING ${_libname})
67 endmacro()
68
69 FIND_STAGING_LIBRARY(Skia_LIBRARY grskia)
70 FIND_STAGING_LIBRARY(Skia_QNX_LIBRARY skia-qnx)
71 FIND_STAGING_LIBRARY(JPEG_LIBRARY jpeg)
72 FIND_STAGING_LIBRARY(PNG_LIBRARY png)
73 FIND_STAGING_LIBRARY(XML2_LIBRARY xml2)
74 FIND_STAGING_LIBRARY(XSLT_LIBRARY xslt)
75 FIND_STAGING_LIBRARY(SQLITE3_LIBRARY sqlite3)
76 FIND_STAGING_LIBRARY(M_LIBRARY m)
77 FIND_STAGING_LIBRARY(FREETYPE_LIBRARY freetype)
78 FIND_STAGING_LIBRARY(ICUData_LIBRARY icudata)
79 FIND_STAGING_LIBRARY(ICUI18N_LIBRARY icui18n)
80 FIND_STAGING_LIBRARY(ICUUC_LIBRARY icuuc)
81 FIND_STAGING_LIBRARY(INTL_LIBRARY intl)
82 FIND_STAGING_LIBRARY(Z_LIBRARY z)
83 FIND_STAGING_LIBRARY(CURL_LIBRARY curl)
84 FIND_STAGING_LIBRARY(WebKitPlatform_LIBRARY webkitplatform)
85 FIND_STAGING_LIBRARY(EGL_LIBRARY EGL)
86 FIND_STAGING_LIBRARY(GLESv2_LIBRARY GLESv2)
87 FIND_STAGING_LIBRARY(HARFBUZZ_LIBRARY harfbuzz)
88 FIND_STAGING_LIBRARY(FONTCONFIG_LIBRARY fontconfig)
89 FIND_STAGING_LIBRARY(PROFILING_LIBRARY profilingS)
90 FIND_STAGING_LIBRARY(LIB_INPUT_UTILITIES input_utilities)
91 FIND_STAGING_LIBRARY(OTS_LIBRARY ots)
92 FIND_STAGING_LIBRARY(LEVELDB_LIBRARY leveldb)
93 FIND_STAGING_LIBRARY(ITYPE_LIBRARY iType)
94 FIND_STAGING_LIBRARY(WTLE_LIBRARY WTLE)
95
96 # Use jpeg-turbo for device build
97 if (TARGETING_PLAYBOOK)
98     FIND_STAGING_STATIC_LIBRARY(JPEG_LIBRARY jpeg-webkit)
99 else ()
100     FIND_STAGING_LIBRARY(JPEG_LIBRARY jpeg)
101 endif ()
102
103 # Add "-fPIC" to CMAKE_SHARED_LIBRARY_C_FLAGS and CMAKE_SHARED_LIBRARY_CXX_FLAGS
104 # This is because "-fPIC" is not included in the default defines under Modules/Platform/QNX.cmake
105 set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC ${CMAKE_SHARED_LIBRARY_C_FLAGS}")
106 set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")
107
108 # Show unresolved symbols when doing the final shared object link
109 if (PROFILING)
110     set(BLACKBERRY_LINK_FLAGS "-Wl,-z,defs -Wl,-z,relro -Wl,-E -Wl,--no-keep-memory")
111 else (PROFILING)
112     set(BLACKBERRY_LINK_FLAGS "-Wl,-z,defs -Wl,-z,relro -Wl,--no-keep-memory")
113 endif ()
114
115 # Set custom CFLAGS for our port
116 if (CMAKE_COMPILER_IS_GNUCC)
117     set(CMAKE_CXX_FLAGS "-fno-exceptions -fstack-protector -fno-rtti -Wformat -Wformat-security -Werror=format-security ${CMAKE_CXX_FLAGS}")
118     set(CMAKE_C_FLAGS "-fstack-protector -Wformat -Wformat-security -Werror=format-security ${CMAKE_C_FLAGS}")
119     set(JSC_LINK_FLAGS "-Wl,-z,defs -Wl,-z,relro -N1024K")
120 endif ()
121
122 if (PROFILING)
123     set(CMAKE_CXX_FLAGS "-finstrument-functions -g ${CMAKE_CXX_FLAGS}")
124     set(CMAKE_C_FLAGS "-finstrument-functions -g ${CMAKE_C_FLAGS}")
125 endif ()
126
127 # FIXME: Make this more elegant
128 if (TARGETING_PLAYBOOK)
129     set(CMAKE_CXX_FLAGS "-mfpu=neon ${CMAKE_CXX_FLAGS}")
130     set(CMAKE_C_FLAGS "-mfpu=neon ${CMAKE_C_FLAGS}")
131     set(CMAKE_CXX_FLAGS "-mthumb -mthumb-interwork ${CMAKE_CXX_FLAGS}")
132     set(CMAKE_C_FLAGS "-mthumb -mthumb-interwork ${CMAKE_C_FLAGS}")
133     # check for BB_RELEASE_FLAGS or BB_DEBUG_FLAGS to set CMAKE_C_FLAGS{DEBUG|RELEASE} CMAKE_CXX_FLAGS{DEBUG|RELEASE}
134     if (DEFINED ENV{BB_RELEASE_FLAGS})
135         set(CMAKE_CXX_FLAGS_RELEASE  "$ENV{BB_RELEASE_FLAGS} -DNDEBUG")
136         set(CMAKE_C_FLAGS_RELEASE  "$ENV{BB_RELEASE_FLAGS} -DNDEBUG")
137         message("== ENV override RELEASE ${CMAKE_CXX_FLAGS_RELEASE}")
138     endif ()
139     if (DEFINED ENV{BB_DEBUG_FLAGS})
140         set(CMAKE_CXX_FLAGS_DEBUG "$ENV{BB_DEBUG_FLAGS}")
141         set(CMAKE_C_FLAGS_DEBUG "$ENV{BB_DEBUG_FLAGS}")
142         message("== ENV override DEBUG ${CMAKE_CXX_FLAGS_DEBUG}")
143     endif ()
144 endif ()
145
146 include_directories(${CMAKE_INCLUDE_PATH})
147
148 set(JSC_EXECUTABLE_NAME jsc)
149
150 set(WTF_LIBRARY_NAME wtf)
151 set(JavaScriptCore_LIBRARY_NAME javascriptcore)
152 set(WebCore_LIBRARY_NAME webcore)
153 set(WebKit_LIBRARY_NAME webkit)
154 set(WebKit_DRT_LIBRARY_NAME webkit_DRT)
155
156 WEBKIT_OPTION_BEGIN()
157
158 WEBKIT_OPTION_DEFINE(ENABLE_EVENT_MODE_METATAGS "Enable meta-tag touch and mouse events" ON)
159 WEBKIT_OPTION_DEFINE(ENABLE_VIEWPORT_REFLOW "Enable viewport reflow" ON)
160
161 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BATTERY_STATUS ON)
162 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BLOB ON)
163 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_IMAGE_RESOLUTION ON)
164 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CUSTOM_SCHEME_HANDLER ON)
165 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DEVICE_ORIENTATION ON)
166 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DRAG_SUPPORT OFF)
167 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DOWNLOAD_ATTRIBUTE ON)
168 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FAST_MOBILE_SCROLLING ON)
169 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FILE_SYSTEM ON)
170 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FILTERS ON)
171 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FULLSCREEN_API ON)
172 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GEOLOCATION ON)
173 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_HIDDEN_PAGE_DOM_TIMER_THROTTLING ON)
174 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_IMAGE_DECODER_DOWN_SAMPLING ON)
175 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INDEXED_DATABASE ON)
176 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INPUT_TYPE_COLOR ON)
177 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LEGACY_NOTIFICATIONS ON)
178 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LEGACY_VIEWPORT_ADAPTION ON)
179 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LLINT ON)
180 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CAPTURE ON)
181 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_STREAM ON)
182 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MICRODATA ON)
183 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_CONTENT_UTILS ON)
184 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETWORK_INFO ON)
185 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS ON)
186 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ORIENTATION_EVENTS ON)
187 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PAGE_POPUP ON)
188 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PAGE_VISIBILITY_API ON)
189 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REPAINT_THROTTLING ON)
190 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REQUEST_ANIMATION_FRAME ON)
191 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SHARED_WORKERS ON)
192 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SMOOTH_SCROLLING ON)
193 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_STYLE_SCOPED ON)
194 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS ON)
195 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_SLIDER ON)
196 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIBRATION ON)
197 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO ON)
198 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO_TRACK OFF)
199 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_TIMING ON)
200 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_XHR_RESPONSE_BLOB ON)
201
202 if (ENABLE_GLES2)
203     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_3D_RENDERING ON)
204     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS ON)
205     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_FILTERS ON)
206     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_SHADERS ON)
207     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL ON)
208 else ()
209     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_3D_RENDERING OFF)
210     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS OFF)
211     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_FILTERS OFF)
212     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_SHADERS OFF)
213     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL OFF)
214 endif ()
215
216 if (CMAKE_SYSTEM_PROCESSOR MATCHES x86)
217     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_JIT OFF)
218 else ()
219     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_JIT ON)
220 endif ()
221
222 WEBKIT_OPTION_END()
223
224 add_definitions(-DENABLE_BLACKBERRY_CREDENTIAL_PERSIST=1)
225
226 # Some of our files, such as platform/graphics/chromium/ComplexTextControllerLinux.cpp, require a
227 # newer ICU version than the version associated with the headers in {WebCore, JavaScriptCore}/icu.
228 # Because of <https://bugs.webkit.org/show_bug.cgi?id=70913> we can't directly reference these newer
229 # ICU headers within the QNX system header directory. As a workaround, we copy these newer ICU headers
230 # from the QNX system header directory to a third-party directory under the CMake binary tree.
231 #
232 # FIXME: Make this mechanism more general purpose. Maybe accept a list or directories/files to copy
233 # instead of individual variables. Generalizing this solution may allow us to fix <https://bugs.webkit.org/show_bug.cgi?id=70913>.
234 set(BLACKBERRY_THIRD_PARTY_DIR "${CMAKE_BINARY_DIR}/ThirdPartyBlackBerry")
235 file(COPY ${THIRD_PARTY_ICU_DIR} DESTINATION "${BLACKBERRY_THIRD_PARTY_DIR}/icu")
236 file(COPY ${THIRD_PARTY_UNICODE_FILE} DESTINATION ${BLACKBERRY_THIRD_PARTY_DIR})