xref: /aosp_15_r20/external/pigweed/pw_protobuf_compiler/CMakeLists.txt (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2021 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
16include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake)
17
18pw_proto_library(pw_protobuf_compiler.pwpb_test_protos
19  SOURCES
20    pwpb_test_protos/pwpb_test.proto
21  INPUTS
22    pwpb_test_protos/pwpb_test.pwpb_options
23  PREFIX
24    "pw_protobuf_compiler/"
25  DEPS
26    pw_protobuf.field_options_proto
27)
28
29pw_add_test(pw_protobuf_compiler.pwpb_test
30  SOURCES
31    pwpb_test.cc
32  PRIVATE_DEPS
33    pw_protobuf_compiler.pwpb_test_protos.pwpb
34  GROUPS
35    pw_protobuf_compiler
36)
37
38pw_proto_library(pw_protobuf_compiler.pwpb_test_no_prefix_protos
39  SOURCES
40    pwpb_no_prefix_test_protos/pwpb_test_no_prefix.proto
41  STRIP_PREFIX
42    "pwpb_no_prefix_test_protos/"
43  DEPS
44    pw_protobuf.field_options_proto
45)
46
47pw_add_test(pw_protobuf_compiler.pwpb_no_prefix_test
48  SOURCES
49    pwpb_test_no_prefix.cc
50  PRIVATE_DEPS
51    pw_protobuf_compiler.pwpb_test_no_prefix_protos.pwpb
52  GROUPS
53    pw_protobuf_compiler
54)
55
56if(NOT "${dir_pw_third_party_nanopb}" STREQUAL "")
57  pw_proto_library(pw_protobuf_compiler.nanopb_test_protos
58    SOURCES
59      nanopb_test_protos/nanopb_test.proto
60    PREFIX
61      "pw_protobuf_compiler/"
62    DEPS
63      pw_third_party.nanopb.proto
64  )
65
66  pw_add_test(pw_protobuf_compiler.nanopb_test
67    SOURCES
68      nanopb_test.cc
69    PRIVATE_DEPS
70      pw_protobuf_compiler.nanopb_test_protos.nanopb
71    GROUPS
72      pw_protobuf_compiler
73  )
74endif()
75