Debian Codegraph @

cmake/modules/QtJsProviderConfig.cmake

raw
1 cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)
2
3 # determines the JavaScript provider (either Qt Script or Qt Declarative)
4
5 if (TARGET_CONFIG_DONE)
6 message(FATAL_ERROR "Can not include QtJsProviderConfig module when targets are already configured.")
7 endif ()
8
9 # configure the specified JavaScript provider
10 set(JS_PROVIDER
11 "qml"
12 CACHE STRING "specifies the JavaScript provider: qml (default), script or none")
13 if (JS_PROVIDER STREQUAL "script")
14 set(JS_PROVIDER Script)
15 set(JS_DEFINITION "${META_PROJECT_VARNAME_UPPER}_USE_SCRIPT")
16 list(APPEND ADDITIONAL_QT_REPOS "script")
17 message(STATUS "Using Qt Script as JavaScript provider.")
18 elseif (JS_PROVIDER STREQUAL "qml")
19 set(JS_PROVIDER Qml)
20 set(JS_DEFINITION "${META_PROJECT_VARNAME_UPPER}_USE_JSENGINE")
21 list(APPEND ADDITIONAL_QT_REPOS "declarative")
22 message(STATUS "Using Qt QML as JavaScript provider.")
23 elseif (JS_PROVIDER STREQUAL "none")
24 set(JS_PROVIDER "")
25 set(JS_DEFINITION "${META_PROJECT_VARNAME_UPPER}_NO_JSENGINE")
26 message(STATUS "JavaScript provider has been disabled.")
27 else ()
28 message(FATAL_ERROR "The specified JavaScript provider '${JS_PROVIDER}' is unknown.")
29 endif ()
30
31 # add header files with some defines/includes to conveniently use the selected provider
32 if (JS_PROVIDER)
33 list(APPEND ADDITIONAL_QT_MODULES "${JS_PROVIDER}")
34
35 if (META_JS_SRC_DIR)
36 set(JS_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${META_JS_SRC_DIR}")
37 else ()
38 set(JS_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/gui")
39 endif ()
40
41 include(TemplateFinder)
42 find_template_file("jsdefs.h" QT_UTILITIES JS_DEFS_H_TEMPLATE_FILE)
43 configure_file(
44 "${JS_DEFS_H_TEMPLATE_FILE}" "${JS_HEADER_DIR}/jsdefs.h" # simply add this to source to ease inclusion
45 NEWLINE_STYLE UNIX # since this goes to sources ensure consistency
46 )
47 find_template_file("jsincludes.h" QT_UTILITIES JS_INCLUDES_H_TEMPLATE_FILE)
48 configure_file(
49 "${JS_INCLUDES_H_TEMPLATE_FILE}" "${JS_HEADER_DIR}/jsincludes.h" # simply add this to source to ease inclusion
50 NEWLINE_STYLE UNIX # since this goes to sources ensure consistency
51 )
52 list(APPEND WIDGETS_FILES "${JS_HEADER_DIR}/jsdefs.h" "${JS_HEADER_DIR}/jsincludes.h")
53 endif ()
54
55 list(APPEND META_PUBLIC_COMPILE_DEFINITIONS ${JS_DEFINITION})