[GTK] [CMake] Clean up library linking
[WebKit-https.git] / Source / WebKit / PlatformGTK.cmake
1 file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBKITGTK_DIR})
2 file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBKITGTK_API_DIR})
3 configure_file(gtk/webkit/webkitversion.h.in ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitversion.h)
4 configure_file(gtk/webkit.pc.in ${WebKit_PKGCONFIG_FILE} @ONLY)
5
6 add_definitions(-DPACKAGE_LOCALE_DIR="${CMAKE_INSTALL_FULL_LOCALEDIR}")
7
8 list(APPEND WebKit_INCLUDE_DIRECTORIES
9     ${DERIVED_SOURCES_DIR}
10     ${DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR}
11     ${DERIVED_SOURCES_WEBKITGTK_DIR}
12     ${DERIVED_SOURCES_WEBKITGTK_API_DIR}
13     ${THIRDPARTY_DIR}/ANGLE/include/GLSLANG
14     ${THIRDPARTY_DIR}/ANGLE/src
15     ${THIRDPARTY_DIR}/ANGLE/include
16     ${THIRDPARTY_DIR}/ANGLE/include/KHR
17     ${THIRDPARTY_DIR}/ANGLE/include/GLSLANG
18     ${WEBCORE_DIR}/ForwardingHeaders
19     ${WEBCORE_DIR}/accessibility/atk
20     ${WEBCORE_DIR}/platform/cairo
21     ${WEBCORE_DIR}/platform/geoclue
22     ${WEBCORE_DIR}/platform/graphics/cairo
23     ${WEBCORE_DIR}/platform/graphics/gtk
24     ${WEBCORE_DIR}/platform/graphics/opentype
25     ${WEBCORE_DIR}/platform/graphics/texmap
26     ${WEBCORE_DIR}/platform/gtk
27     ${WEBCORE_DIR}/platform/network/soup
28     ${WEBCORE_DIR}/platform/text/enchant
29     ${WEBKIT_DIR}/gtk
30     ${WEBKIT_DIR}/gtk/webkit
31     ${WEBKIT_DIR}/gtk/WebCoreSupport
32     ${ENCHANT_INCLUDE_DIRS}
33     ${GEOCLUE_INCLUDE_DIRS}
34     ${GTK_INCLUDE_DIRS}
35     ${LIBSOUP_INCLUDE_DIRS}
36 )
37
38 list(APPEND WebKit_SOURCES
39     ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitenumtypes.cpp
40     ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitmarshal.cpp
41
42     gtk/WebCoreSupport/AcceleratedCompositingContextGL.cpp
43     gtk/WebCoreSupport/ChromeClientGtk.cpp
44     gtk/WebCoreSupport/ContextMenuClientGtk.cpp
45     gtk/WebCoreSupport/DeviceMotionClientGtk.cpp
46     gtk/WebCoreSupport/DeviceOrientationClientGtk.cpp
47     gtk/WebCoreSupport/DocumentLoaderGtk.cpp
48     gtk/WebCoreSupport/DragClientGtk.cpp
49     gtk/WebCoreSupport/DumpRenderTreeSupportGtk.cpp
50     gtk/WebCoreSupport/EditorClientGtk.cpp
51     gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
52     gtk/WebCoreSupport/FrameNetworkingContextGtk.cpp
53     gtk/WebCoreSupport/GeolocationClientGtk.cpp
54     gtk/WebCoreSupport/GtkAdjustmentWatcher.cpp
55     gtk/WebCoreSupport/InspectorClientGtk.cpp
56     gtk/WebCoreSupport/NavigatorContentUtilsClientGtk.cpp
57     gtk/WebCoreSupport/PlatformStrategiesGtk.cpp
58     gtk/WebCoreSupport/ProgressTrackerClientGtk.cpp
59     gtk/WebCoreSupport/TextCheckerClientGtk.cpp
60     gtk/WebCoreSupport/UserMediaClientGtk.cpp
61     gtk/WebCoreSupport/WebViewInputMethodFilter.cpp
62
63     gtk/webkit/webkitapplicationcache.cpp
64     gtk/webkit/webkitauthenticationdialog.cpp
65     gtk/webkit/webkitdownload.cpp
66     gtk/webkit/webkiterror.cpp
67     gtk/webkit/webkitfavicondatabase.cpp
68     gtk/webkit/webkitfilechooserrequest.cpp
69     gtk/webkit/webkitgeolocationpolicydecision.cpp
70     gtk/webkit/webkitglobals.cpp
71     gtk/webkit/webkithittestresult.cpp
72     gtk/webkit/webkiticondatabase.cpp
73     gtk/webkit/webkitnetworkrequest.cpp
74     gtk/webkit/webkitnetworkresponse.cpp
75     gtk/webkit/webkitsecurityorigin.cpp
76     gtk/webkit/webkitsoupauthdialog.cpp
77     gtk/webkit/webkitspellchecker.cpp
78     gtk/webkit/webkitspellcheckerenchant.cpp
79     gtk/webkit/webkitversion.cpp
80     gtk/webkit/webkitviewportattributes.cpp
81     gtk/webkit/webkitwebbackforwardlist.cpp
82     gtk/webkit/webkitwebdatabase.cpp
83     gtk/webkit/webkitwebdatasource.cpp
84     gtk/webkit/webkitwebframe.cpp
85     gtk/webkit/webkitwebhistoryitem.cpp
86     gtk/webkit/webkitwebinspector.cpp
87     gtk/webkit/webkitwebnavigationaction.cpp
88     gtk/webkit/webkitwebplugin.cpp
89     gtk/webkit/webkitwebplugindatabase.cpp
90     gtk/webkit/webkitwebpolicydecision.cpp
91     gtk/webkit/webkitwebresource.cpp
92     gtk/webkit/webkitwebsettings.cpp
93     gtk/webkit/webkitwebview.cpp
94     gtk/webkit/webkitwebwindowfeatures.cpp
95 )
96
97 list(APPEND WebKitGTK_INSTALLED_HEADERS
98     ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitenumtypes.h
99     ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitversion.h
100     ${WEBKIT_DIR}/gtk/webkit/webkit.h
101     ${WEBKIT_DIR}/gtk/webkit/webkitapplicationcache.h
102     ${WEBKIT_DIR}/gtk/webkit/webkitdefines.h
103     ${WEBKIT_DIR}/gtk/webkit/webkitdom.h
104     ${WEBKIT_DIR}/gtk/webkit/webkitdownload.h
105     ${WEBKIT_DIR}/gtk/webkit/webkiterror.h
106     ${WEBKIT_DIR}/gtk/webkit/webkitfavicondatabase.h
107     ${WEBKIT_DIR}/gtk/webkit/webkitfilechooserrequest.h
108     ${WEBKIT_DIR}/gtk/webkit/webkitgeolocationpolicydecision.h
109     ${WEBKIT_DIR}/gtk/webkit/webkitglobals.h
110     ${WEBKIT_DIR}/gtk/webkit/webkithittestresult.h
111     ${WEBKIT_DIR}/gtk/webkit/webkiticondatabase.h
112     ${WEBKIT_DIR}/gtk/webkit/webkitnetworkrequest.h
113     ${WEBKIT_DIR}/gtk/webkit/webkitnetworkresponse.h
114     ${WEBKIT_DIR}/gtk/webkit/webkitsecurityorigin.h
115     ${WEBKIT_DIR}/gtk/webkit/webkitsoupauthdialog.h
116     ${WEBKIT_DIR}/gtk/webkit/webkitspellchecker.h
117     ${WEBKIT_DIR}/gtk/webkit/webkitviewportattributes.h
118     ${WEBKIT_DIR}/gtk/webkit/webkitwebbackforwardlist.h
119     ${WEBKIT_DIR}/gtk/webkit/webkitwebdatabase.h
120     ${WEBKIT_DIR}/gtk/webkit/webkitwebdatasource.h
121     ${WEBKIT_DIR}/gtk/webkit/webkitwebframe.h
122     ${WEBKIT_DIR}/gtk/webkit/webkitwebhistoryitem.h
123     ${WEBKIT_DIR}/gtk/webkit/webkitwebinspector.h
124     ${WEBKIT_DIR}/gtk/webkit/webkitwebnavigationaction.h
125     ${WEBKIT_DIR}/gtk/webkit/webkitwebplugin.h
126     ${WEBKIT_DIR}/gtk/webkit/webkitwebplugindatabase.h
127     ${WEBKIT_DIR}/gtk/webkit/webkitwebpolicydecision.h
128     ${WEBKIT_DIR}/gtk/webkit/webkitwebresource.h
129     ${WEBKIT_DIR}/gtk/webkit/webkitwebsettings.h
130     ${WEBKIT_DIR}/gtk/webkit/webkitwebview.h
131     ${WEBKIT_DIR}/gtk/webkit/webkitwebwindowfeatures.h
132 )
133
134 # Since the GObjectDOMBindings convenience library exports API that is unused except
135 # in embedding applications we need to instruct the linker to link all symbols explicitly.
136 list(APPEND WebKit_LIBRARIES
137     GObjectDOMBindings
138     WebCorePlatformGTK
139 )
140 ADD_WHOLE_ARCHIVE_TO_LIBRARIES(WebKit_LIBRARIES)
141
142 set(WebKit_MARSHAL_LIST ${WEBKIT_DIR}/gtk/webkitmarshal.list)
143
144 add_custom_command(
145     OUTPUT ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitmarshal.cpp
146            ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitmarshal.h
147     MAIN_DEPENDENCY ${WebKit_MARSHAL_LIST}
148
149     COMMAND echo extern \"C\" { > ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitmarshal.cpp
150     COMMAND glib-genmarshal --prefix=webkit_marshal ${WebKit_MARSHAL_LIST} --body >> ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitmarshal.cpp
151     COMMAND echo } >> ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitmarshal.cpp
152
153     COMMAND glib-genmarshal --prefix=webkit_marshal ${WebKit_MARSHAL_LIST} --header > ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitmarshal.h
154     VERBATIM
155 )
156
157 # To generate webkitenumtypes.h we want to use all installed headers, except webkitenumtypes.h itself.
158 set(WebKitGTK_ENUM_GENERATION_HEADERS ${WebKitGTK_INSTALLED_HEADERS})
159 list(REMOVE_ITEM WebKitGTK_ENUM_GENERATION_HEADERS ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitenumtypes.h)
160 add_custom_command(
161     OUTPUT ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitenumtypes.h
162            ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitenumtypes.cpp
163     DEPENDS ${WebKitGTK_ENUM_GENERATION_HEADERS}
164
165     COMMAND glib-mkenums --template ${WEBKIT_DIR}/gtk/webkit/webkitenumtypes.h.template ${WebKitGTK_ENUM_GENERATION_HEADERS} | sed s/web_kit/webkit/ | sed s/WEBKIT_TYPE_KIT/WEBKIT_TYPE/ > ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitenumtypes.h
166
167     COMMAND glib-mkenums --template ${WEBKIT_DIR}/gtk/webkit/webkitenumtypes.cpp.template ${WebKitGTK_ENUM_GENERATION_HEADERS} | sed s/web_kit/webkit/ > ${DERIVED_SOURCES_WEBKITGTK_API_DIR}/webkitenumtypes.cpp
168     VERBATIM
169 )
170
171 add_custom_command(
172     OUTPUT ${CMAKE_BINARY_DIR}/WebKit-${WEBKITGTK_API_VERSION}.gir
173     DEPENDS WebKit
174     DEPENDS ${CMAKE_BINARY_DIR}/JavaScriptCore-${WEBKITGTK_API_VERSION}.gir
175     COMMAND CC=${CMAKE_C_COMPILER} CFLAGS=-Wno-deprecated-declarations
176         ${INTROSPECTION_SCANNER}
177         --quiet
178         --warn-all
179         --symbol-prefix=webkit
180         --identifier-prefix=WebKit
181         --namespace=WebKit
182         --nsversion=${WEBKITGTK_API_VERSION}
183         --include=GObject-2.0
184         --include=Gtk-${WEBKITGTK_API_VERSION}
185         --include=Soup-2.4
186         --include-uninstalled=${CMAKE_BINARY_DIR}/JavaScriptCore-${WEBKITGTK_API_VERSION}.gir
187         --library=webkitgtk-${WEBKITGTK_API_VERSION}
188         --library=javascriptcoregtk-${WEBKITGTK_API_VERSION}
189         -L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
190         --no-libtool
191         --pkg=gobject-2.0
192         --pkg=gtk+-${WEBKITGTK_API_VERSION}
193         --pkg=libsoup-2.4
194         --pkg-export=webkitgtk-${WEBKITGTK_API_VERSION}
195         --output=${CMAKE_BINARY_DIR}/WebKit-${WEBKITGTK_API_VERSION}.gir
196         --c-include="webkit/webkit.h"
197         -DBUILDING_WEBKIT
198         -I${CMAKE_SOURCE_DIR}/Source
199         -I${WEBKIT_DIR}/gtk
200         -I${JAVASCRIPTCORE_DIR}/ForwardingHeaders
201         -I${DERIVED_SOURCES_DIR}
202         -I${DERIVED_SOURCES_WEBKITGTK_DIR}
203         -I${WEBCORE_DIR}/platform/gtk
204         ${GObjectDOMBindings_GIR_HEADERS}
205         ${WebKitGTK_INSTALLED_HEADERS}
206         ${WEBKIT_DIR}/gtk/webkit/*.cpp
207 )
208
209 add_custom_command(
210     OUTPUT ${CMAKE_BINARY_DIR}/WebKit-${WEBKITGTK_API_VERSION}.typelib
211     DEPENDS ${CMAKE_BINARY_DIR}/WebKit-${WEBKITGTK_API_VERSION}.gir
212     COMMAND ${INTROSPECTION_COMPILER} --includedir=${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/WebKit-${WEBKITGTK_API_VERSION}.gir -o ${CMAKE_BINARY_DIR}/WebKit-${WEBKITGTK_API_VERSION}.typelib
213 )
214
215 ADD_TYPELIB(${CMAKE_BINARY_DIR}/WebKit-${WEBKITGTK_API_VERSION}.typelib)
216
217 install(FILES "${CMAKE_BINARY_DIR}/Source/WebKit/gtk/webkitgtk-${WEBKITGTK_API_VERSION}.pc"
218         DESTINATION "${LIB_INSTALL_DIR}/pkgconfig"
219 )
220 install(FILES "${WEBKIT_DIR}/gtk/resources/error.html"
221         DESTINATION "${DATA_INSTALL_DIR}/resources"
222 )
223 install(FILES ${WebKitGTK_INSTALLED_HEADERS}
224         DESTINATION "${WEBKITGTK_HEADER_INSTALL_DIR}/webkit"
225 )
226 install(FILES ${CMAKE_BINARY_DIR}/WebKit-${WEBKITGTK_API_VERSION}.gir
227         DESTINATION ${INTROSPECTION_INSTALL_GIRDIR}
228 )
229 install(FILES ${CMAKE_BINARY_DIR}/WebKit-${WEBKITGTK_API_VERSION}.typelib
230         DESTINATION ${INTROSPECTION_INSTALL_TYPELIBDIR}
231 )
232
233 file(WRITE ${CMAKE_BINARY_DIR}/gtkdoc-webkitgtk.cfg
234     "[webkitgtk]\n"
235     "pkgconfig_file=${WebKit_PKGCONFIG_FILE}\n"
236     "namespace=webkit\n"
237     "cflags=-I${DERIVED_SOURCES_DIR}\n"
238     "       -I${CMAKE_SOURCE_DIR}\n"
239     "       -I${CMAKE_SOURCE_DIR}/Source\n"
240     "       -I${CMAKE_SOURCE_DIR}/JavaScriptCore/ForwardingHeaders\n"
241     "doc_dir=${WEBKIT_DIR}/gtk/docs\n"
242     "source_dirs=${WEBKIT_DIR}/gtk/webkit\n"
243     "            ${DERIVED_SOURCES_WEBKITGTK_API_DIR}\n"
244     "headers=${WebKitGTK_ENUM_GENERATION_HEADERS}\n"
245 )