[GTK] Be able to disable gtk2 dependency
[WebKit-https.git] / Source / cmake / OptionsGTK.cmake
1 include(GNUInstallDirs)
2
3 set(PROJECT_VERSION_MAJOR 2)
4 set(PROJECT_VERSION_MINOR 5)
5 set(PROJECT_VERSION_MICRO 1)
6 set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_MICRO})
7 set(WEBKITGTK_API_VERSION 4.0)
8
9 # Libtool library version, not to be confused with API version.
10 # See http://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
11 CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(WEBKIT2 37 0 0)
12 CALCULATE_LIBRARY_VERSIONS_FROM_LIBTOOL_TRIPLE(JAVASCRIPTCORE 18 0 0)
13
14 set(ENABLE_CREDENTIAL_STORAGE ON CACHE BOOL "Whether or not to enable support for credential storage using libsecret.")
15 set(ENABLE_GTKDOC OFF CACHE BOOL "Whether or not to use generate gtkdoc.")
16 set(ENABLE_X11_TARGET ON CACHE BOOL "Whether to enable support for the X11 windowing target.")
17 set(ENABLE_WAYLAND_TARGET OFF CACHE BOOL "Whether to enable support for the Wayland windowing target.")
18
19 # These are shared variables, but we special case their definition so that we can use the
20 # CMAKE_INSTALL_* variables that are populated by the GNUInstallDirs macro.
21 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBDIR}" CACHE PATH "Absolute path to library installation directory")
22 set(EXEC_INSTALL_DIR "${CMAKE_INSTALL_FULL_BINDIR}" CACHE PATH "Absolute path to executable installation directory")
23 set(LIBEXEC_INSTALL_DIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}" CACHE PATH "Absolute path to install executables executed by the library")
24
25 set(DATA_BUILD_DIR "${CMAKE_BINARY_DIR}/share/${WebKit_OUTPUT_NAME}")
26 set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/webkitgtk-${WEBKITGTK_API_VERSION}")
27 set(WEBKITGTK_HEADER_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/webkitgtk-${WEBKITGTK_API_VERSION}")
28
29 find_package(Cairo 1.10.2 REQUIRED)
30 find_package(Fontconfig 2.8.0 REQUIRED)
31 find_package(Freetype2 2.4.2 REQUIRED)
32 find_package(HarfBuzz 0.9.2 REQUIRED)
33 find_package(ICU REQUIRED)
34 find_package(JPEG REQUIRED)
35 find_package(LibSoup 2.40.3 REQUIRED)
36 find_package(LibXml2 2.8.0 REQUIRED)
37 find_package(LibXslt 1.1.7 REQUIRED)
38 find_package(PNG REQUIRED)
39 find_package(Sqlite REQUIRED)
40 find_package(Threads REQUIRED)
41 find_package(ZLIB REQUIRED)
42 find_package(ATK REQUIRED)
43 find_package(WebP REQUIRED)
44 find_package(ATSPI 2.5.3)
45 find_package(GObjectIntrospection)
46 find_package(OpenGL)
47 find_package(EGL)
48 find_package(GeoClue2 2.1.5)
49
50 if (NOT GEOCLUE2_FOUND)
51     find_package(GeoClue)
52 endif ()
53
54 if (ENABLE_X11_TARGET)
55     # We don't use find_package for GLX because it is part of -lGL, unlike EGL.
56     check_include_files("GL/glx.h" GLX_FOUND)
57 endif ()
58
59 WEBKIT_OPTION_BEGIN()
60 WEBKIT_OPTION_DEFINE(ENABLE_PLUGIN_PROCESS_GTK2 "Whether to build WebKitPluginProcess2 to load GTK2 based plugins." ON)
61
62 if (OPENGL_FOUND AND (GLX_FOUND OR EGL_FOUND))
63     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL ON)
64
65     if (GLX_FOUND)
66         list(APPEND CAIRO_GL_COMPONENTS cairo-glx)
67     endif ()
68     if (EGL_FOUND)
69         list(APPEND CAIRO_GL_COMPONENTS cairo-egl)
70     endif ()
71     find_package(CairoGL 1.10.2 COMPONENTS ${CAIRO_GL_COMPONENTS})
72     if (CAIRO_GL_FOUND)
73         WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS ON)
74     else ()
75         WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS OFF)
76     endif ()
77 else ()
78     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEBGL OFF)
79     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS OFF)
80 endif ()
81
82 if (GEOCLUE2_FOUND OR GEOCLUE_FOUND)
83     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GEOLOCATION ON)
84 else ()
85     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GEOLOCATION OFF)
86 endif ()
87
88 if (DEVELOPER_MODE)
89     set(ENABLE_TOOLS ON)
90     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS ON)
91 else ()
92     set(ENABLE_TOOLS OFF)
93     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS OFF)
94     set(VERSION_SCRIPT "-Wl,--version-script,${CMAKE_SOURCE_DIR}/Source/autotools/symbols.filter")
95 endif ()
96
97 # FIXME: We want to expose fewer options to downstream, but for now everything is public.
98 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_3D_RENDERING ON)
99 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCESSIBILITY ON)
100 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BATTERY_STATUS OFF)
101 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CANVAS_PATH OFF)
102 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS3_CONDITIONAL_RULES ON)
103 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS3_TEXT OFF)
104 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_DEVICE_ADAPTATION OFF)
105 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_FILTERS ON)
106 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_GRID_LAYOUT OFF)
107 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_IMAGE_SET OFF)
108 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_REGIONS ON)
109 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_SELECTORS_LEVEL4 ON)
110 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_TRANSFORMS_ANIMATIONS_UNPREFIXED OFF)
111 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CUSTOM_SCHEME_HANDLER OFF)
112 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DATALIST_ELEMENT OFF)
113 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DOWNLOAD_ATTRIBUTE OFF)
114 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DRAG_SUPPORT ON)
115 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA OFF)
116 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ENCRYPTED_MEDIA_V2 OFF)
117 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FILTERS ON)
118 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FTPDIR OFF)
119 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FULLSCREEN_API ON)
120 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GAMEPAD OFF)
121 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GAMEPAD_DEPRECATED OFF)
122 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INDEXED_DATABASE OFF)
123 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INDEXED_DATABASE_IN_WORKERS OFF)
124 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INPUT_TYPE_COLOR OFF)
125 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LEGACY_WEB_AUDIO OFF)
126 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LINK_PREFETCH OFF)
127 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CAPTURE OFF)
128 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_CONTROLS_SCRIPT ON)
129 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEMORY_SAMPLER ON)
130 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MHTML ON)
131 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_CONTENT_UTILS OFF)
132 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NAVIGATOR_HWCONCURRENCY ON)
133 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETSCAPE_PLUGIN_API ON)
134 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PICTURE_SIZES ON)
135 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_QUOTA OFF)
136 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOLUTION_MEDIA_QUERY OFF)
137 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REQUEST_ANIMATION_FRAME ON)
138 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SECCOMP_FILTERS OFF)
139 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SHARED_WORKERS ON)
140 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SPELLCHECK ON)
141 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TEMPLATE_ELEMENT ON)
142 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS ON)
143 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USERSELECT_ALL ON)
144 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIBRATION OFF)
145 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO ON)
146 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO_TRACK ON)
147 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIEW_MODE_CSS_MEDIA ON)
148 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_AUDIO ON)
149 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_WEB_TIMING ON)
150 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_XHR_TIMEOUT ON)
151 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NETWORK_PROCESS ON)
152 WEBKIT_OPTION_DEFAULT_PORT_VALUE(WTF_USE_TILED_BACKING_STORE OFF)
153 WEBKIT_OPTION_END()
154
155 if (ENABLE_PLUGIN_PROCESS_GTK2)
156     find_package(GTK2 2.24.10 REQUIRED)
157     find_package(GDK2 2.24.10 REQUIRED)
158     add_definitions(-DENABLE_PLUGIN_PROCESS_GTK2=1)
159 endif ()
160
161 if (ENABLE_X11_TARGET)
162     add_definitions(-DWTF_PLATFORM_X11=1)
163     add_definitions(-DMOZ_X11=1)
164     if (WTF_OS_UNIX)
165         add_definitions(-DXP_UNIX)
166     endif ()
167 endif ()
168
169 if (ENABLE_WAYLAND_TARGET)
170     add_definitions(-DWTF_PLATFORM_WAYLAND=1)
171 endif ()
172
173 set(ENABLE_WEBCORE ON)
174 set(ENABLE_INSPECTOR ON)
175 set(ENABLE_WEBKIT OFF)
176 set(ENABLE_WEBKIT2 ON)
177 set(ENABLE_PLUGIN_PROCESS ON)
178
179 set(GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_6)
180 set(GTK_API_VERSION 3.0)
181
182 set(WTF_USE_SOUP 1)
183 set(WTF_USE_UDIS86 1)
184
185 set(WTF_LIBRARY_TYPE STATIC)
186 set(WTF_OUTPUT_NAME WTFGTK)
187 set(JavaScriptCore_OUTPUT_NAME javascriptcoregtk-${WEBKITGTK_API_VERSION})
188 set(WebCore_OUTPUT_NAME WebCoreGTK)
189 set(WebKit_OUTPUT_NAME webkitgtk-${WEBKITGTK_API_VERSION})
190 set(WebKit2_OUTPUT_NAME webkit2gtk-${WEBKITGTK_API_VERSION})
191 set(WebKit2_WebProcess_OUTPUT_NAME WebKitWebProcess)
192 set(WebKit2_NetworkProcess_OUTPUT_NAME WebKitNetworkProcess)
193 set(WebKit2_PluginProcess_OUTPUT_NAME WebKitPluginProcess)
194
195 add_definitions(-DBUILDING_GTK__=1)
196 add_definitions(-DGETTEXT_PACKAGE="WebKit2GTK-${WEBKITGTK_API_VERSION}")
197 add_definitions(-DDATA_DIR="${CMAKE_INSTALL_DATADIR}")
198 add_definitions(-DUSER_AGENT_GTK_MAJOR_VERSION=601)
199 add_definitions(-DUSER_AGENT_GTK_MINOR_VERSION=1)
200 add_definitions(-DWEBKITGTK_API_VERSION_STRING="${WEBKITGTK_API_VERSION}")
201
202 if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
203     set(GSTREAMER_COMPONENTS app pbutils)
204     add_definitions(-DWTF_USE_GSTREAMER)
205     if (ENABLE_VIDEO)
206         list(APPEND GSTREAMER_COMPONENTS video mpegts tag)
207     endif ()
208
209     if (ENABLE_WEB_AUDIO)
210         list(APPEND GSTREAMER_COMPONENTS audio fft)
211         add_definitions(-DWTF_USE_WEBAUDIO_GSTREAMER)
212     endif ()
213
214     find_package(GStreamer 1.0.3 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
215
216     if (PC_GSTREAMER_MPEGTS_FOUND)
217         add_definitions(-DWTF_USE_GSTREAMER_MPEGTS)
218         set(USE_GSTREAMER_MPEGTS TRUE)
219     endif ()
220 endif ()
221
222 if (ENABLE_WAYLAND_TARGET)
223     set(GTK3_REQUIRED_VERSION 3.12.0)
224 else ()
225     set(GTK3_REQUIRED_VERSION 3.6.0)
226 endif ()
227
228 find_package(GTK3 ${GTK3_REQUIRED_VERSION} REQUIRED)
229 find_package(GDK3 ${GTK3_REQUIRED_VERSION} REQUIRED)
230 set(GTK_LIBRARIES ${GTK3_LIBRARIES})
231 set(GTK_INCLUDE_DIRS ${GTK3_INCLUDE_DIRS})
232 set(GDK_LIBRARIES ${GDK3_LIBRARIES})
233 set(GDK_INCLUDE_DIRS ${GDK3_INCLUDE_DIRS})
234
235 set(glib_components gio gobject gthread gmodule)
236 if (ENABLE_GAMEPAD_DEPRECATED OR ENABLE_GEOLOCATION)
237     list(APPEND glib_components gio-unix)
238 endif ()
239 find_package(GLIB 2.33.2 REQUIRED COMPONENTS ${glib_components})
240
241 if (ENABLE_GEOLOCATION)
242     if (GEOCLUE2_FOUND)
243       set(WTF_USE_GEOCLUE2 1)
244     else ()
245       set(WTF_USE_GEOCLUE2 0)
246     endif ()
247 endif ()
248
249 find_package(GTKUnixPrint)
250 if (GTK_UNIX_PRINT_FOUND)
251     set(HAVE_GTK_UNIX_PRINTING 1)
252 endif ()
253
254 if (ENABLE_CREDENTIAL_STORAGE)
255     find_package(Libsecret)
256     set(ENABLE_CREDENTIAL_STORAGE 1)
257 endif ()
258
259 # This part can be simplified once CMake 2.8.6 is required and
260 # CMakePushCheckState can be used. We need to have OPENGL_INCLUDE_DIR as part
261 # of the directories check_include_files() looks for in case OpenGL is
262 # installed into a non-standard location.
263 if (ENABLE_X11_TARGET)
264     set(REQUIRED_INCLUDES_OLD ${CMAKE_REQUIRED_INCLUDES})
265     set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OPENGL_INCLUDE_DIR})
266     set(CMAKE_REQUIRED_INCLUDES ${REQUIRED_INCLUDES_OLD})
267
268     if (GLX_FOUND)
269         set(WTF_USE_GLX 1)
270     endif ()
271 endif ()
272
273 if (EGL_FOUND)
274     set(WTF_USE_EGL 1)
275 endif ()
276
277 if (ENABLE_SPELLCHECK)
278     find_package(Enchant REQUIRED)
279 endif ()
280
281 if (OPENGL_FOUND AND (GLX_FOUND OR EGL_FOUND))
282     set(ENABLE_TEXTURE_MAPPER 1)
283     set(WTF_USE_3D_GRAPHICS 1)
284
285     add_definitions(-DWTF_USE_OPENGL=1)
286     add_definitions(-DWTF_USE_3D_GRAPHICS=1)
287     add_definitions(-DWTF_USE_TEXTURE_MAPPER=1)
288     add_definitions(-DWTF_USE_TEXTURE_MAPPER_GL=1)
289     add_definitions(-DENABLE_3D_RENDERING=1)
290
291     if (EGL_FOUND)
292         add_definitions(-DWTF_USE_EGL=1)
293     endif ()
294
295     if (GLX_FOUND)
296         add_definitions(-DWTF_USE_GLX=1)
297     endif ()
298 endif ()
299
300 if (ENABLE_INDEXED_DATABASE)
301     set(WTF_USE_LEVELDB 1)
302     add_definitions(-DWTF_USE_LEVELDB=1)
303 endif ()
304
305 if (ENABLE_GAMEPAD_DEPRECATED)
306     find_package(GUdev)
307 endif ()
308
309 if (ENABLE_FTL_JIT)
310     find_package(LLVM REQUIRED)
311     find_package(LIBCXXABI REQUIRED)
312     set(HAVE_LLVM ON)
313 endif ()
314
315 set(CPACK_SOURCE_GENERATOR TBZ2)
316
317 set(DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR ${DERIVED_SOURCES_DIR}/webkitdom)
318 set(DERIVED_SOURCES_WEBKITGTK_DIR ${DERIVED_SOURCES_DIR}/webkitgtk)
319 set(DERIVED_SOURCES_WEBKITGTK_API_DIR ${DERIVED_SOURCES_WEBKITGTK_DIR}/webkit)
320 set(DERIVED_SOURCES_GOBJECT_DOM_BINDINGS_DIR ${DERIVED_SOURCES_DIR}/webkitdom)
321 set(DERIVED_SOURCES_WEBKIT2GTK_DIR ${DERIVED_SOURCES_DIR}/webkit2gtk)
322 set(DERIVED_SOURCES_WEBKIT2GTK_API_DIR ${DERIVED_SOURCES_WEBKIT2GTK_DIR}/webkit2)
323 set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders)
324 set(FORWARDING_HEADERS_WEBKIT2GTK_DIR ${FORWARDING_HEADERS_DIR}/webkit2gtk)
325 set(FORWARDING_HEADERS_WEBKIT2GTK_EXTENSION_DIR ${FORWARDING_HEADERS_DIR}/webkit2gtk-webextension)
326
327 set(WebKit_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit/gtk/webkitgtk-${WEBKITGTK_API_VERSION}.pc)
328 set(WebKit2_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit2/webkit2gtk-${WEBKITGTK_API_VERSION}.pc)
329 set(WebKit2WebExtension_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/Source/WebKit2/webkit2gtk-web-extension-${WEBKITGTK_API_VERSION}.pc)
330
331 set(SHOULD_INSTALL_JS_SHELL ON)
332
333 # Push of rbp is needed after JSC JIT uses CStack. See http://wkbug.com/127777.
334 if (UNIX AND NOT APPLE)
335     if (CMAKE_COMPILER_IS_GNUCXX)
336         set(CMAKE_C_FLAGS_RELEASE "-fno-omit-frame-pointer -fno-tree-dce ${CMAKE_C_FLAGS_RELEASE}")
337         set(CMAKE_CXX_FLAGS_RELEASE "-fno-omit-frame-pointer -fno-tree-dce ${CMAKE_CXX_FLAGS_RELEASE}")
338     endif ()
339     if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
340         set(CMAKE_C_FLAGS_RELEASE "-fno-omit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}")
341         set(CMAKE_CXX_FLAGS_RELEASE "-fno-omit-frame-pointer ${CMAKE_CXX_FLAGS_RELEASE}")
342     endif ()
343 endif ()
344
345 # Add a typelib file to the list of all typelib dependencies. This makes it easy to
346 # expose a 'gir' target with all gobject-introspection files.
347 macro(ADD_TYPELIB typelib)
348     get_filename_component(target_name ${typelib} NAME_WE)
349     add_custom_target(${target_name}-gir ALL DEPENDS ${typelib})
350     list(APPEND GObjectIntrospectionTargets ${target_name}-gir)
351     set(GObjectIntrospectionTargets ${GObjectIntrospectionTargets} PARENT_SCOPE)
352 endmacro()
353
354 # CMake does not automatically add --whole-archive when building shared objects from
355 # a list of convenience libraries. This can lead to missing symbols in the final output.
356 # We add --whole-archive to all libraries manually to prevent the linker from trimming
357 # symbols that we actually need later.
358 macro(ADD_WHOLE_ARCHIVE_TO_LIBRARIES _list_name)
359     foreach (library IN LISTS ${_list_name})
360       list(APPEND ${_list_name}_TMP -Wl,--whole-archive ${library} -Wl,--no-whole-archive)
361     endforeach ()
362     set(${_list_name} "${${_list_name}_TMP}")
363 endmacro()
364
365 build_command(COMMAND_LINE_TO_BUILD)
366 # build_command unconditionally adds -i (ignore errors) for make, and there's
367 # no reasonable way to turn that off, so we just replace it with -k, which has
368 # the same effect, except that the return code will indicate that an error occurred.
369 # See: http://www.cmake.org/cmake/help/v3.0/command/build_command.html
370 string(REPLACE " -i" " -k" COMMAND_LINE_TO_BUILD ${COMMAND_LINE_TO_BUILD})
371 file(WRITE
372     ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/build.sh
373     "#!/bin/sh\n"
374     "${COMMAND_LINE_TO_BUILD} $@"
375 )
376 file(COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/build.sh
377   DESTINATION ${CMAKE_BINARY_DIR}
378   FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE)