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