[CMake] Share build system options across ports
[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(-DBUILDING_BLACKBERRY__)
10 ADD_DEFINITIONS(-DBUILD_WEBKIT)
11
12 # Workaround for now so that SK_DEBUG isn't defined in SkPreConfig.h
13 ADD_DEFINITIONS(-DSK_RELEASE)
14
15 # TODO: Make this build-time configurable
16 SET(WTF_USE_PTHREADS 1)
17 ADD_DEFINITIONS(-DWTF_USE_PTHREADS=1)
18 SET(WTF_USE_OPENTYPE_SANITIZER 1)
19 ADD_DEFINITIONS(-DWTF_USE_OPENTYPE_SANITIZER=1)
20
21 IF (TARGETING_PLAYBOOK)
22     SET(WTF_USE_ACCELERATED_COMPOSITING 1)
23     ADD_DEFINITIONS(-DWTF_USE_ACCELERATED_COMPOSITING=1)
24     ADD_DEFINITIONS(-DBLACKBERRY_PLATFORM_GRAPHICS_EGL=1)
25     ADD_DEFINITIONS(-DBLACKBERRY_PLATFORM_EXPORT_WEBDOM=1)
26 ENDIF ()
27
28 IF (ADDITIONAL_SYSTEM_INCLUDE_PATH)
29     SET(CMAKE_INCLUDE_SYSTEM_FLAG_C "-Wp,-isystem")
30     SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-Wp,-isystem")
31     FOREACH (directory ${ADDITIONAL_SYSTEM_INCLUDE_PATH})
32         INCLUDE_DIRECTORIES(SYSTEM ${directory})
33     ENDFOREACH ()
34 ENDIF ()
35
36 IF (ENABLE_DRT)
37     message("*** DRT is ENABLED ***")
38 ENDIF ()
39
40 ADD_DEFINITIONS(-D__QNXNTO__)
41 ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
42 ADD_DEFINITIONS(-D_LARGEFILE64_SOURCE)
43
44 # Find a library only in the staging directory (which is the CMAKE_INSTALL_PATH)
45 # TODO: CMAKE_INSTALL_PATH may not be staging directory.
46 MACRO(FIND_STAGING_LIBRARY _var _libname)
47   FIND_LIBRARY(${_var} ${_libname}
48     PATHS "${CMAKE_INSTALL_PREFIX}"
49     ENV "QNX_TARGET"
50     PATH_SUFFIXES "${CMAKE_SYSTEM_PROCESSOR}/usr/lib" "${CMAKE_SYSTEM_PROCESSOR}/usr/lib/torch-webkit" "${CMAKE_SYSTEM_PROCESSOR}/lib"
51     NO_DEFAULT_PATH)
52 ENDMACRO()
53
54 FIND_STAGING_LIBRARY(Skia_LIBRARY grskia)
55 FIND_STAGING_LIBRARY(Skia_QNX_LIBRARY skia-qnx)
56 FIND_STAGING_LIBRARY(JPEG_LIBRARY jpeg)
57 FIND_STAGING_LIBRARY(PNG_LIBRARY png)
58 FIND_STAGING_LIBRARY(XML2_LIBRARY xml2)
59 FIND_STAGING_LIBRARY(XSLT_LIBRARY xslt)
60 FIND_STAGING_LIBRARY(SQLITE3_LIBRARY sqlite3)
61 FIND_STAGING_LIBRARY(M_LIBRARY m)
62 FIND_STAGING_LIBRARY(NBUTIL_LIBRARY nbutil)
63 FIND_STAGING_LIBRARY(FREETYPE_LIBRARY freetype)
64 FIND_STAGING_LIBRARY(ICUData_LIBRARY icudata)
65 FIND_STAGING_LIBRARY(ICUI18N_LIBRARY icui18n)
66 FIND_STAGING_LIBRARY(ICUUC_LIBRARY icuuc)
67 FIND_STAGING_LIBRARY(Iconv_LIBRARY iconv)
68 FIND_STAGING_LIBRARY(INTL_LIBRARY intl)
69 FIND_STAGING_LIBRARY(Z_LIBRARY z)
70 FIND_STAGING_LIBRARY(Socket_LIBRARY socket)
71 FIND_STAGING_LIBRARY(CURL_LIBRARY curl)
72 FIND_STAGING_LIBRARY(SSL_LIBRARY ssl)
73 FIND_STAGING_LIBRARY(Crypto_LIBRARY crypto)
74 FIND_STAGING_LIBRARY(WebKitPlatform_LIBRARY webkitplatform)
75 FIND_STAGING_LIBRARY(UUID_LIBRARY uuid-browser)
76 FIND_STAGING_LIBRARY(Screen_LIBRARY screen)
77 FIND_STAGING_LIBRARY(MMR_LIBRARY mmrndclient)
78 FIND_STAGING_LIBRARY(PPSCache_LIBRARY ppscache)
79 FIND_STAGING_LIBRARY(MD_LIBRARY md)
80 FIND_STAGING_LIBRARY(AOI_LIBRARY aoi)
81 FIND_STAGING_LIBRARY(CLIPBOARD_LIBRARY clipboard)
82 FIND_STAGING_LIBRARY(EGL_LIBRARY EGL)
83 FIND_STAGING_LIBRARY(GLESv2_LIBRARY GLESv2)
84 FIND_STAGING_LIBRARY(STRM_LIBRARY strm)
85 FIND_STAGING_LIBRARY(HARFBUZZ_LIBRARY harfbuzz)
86 FIND_STAGING_LIBRARY(FONTCONFIG_LIBRARY fontconfig)
87 FIND_STAGING_LIBRARY(PROFILING_LIBRARY profilingS)
88 FIND_STAGING_LIBRARY(LIB_INPUT_UTILITIES input_utilities)
89 FIND_STAGING_LIBRARY(OTS_LIBRARY ots)
90
91 # Show unresolved symbols when doing the final shared object link
92 IF (PROFILING)
93     SET(BLACKBERRY_LINK_FLAGS "-Wl,-z,defs -Wl,-zrelro -Wl,-E")
94 ELSE (PROFILING)
95     SET(BLACKBERRY_LINK_FLAGS "-Wl,-z,defs -Wl,-zrelro")
96 ENDIF ()
97
98 # Set custom CFLAGS for our port
99 IF (CMAKE_COMPILER_IS_GNUCC)
100     SET(CMAKE_CXX_FLAGS "-fstack-protector -fno-rtti -Wformat -Wformat-security -Werror=format-security ${CMAKE_CXX_FLAGS}")
101     SET(CMAKE_C_FLAGS "-fstack-protector -fno-rtti -Wformat -Wformat-security -Werror=format-security ${CMAKE_C_FLAGS}")
102     SET(JSC_LINK_FLAGS "-N1024K")
103 ENDIF ()
104
105 IF (PROFILING)
106     SET(CMAKE_CXX_FLAGS "-finstrument-functions -g ${CMAKE_CXX_FLAGS}")
107     SET(CMAKE_C_FLAGS "-finstrument-functions -g ${CMAKE_C_FLAGS}")
108 ENDIF ()
109
110 # FIXME: Make this more elegant
111 IF (TARGETING_PLAYBOOK)
112     SET(CMAKE_CXX_FLAGS "-mfpu=vfpv3 -mthumb -mthumb-interwork ${CMAKE_CXX_FLAGS}")
113     SET(CMAKE_C_FLAGS "-mfpu=vfpv3 -mthumb -mthumb-interwork ${CMAKE_C_FLAGS}")
114 ENDIF ()
115
116 ADD_DEFINITIONS(-DRESOURCE_PATH="/usr/share/webkit-owb/resources/")
117 INCLUDE_DIRECTORIES(${CMAKE_INCLUDE_PATH})
118
119 SET(JSC_EXECUTABLE_NAME jsc)
120
121 SET(WTF_LIBRARY_NAME wtf)
122 SET(JavaScriptCore_LIBRARY_NAME javascriptcore)
123 SET(WebCore_LIBRARY_NAME webcore)
124 SET(WebKit_LIBRARY_NAME webkit)
125 SET(WebKit_DRT_LIBRARY_NAME webkit_DRT)
126
127 WEBKIT_OPTION_BEGIN()
128
129 WEBKIT_OPTION_DEFINE(ENABLE_EVENT_MODE_METATAGS "Enable meta-tag touch and mouse events" ON)
130 WEBKIT_OPTION_DEFINE(ENABLE_VIEWPORT_REFLOW "Enable viewport reflow" ON)
131
132 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ANIMATION_API ON)
133 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ASSEMBLER_WX_EXCLUSIVE ON)
134 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BATTERY_STATUS ON)
135 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BLOB ON)
136 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DEVICE_ORIENTATION ON)
137 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DOWNLOAD_ATTRIBUTE ON)
138 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FILE_SYSTEM ON)
139 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FILTERS ON)
140 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GEOLOCATION ON)
141 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_IMAGE_DECODER_DOWN_SAMPLING ON)
142 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INPUT_TYPE_COLOR ON)
143 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LEGACY_NOTIFICATIONS ON)
144 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS ON)
145 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ORIENTATION_EVENTS ON)
146 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PAGE_VISIBILITY_API ON)
147 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REPAINT_THROTTLING ON)
148 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REQUEST_ANIMATION_FRAME ON)
149 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SHARED_WORKERS ON)
150 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS ON)
151 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIBRATION ON)
152 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO ON)
153 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_TIMING ON)
154 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WORKERS ON)
155
156 IF (TARGETING_PLAYBOOK)
157     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_3D_RENDERING ON)
158     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL ON)
159 ELSE ()
160     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_3D_RENDERING OFF)
161     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL OFF)
162 ENDIF ()
163
164 IF (CMAKE_SYSTEM_PROCESSOR MATCHES x86)
165     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_JIT OFF)
166 ELSE ()
167     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_JIT ON)
168 ENDIF ()
169
170 WEBKIT_OPTION_END()
171
172 # Some of our files, such as platform/graphics/chromium/ComplexTextControllerLinux.cpp, require a
173 # newer ICU version than the version associated with the headers in {WebCore, JavaScriptCore}/icu.
174 # Because of <https://bugs.webkit.org/show_bug.cgi?id=70913> we can't directly reference these newer
175 # ICU headers within the QNX system header directory. As a workaround, we copy these newer ICU headers
176 # from the QNX system header directory to a third-party directory under the CMake binary tree.
177 #
178 # FIXME: Make this mechanism more general purpose. Maybe accept a list or directories/files to copy
179 # instead of individual variables. Generalizing this solution may allow us to fix <https://bugs.webkit.org/show_bug.cgi?id=70913>.
180 SET(BLACKBERRY_THIRD_PARTY_DIR "${CMAKE_BINARY_DIR}/ThirdPartyBlackBerry")
181 FILE(COPY ${THIRD_PARTY_ICU_DIR} DESTINATION "${BLACKBERRY_THIRD_PARTY_DIR}/icu")
182 FILE(COPY ${THIRD_PARTY_UNICODE_FILE} DESTINATION ${BLACKBERRY_THIRD_PARTY_DIR})