Debian Codegraph @

cmake/modules/QtWebViewProviderConfig.cmake

raw
1 cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)
2
3 # determines the web view provider (either Qt WebKit or Qt WebEngine)
4
5 if (TARGET_CONFIG_DONE)
6 message(FATAL_ERROR "Can not include QtWebViewProviderConfig module when targets are already configured.")
7 endif ()
8
9 # include required modules
10 include(QtLinkage)
11
12 # check whether Qt WebEngine is present
13 find_package("${QT_PACKAGE_PREFIX}WebEngineWidgets" "${META_QT_VERSION}")
14 set(WEBVIEW_PROVIDER_DEFAULT "none")
15 if ("${${QT_PACKAGE_PREFIX}WebEngineWidgets_FOUND}")
16 set(WEBVIEW_PROVIDER_DEFAULT "webengine")
17 endif ()
18
19 # configure the specified web view provider
20 set(WEBVIEW_PROVIDER
21 "${WEBVIEW_PROVIDER_DEFAULT}"
22 CACHE STRING "specifies the web view provider: webengine (default), webkit or none")
23 if (WEBVIEW_PROVIDER STREQUAL "webkit")
24 set(WEBVIEW_PROVIDER WebKitWidgets)
25 set(WEBVIEW_DEFINITION "${META_PROJECT_VARNAME_UPPER}_USE_WEBKIT")
26 message(STATUS "Using Qt WebKit as web view provider.")
27 elseif (WEBVIEW_PROVIDER STREQUAL "webengine")
28 set(WEBVIEW_PROVIDER WebEngineWidgets)
29 if (META_WEBVIEW_WITH_CORE)
30 list(APPEND WEBVIEW_PROVIDER WebEngineCore)
31 endif ()
32 set(WEBVIEW_DEFINITION "${META_PROJECT_VARNAME_UPPER}_USE_WEBENGINE")
33 list(APPEND ADDITIONAL_QT_REPOS "webengine")
34 message(STATUS "Using Qt WebEngine as web view provider.")
35 elseif (WEBVIEW_PROVIDER STREQUAL "none")
36 set(WEBVIEW_PROVIDER "")
37 set(WEBVIEW_DEFINITION "${META_PROJECT_VARNAME_UPPER}_NO_WEBVIEW")
38 message(STATUS "Built-in web view has been disabled.")
39 else ()
40 message(FATAL_ERROR "The specified web view provider '${WEBVIEW_PROVIDER}' is unknown.")
41 endif ()
42
43 # add header files with some defines/includes to conveniently use the selected provider
44 if (WEBVIEW_PROVIDER)
45 list(APPEND ADDITIONAL_QT_MODULES "${WEBVIEW_PROVIDER}")
46
47 if (META_WEBVIEW_SRC_DIR)
48 set(WEBVIEW_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${META_WEBVIEW_SRC_DIR}")
49 else ()
50 set(WEBVIEW_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/gui")
51 endif ()
52
53 include(TemplateFinder)
54 find_template_file("webviewdefs.h" QT_UTILITIES WEBVIEWDEFS_H_TEMPLATE_FILE)
55 configure_file(
56 "${WEBVIEWDEFS_H_TEMPLATE_FILE}" "${WEBVIEW_HEADER_DIR}/webviewdefs.h" # simply add this to source to ease inclusion
57 NEWLINE_STYLE UNIX # since this goes to sources ensure consistency
58 )
59 find_template_file("webviewincludes.h" QT_UTILITIES WEBVIEWINCLUDES_H_TEMPLATE_FILE)
60 configure_file(
61 "${WEBVIEWINCLUDES_H_TEMPLATE_FILE}" "${WEBVIEW_HEADER_DIR}/webviewincludes.h" # simply add this to source to ease
62 # inclusion
63 NEWLINE_STYLE UNIX # since this goes to sources ensure consistency
64 )
65 list(APPEND WIDGETS_FILES "${WEBVIEW_HEADER_DIR}/webviewdefs.h" "${WEBVIEW_HEADER_DIR}/webviewincludes.h")
66 endif ()
67
68 list(APPEND META_PUBLIC_COMPILE_DEFINITIONS ${WEBVIEW_DEFINITION})