blob: f545b6bfe803f8647ee6f1d4cdfce7ee9b14d550 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG_save "${CMAKE_FIND_PACKAGE_PREFER_CONFIG}")
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
qt_find_package(protobuf
MODULE_NAME global
NAMES protobuf Protobuf
VCPKG_PORT protobuf
)
if(NOT protobuf_FOUND)
# Attempt looking in MODULE mode
qt_find_package(Protobuf
MODULE_NAME global
)
endif()
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG "${CMAKE_FIND_PACKAGE_PREFER_CONFIG_save}")
# WrapProtoc::WrapProtoc could come from top-level CMakeLists.txt so avoid promoting it to GLOBAL
# here in this case.
if(TARGET WrapProtoc::WrapProtoc)
qt_internal_disable_find_package_global_promotion(WrapProtoc::WrapProtoc)
endif()
qt_find_package(WrapProtoc
PROVIDED_TARGETS WrapProtoc::WrapProtoc
MODULE_NAME global
)
qt_config_compile_test(libprotobuf
LIBRARIES
protobuf::libprotobuf
CODE
"#include <google/protobuf/descriptor.h>
int main(void)
{
google::protobuf::DescriptorPool pool;
pool.FindMessageTypeByName(\"\");
return 0;
}
")
qt_config_compile_test(libprotoc
LIBRARIES
protobuf::libprotoc
protobuf::libprotobuf
CODE
"#include <google/protobuf/compiler/plugin.h>
int main(void)
{
return ::google::protobuf::compiler::PluginMain(0, nullptr, nullptr);
}
")
qt_feature("qtprotobufgen" PRIVATE
SECTION "Utilities"
LABEL "Qt Protobuf generator"
PURPOSE "Provides support for generating Qt-based classes for use with Protocol Buffers."
CONDITION TARGET protobuf::libprotoc AND TARGET protobuf::libprotobuf AND
TARGET WrapProtoc::WrapProtoc AND TEST_libprotobuf AND TEST_libprotoc
)
qt_feature("protobuf-qtcoretypes" PUBLIC
SECTION "Qt Protobuf"
LABEL "Qt Core types support"
AUTODETECT TRUE
CONDITION TARGET WrapProtoc::WrapProtoc AND
( TARGET Qt6::qtprotobufgen OR Qt6::qtprotobufgen IN_LIST Qt6ProtobufTools_TARGETS OR
( QT_FEATURE_qtprotobufgen AND NOT CMAKE_CROSSCOMPILING ) )
)
qt_feature("protobuf-qtguitypes" PUBLIC
SECTION "Qt Protobuf"
LABEL "Qt Gui types support"
AUTODETECT TRUE
CONDITION TARGET WrapProtoc::WrapProtoc AND
( TARGET Qt6::qtprotobufgen OR Qt6::qtprotobufgen IN_LIST Qt6ProtobufTools_TARGETS OR
( QT_FEATURE_qtprotobufgen AND NOT CMAKE_CROSSCOMPILING ) )
)
qt_feature("protobuf-wellknowntypes" PUBLIC
SECTION "Qt Protobuf"
LABEL "Well-known types support"
AUTODETECT TRUE
CONDITION TARGET WrapProtoc::WrapProtoc AND
(TARGET protobuf::libprotobuf OR QT_PROTOBUF_WELL_KNOWN_TYPES_PROTO_DIR) AND
( TARGET Qt6::qtprotobufgen OR Qt6::qtprotobufgen IN_LIST Qt6ProtobufTools_TARGETS OR
( QT_FEATURE_qtprotobufgen AND NOT CMAKE_CROSSCOMPILING ) )
)
qt_feature("protobufquick" PUBLIC
SECTION "Qt Protobuf"
LABEL "QML Protobuf support"
PURPOSE "Allows using the generated Protobuf code from QML"
AUTODETECT TRUE
CONDITION TARGET Qt6::Quick
)
qt_feature("protobuf-unsafe-registry" PRIVATE
SECTION "Qt Protobuf"
LABEL "Unsafe registry"
PURPOSE "Allows lock-free registry access for custom serializers"
AUTODETECT FALSE
)
qt_configure_add_summary_section(NAME "Qt Protobuf")
qt_configure_add_summary_entry(ARGS "protobuf-qtcoretypes")
qt_configure_add_summary_entry(ARGS "protobuf-qtguitypes")
qt_configure_add_summary_entry(ARGS "protobuf-wellknowntypes")
qt_configure_add_summary_entry(ARGS "protobufquick")
qt_configure_add_summary_entry(ARGS "protobuf-unsafe-registry")
qt_configure_end_summary_section()
qt_configure_add_summary_section(NAME "Qt Protobuf tools")
qt_configure_add_summary_entry(ARGS "qtprotobufgen")
qt_configure_end_summary_section()
|