From 46292366f79d6131fd2b36f2860e22994ecdccd4 Mon Sep 17 00:00:00 2001 From: Laramie Leavitt Date: Sun, 15 Sep 2024 14:18:02 -0700 Subject: [PATCH] bazel_to_cmake: Identify bazel proto constructs which are not well handled. This changes the bazel_to_cmake test to include a BAZEL configuration variant which is not well handled by bazel_to_cmake without yet fixing the translation. Related to: https://github.com/google/tensorstore/issues/197 PiperOrigin-RevId: 674930925 Change-Id: I3498b8d81c8b8634169cd0db7e16076769634812 --- tools/cmake/BUILD | 46 ++- .../bzl_library/grpc_generate_cc.py | 1 + .../testdata/rules_proto/BUILD.bazel | 14 +- .../testdata/rules_proto/a.proto | 3 +- .../testdata/rules_proto/b.proto | 3 +- .../testdata/rules_proto/c.proto | 3 +- .../testdata/rules_proto/config.json | 10 +- .../rules_proto/golden/build_rules.cmake | 318 ++++++++++++------ .../testdata/rules_proto/src/subdir/y.proto | 2 + .../testdata/rules_proto/x.proto | 3 +- .../testdata/upb_proto_library/BUILD.bazel | 58 ++-- .../testdata/upb_proto_library/a.cc | 1 - .../testdata/upb_proto_library/a.proto | 1 + .../testdata/upb_proto_library/b.proto | 1 + .../testdata/upb_proto_library/config.json | 10 +- .../testdata/upb_proto_library/d.proto | 1 - .../golden/build_rules.cmake | 299 +++++----------- .../testdata/upb_proto_library/x.cc | 1 + 18 files changed, 412 insertions(+), 363 deletions(-) create mode 100644 tools/cmake/bazel_to_cmake/testdata/rules_proto/src/subdir/y.proto delete mode 100644 tools/cmake/bazel_to_cmake/testdata/upb_proto_library/a.cc create mode 100644 tools/cmake/bazel_to_cmake/testdata/upb_proto_library/a.proto create mode 100644 tools/cmake/bazel_to_cmake/testdata/upb_proto_library/b.proto delete mode 100644 tools/cmake/bazel_to_cmake/testdata/upb_proto_library/d.proto create mode 100644 tools/cmake/bazel_to_cmake/testdata/upb_proto_library/x.cc diff --git a/tools/cmake/BUILD b/tools/cmake/BUILD index 35427fa11..ce22a12e7 100644 --- a/tools/cmake/BUILD +++ b/tools/cmake/BUILD @@ -132,6 +132,7 @@ TESTDATA = [ "bazel_to_cmake/testdata/rules_proto/golden/build_rules.cmake", "bazel_to_cmake/testdata/rules_proto/WORKSPACE.bazel", "bazel_to_cmake/testdata/rules_proto/x.proto", + "bazel_to_cmake/testdata/rules_proto/src/subdir/y.proto", "bazel_to_cmake/testdata/third_party_http_archive/a.cc", "bazel_to_cmake/testdata/third_party_http_archive/BUILD.bazel", "bazel_to_cmake/testdata/third_party_http_archive/config.json", @@ -142,11 +143,12 @@ TESTDATA = [ "bazel_to_cmake/testdata/third_party_http_archive/golden/build_rules.cmake", "bazel_to_cmake/testdata/third_party_http_archive/half.BUILD.bazel", "bazel_to_cmake/testdata/third_party_http_archive/WORKSPACE.bazel", - "bazel_to_cmake/testdata/upb_proto_library/a.cc", + "bazel_to_cmake/testdata/upb_proto_library/x.cc", "bazel_to_cmake/testdata/upb_proto_library/BUILD.bazel", + "bazel_to_cmake/testdata/upb_proto_library/a.proto", + "bazel_to_cmake/testdata/upb_proto_library/b.proto", "bazel_to_cmake/testdata/upb_proto_library/c.proto", "bazel_to_cmake/testdata/upb_proto_library/config.json", - "bazel_to_cmake/testdata/upb_proto_library/d.proto", "bazel_to_cmake/testdata/upb_proto_library/golden/build_rules.cmake", "bazel_to_cmake/testdata/upb_proto_library/WORKSPACE.bazel", ] @@ -161,3 +163,43 @@ tensorstore_pytest_test( "skip-windows", # path canonicalization isn't correct when testing on windows. ], ) + +cc_library( + name = "bazel_to_cmake/testdata/upb_proto_library/x", + srcs = ["bazel_to_cmake/testdata/upb_proto_library/x.cc"], +) + +proto_library( + name = "bazel_to_cmake/testdata/rules_proto/a_proto", + srcs = ["bazel_to_cmake/testdata/rules_proto/a.proto"], +) + +proto_library( + name = "bazel_to_cmake/testdata/rules_proto/c_proto", + srcs = ["bazel_to_cmake/testdata/rules_proto/c.proto"], +) + +proto_library( + name = "bazel_to_cmake/testdata/rules_proto/b_proto", + srcs = ["bazel_to_cmake/testdata/rules_proto/b.proto"], +) + +proto_library( + name = "bazel_to_cmake/testdata/upb_proto_library/a_proto", + srcs = ["bazel_to_cmake/testdata/upb_proto_library/a.proto"], +) + +proto_library( + name = "bazel_to_cmake/testdata/rules_proto/x_proto", + srcs = ["bazel_to_cmake/testdata/rules_proto/x.proto"], +) + +proto_library( + name = "bazel_to_cmake/testdata/rules_proto/src/subdir/y_proto", + srcs = ["bazel_to_cmake/testdata/rules_proto/src/subdir/y.proto"], +) + +proto_library( + name = "bazel_to_cmake/testdata/upb_proto_library/b_proto", + srcs = ["bazel_to_cmake/testdata/upb_proto_library/b.proto"], +) diff --git a/tools/cmake/bazel_to_cmake/bzl_library/grpc_generate_cc.py b/tools/cmake/bazel_to_cmake/bzl_library/grpc_generate_cc.py index c45f59ee7..7d45abfab 100644 --- a/tools/cmake/bazel_to_cmake/bzl_library/grpc_generate_cc.py +++ b/tools/cmake/bazel_to_cmake/bzl_library/grpc_generate_cc.py @@ -35,6 +35,7 @@ from ..starlark.provider import TargetInfo from ..starlark.select import Configurable +from .upb_proto_library import UPB_REPO # pylint: disable=unused-import GRPC_REPO = RepositoryId("com_github_grpc_grpc") diff --git a/tools/cmake/bazel_to_cmake/testdata/rules_proto/BUILD.bazel b/tools/cmake/bazel_to_cmake/testdata/rules_proto/BUILD.bazel index 3760ee933..76f81275b 100644 --- a/tools/cmake/bazel_to_cmake/testdata/rules_proto/BUILD.bazel +++ b/tools/cmake/bazel_to_cmake/testdata/rules_proto/BUILD.bazel @@ -14,9 +14,9 @@ proto_library( proto_library( name = "ab_proto", - deps = [ - "a_proto", - ":b_proto", + srcs = [ + "a.proto", + "b.proto", ], ) @@ -24,7 +24,7 @@ proto_library( name = "abc_proto", srcs = ["c.proto"], deps = [ - "ab_proto", + ":ab_proto", ], ) @@ -48,3 +48,9 @@ cc_proto_library( name = "x_proto_cc", deps = [":x_proto"], ) + +proto_library( + name = "y_proto", + srcs = ["src/subdir/y.proto"], + strip_import_prefix = "src", +) diff --git a/tools/cmake/bazel_to_cmake/testdata/rules_proto/a.proto b/tools/cmake/bazel_to_cmake/testdata/rules_proto/a.proto index 11a6a9c25..019b7e376 100644 --- a/tools/cmake/bazel_to_cmake/testdata/rules_proto/a.proto +++ b/tools/cmake/bazel_to_cmake/testdata/rules_proto/a.proto @@ -1 +1,2 @@ -// a.proto \ No newline at end of file +// a.proto +syntax = "proto2"; diff --git a/tools/cmake/bazel_to_cmake/testdata/rules_proto/b.proto b/tools/cmake/bazel_to_cmake/testdata/rules_proto/b.proto index 27c6e6e63..3379a6493 100644 --- a/tools/cmake/bazel_to_cmake/testdata/rules_proto/b.proto +++ b/tools/cmake/bazel_to_cmake/testdata/rules_proto/b.proto @@ -1 +1,2 @@ -// b.proto \ No newline at end of file +// b.proto +syntax = "proto2"; diff --git a/tools/cmake/bazel_to_cmake/testdata/rules_proto/c.proto b/tools/cmake/bazel_to_cmake/testdata/rules_proto/c.proto index f063ca09a..4e9f903b7 100644 --- a/tools/cmake/bazel_to_cmake/testdata/rules_proto/c.proto +++ b/tools/cmake/bazel_to_cmake/testdata/rules_proto/c.proto @@ -1 +1,2 @@ -// c.proto \ No newline at end of file +// c.proto +syntax = "proto2"; diff --git a/tools/cmake/bazel_to_cmake/testdata/rules_proto/config.json b/tools/cmake/bazel_to_cmake/testdata/rules_proto/config.json index cbd58ab09..85053118a 100644 --- a/tools/cmake/bazel_to_cmake/testdata/rules_proto/config.json +++ b/tools/cmake/bazel_to_cmake/testdata/rules_proto/config.json @@ -11,26 +11,22 @@ "//:a_proto__upbdefs_library", "//:ab_proto", "//:ab_proto__cpp_library", - "//:ab_proto__minitable_library", "//:ab_proto__upb_library", "//:ab_proto__upbdefs_library", "//:ab_protos_cc", "//:abc_proto", "//:abc_proto__cpp_library", - "//:abc_proto__minitable_library", "//:abc_proto__upb_library", "//:abc_proto__upbdefs_library", "//:abc_protos_cc", "//:b_proto", "//:b_proto__cpp_library", - "//:b_proto__minitable_library", "//:b_proto__upb_library", "//:b_proto__upbdefs_library", - "//:x_proto", - "//:x_proto__cpp_library", - "//:x_proto__minitable_library", "//:x_proto__upb_library", "//:x_proto__upbdefs_library", - "//:x_proto_cc" + "//:x_proto_cc", + "//:y_proto__cpp_library", + "//:y_proto__upb_library" ] } diff --git a/tools/cmake/bazel_to_cmake/testdata/rules_proto/golden/build_rules.cmake b/tools/cmake/bazel_to_cmake/testdata/rules_proto/golden/build_rules.cmake index 96462c6e0..8b78fde95 100644 --- a/tools/cmake/bazel_to_cmake/testdata/rules_proto/golden/build_rules.cmake +++ b/tools/cmake/bazel_to_cmake/testdata/rules_proto/golden/build_rules.cmake @@ -86,138 +86,93 @@ btc_protobuf( DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upbdefs" ) -# proto_library(@rules_proto_test_repo//:b_proto) -add_library(CMakeProject_b_proto INTERFACE) -target_sources(CMakeProject_b_proto INTERFACE - "${PROJECT_SOURCE_DIR}/b.proto") -target_include_directories(CMakeProject_b_proto INTERFACE - "${PROJECT_SOURCE_DIR}") -add_library(CMakeProject::b_proto ALIAS CMakeProject_b_proto) - # proto_library(@rules_proto_test_repo//:ab_proto) add_library(CMakeProject_ab_proto INTERFACE) -target_link_libraries(CMakeProject_ab_proto INTERFACE - "CMakeProject::a_proto" - "CMakeProject::b_proto") +target_sources(CMakeProject_ab_proto INTERFACE + "${PROJECT_SOURCE_DIR}/a.proto" + "${PROJECT_SOURCE_DIR}/b.proto") +target_include_directories(CMakeProject_ab_proto INTERFACE + "${PROJECT_SOURCE_DIR}") add_library(CMakeProject::ab_proto ALIAS CMakeProject_ab_proto) -# @rules_proto_test_repo//:b_proto__cpp_library -add_library(CMakeProject_b_proto__cpp_library) -set_property(TARGET CMakeProject_b_proto__cpp_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_b_proto__cpp_library PUBLIC +# @rules_proto_test_repo//:ab_proto__cpp_library +add_library(CMakeProject_ab_proto__cpp_library) +set_property(TARGET CMakeProject_ab_proto__cpp_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_ab_proto__cpp_library PUBLIC "protobuf::libprotobuf") -target_compile_features(CMakeProject_b_proto__cpp_library PUBLIC cxx_std_17) -add_library(CMakeProject::b_proto__cpp_library ALIAS CMakeProject_b_proto__cpp_library) +target_compile_features(CMakeProject_ab_proto__cpp_library PUBLIC cxx_std_17) +add_library(CMakeProject::ab_proto__cpp_library ALIAS CMakeProject_ab_proto__cpp_library) btc_protobuf( - TARGET CMakeProject_b_proto__cpp_library - PROTO_TARGET CMakeProject_b_proto + TARGET CMakeProject_ab_proto__cpp_library + PROTO_TARGET CMakeProject_ab_proto LANGUAGE cpp GENERATE_EXTENSIONS ".pb.h" ".pb.cc" PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/0cdcec13 + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/3ec71571 DEPENDENCIES "protobuf::protoc" ) -# @rules_proto_test_repo//:ab_proto__cpp_library -add_library(CMakeProject_ab_proto__cpp_library INTERFACE) -target_link_libraries(CMakeProject_ab_proto__cpp_library INTERFACE - "CMakeProject_a_proto__cpp_library" - "CMakeProject_b_proto__cpp_library" - "protobuf::libprotobuf") -target_compile_features(CMakeProject_ab_proto__cpp_library INTERFACE cxx_std_17) -add_library(CMakeProject::ab_proto__cpp_library ALIAS CMakeProject_ab_proto__cpp_library) - -# @rules_proto_test_repo//:b_proto__minitable_library -add_library(CMakeProject_b_proto__minitable_library) -set_property(TARGET CMakeProject_b_proto__minitable_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_b_proto__minitable_library PUBLIC +# @rules_proto_test_repo//:ab_proto__minitable_library +add_library(CMakeProject_ab_proto__minitable_library) +set_property(TARGET CMakeProject_ab_proto__minitable_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_ab_proto__minitable_library PUBLIC "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") -target_compile_features(CMakeProject_b_proto__minitable_library PUBLIC cxx_std_17) -add_library(CMakeProject::b_proto__minitable_library ALIAS CMakeProject_b_proto__minitable_library) +target_compile_features(CMakeProject_ab_proto__minitable_library PUBLIC cxx_std_17) +add_library(CMakeProject::ab_proto__minitable_library ALIAS CMakeProject_ab_proto__minitable_library) btc_protobuf( - TARGET CMakeProject_b_proto__minitable_library - PROTO_TARGET CMakeProject_b_proto + TARGET CMakeProject_ab_proto__minitable_library + PROTO_TARGET CMakeProject_ab_proto LANGUAGE upb_minitable GENERATE_EXTENSIONS ".upb_minitable.h" ".upb_minitable.c" PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/0cdcec13 + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/3ec71571 PLUGIN protoc-gen-upb_minitable=$ DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upb_minitable_stage1" ) -# @rules_proto_test_repo//:ab_proto__minitable_library -add_library(CMakeProject_ab_proto__minitable_library INTERFACE) -target_link_libraries(CMakeProject_ab_proto__minitable_library INTERFACE - "CMakeProject_a_proto__minitable_library" - "CMakeProject_b_proto__minitable_library" - "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") -target_compile_features(CMakeProject_ab_proto__minitable_library INTERFACE cxx_std_17) -add_library(CMakeProject::ab_proto__minitable_library ALIAS CMakeProject_ab_proto__minitable_library) - -# @rules_proto_test_repo//:b_proto__upb_library -add_library(CMakeProject_b_proto__upb_library) -set_property(TARGET CMakeProject_b_proto__upb_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_b_proto__upb_library PUBLIC - "CMakeProject::b_proto__minitable_library" +# @rules_proto_test_repo//:ab_proto__upb_library +add_library(CMakeProject_ab_proto__upb_library) +set_property(TARGET CMakeProject_ab_proto__upb_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_ab_proto__upb_library PUBLIC + "CMakeProject::ab_proto__minitable_library" "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") -target_compile_features(CMakeProject_b_proto__upb_library PUBLIC cxx_std_17) -add_library(CMakeProject::b_proto__upb_library ALIAS CMakeProject_b_proto__upb_library) +target_compile_features(CMakeProject_ab_proto__upb_library PUBLIC cxx_std_17) +add_library(CMakeProject::ab_proto__upb_library ALIAS CMakeProject_ab_proto__upb_library) btc_protobuf( - TARGET CMakeProject_b_proto__upb_library - PROTO_TARGET CMakeProject_b_proto + TARGET CMakeProject_ab_proto__upb_library + PROTO_TARGET CMakeProject_ab_proto LANGUAGE upb GENERATE_EXTENSIONS ".upb.h" ".upb.c" PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/0cdcec13 + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/3ec71571 PLUGIN protoc-gen-upb=$ DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upb" ) -# @rules_proto_test_repo//:ab_proto__upb_library -add_library(CMakeProject_ab_proto__upb_library INTERFACE) -target_link_libraries(CMakeProject_ab_proto__upb_library INTERFACE +# @rules_proto_test_repo//:ab_proto__upbdefs_library +add_library(CMakeProject_ab_proto__upbdefs_library) +set_property(TARGET CMakeProject_ab_proto__upbdefs_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_ab_proto__upbdefs_library PUBLIC "CMakeProject::ab_proto__minitable_library" - "CMakeProject_a_proto__upb_library" - "CMakeProject_b_proto__upb_library" - "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") -target_compile_features(CMakeProject_ab_proto__upb_library INTERFACE cxx_std_17) -add_library(CMakeProject::ab_proto__upb_library ALIAS CMakeProject_ab_proto__upb_library) - -# @rules_proto_test_repo//:b_proto__upbdefs_library -add_library(CMakeProject_b_proto__upbdefs_library) -set_property(TARGET CMakeProject_b_proto__upbdefs_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_b_proto__upbdefs_library PUBLIC - "CMakeProject::b_proto__minitable_library" "Protobuf::upb_generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me" "Protobuf::upb_port") -target_compile_features(CMakeProject_b_proto__upbdefs_library PUBLIC cxx_std_17) -add_library(CMakeProject::b_proto__upbdefs_library ALIAS CMakeProject_b_proto__upbdefs_library) +target_compile_features(CMakeProject_ab_proto__upbdefs_library PUBLIC cxx_std_17) +add_library(CMakeProject::ab_proto__upbdefs_library ALIAS CMakeProject_ab_proto__upbdefs_library) btc_protobuf( - TARGET CMakeProject_b_proto__upbdefs_library - PROTO_TARGET CMakeProject_b_proto + TARGET CMakeProject_ab_proto__upbdefs_library + PROTO_TARGET CMakeProject_ab_proto LANGUAGE upbdefs GENERATE_EXTENSIONS ".upbdefs.h" ".upbdefs.c" PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/0cdcec13 + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/3ec71571 PLUGIN protoc-gen-upbdefs=$ DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upbdefs" ) -# @rules_proto_test_repo//:ab_proto__upbdefs_library -add_library(CMakeProject_ab_proto__upbdefs_library INTERFACE) -target_link_libraries(CMakeProject_ab_proto__upbdefs_library INTERFACE - "CMakeProject::ab_proto__minitable_library" - "CMakeProject_a_proto__upbdefs_library" - "CMakeProject_b_proto__upbdefs_library" - "Protobuf::upb_generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me" - "Protobuf::upb_port") -target_compile_features(CMakeProject_ab_proto__upbdefs_library INTERFACE cxx_std_17) -add_library(CMakeProject::ab_proto__upbdefs_library ALIAS CMakeProject_ab_proto__upbdefs_library) - # cc_proto_library(@rules_proto_test_repo//:ab_protos_cc) add_library(CMakeProject_ab_protos_cc INTERFACE) target_link_libraries(CMakeProject_ab_protos_cc INTERFACE @@ -324,36 +279,103 @@ target_link_libraries(CMakeProject_abc_protos_cc INTERFACE target_compile_features(CMakeProject_abc_protos_cc INTERFACE cxx_std_17) add_library(CMakeProject::abc_protos_cc ALIAS CMakeProject_abc_protos_cc) -# proto_library(@rules_proto_test_repo//:x_proto) -add_library(CMakeProject_x_proto INTERFACE) -target_sources(CMakeProject_x_proto INTERFACE - "${PROJECT_SOURCE_DIR}/x.proto") -target_link_libraries(CMakeProject_x_proto INTERFACE - "Protobuf_any_proto") -target_include_directories(CMakeProject_x_proto INTERFACE - ${Protobuf_IMPORT_DIRS} +# proto_library(@rules_proto_test_repo//:b_proto) +add_library(CMakeProject_b_proto INTERFACE) +target_sources(CMakeProject_b_proto INTERFACE + "${PROJECT_SOURCE_DIR}/b.proto") +target_include_directories(CMakeProject_b_proto INTERFACE "${PROJECT_SOURCE_DIR}") -add_library(CMakeProject::x_proto ALIAS CMakeProject_x_proto) +add_library(CMakeProject::b_proto ALIAS CMakeProject_b_proto) -# @rules_proto_test_repo//:x_proto__cpp_library -add_library(CMakeProject_x_proto__cpp_library) -set_property(TARGET CMakeProject_x_proto__cpp_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_x_proto__cpp_library PUBLIC - "Protobuf_any_proto__cpp_library" +# @rules_proto_test_repo//:b_proto__cpp_library +add_library(CMakeProject_b_proto__cpp_library) +set_property(TARGET CMakeProject_b_proto__cpp_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_b_proto__cpp_library PUBLIC "protobuf::libprotobuf") -target_compile_features(CMakeProject_x_proto__cpp_library PUBLIC cxx_std_17) -add_library(CMakeProject::x_proto__cpp_library ALIAS CMakeProject_x_proto__cpp_library) +target_compile_features(CMakeProject_b_proto__cpp_library PUBLIC cxx_std_17) +add_library(CMakeProject::b_proto__cpp_library ALIAS CMakeProject_b_proto__cpp_library) btc_protobuf( - TARGET CMakeProject_x_proto__cpp_library - PROTO_TARGET CMakeProject_x_proto + TARGET CMakeProject_b_proto__cpp_library + PROTO_TARGET CMakeProject_b_proto LANGUAGE cpp GENERATE_EXTENSIONS ".pb.h" ".pb.cc" PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/db1b3834 + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/0cdcec13 DEPENDENCIES "protobuf::protoc" ) +# @rules_proto_test_repo//:b_proto__minitable_library +add_library(CMakeProject_b_proto__minitable_library) +set_property(TARGET CMakeProject_b_proto__minitable_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_b_proto__minitable_library PUBLIC + "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") +target_compile_features(CMakeProject_b_proto__minitable_library PUBLIC cxx_std_17) +add_library(CMakeProject::b_proto__minitable_library ALIAS CMakeProject_b_proto__minitable_library) + +btc_protobuf( + TARGET CMakeProject_b_proto__minitable_library + PROTO_TARGET CMakeProject_b_proto + LANGUAGE upb_minitable + GENERATE_EXTENSIONS ".upb_minitable.h" ".upb_minitable.c" + PROTOC_OPTIONS --experimental_allow_proto3_optional + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/0cdcec13 + PLUGIN protoc-gen-upb_minitable=$ + DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upb_minitable_stage1" +) + +# @rules_proto_test_repo//:b_proto__upb_library +add_library(CMakeProject_b_proto__upb_library) +set_property(TARGET CMakeProject_b_proto__upb_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_b_proto__upb_library PUBLIC + "CMakeProject::b_proto__minitable_library" + "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") +target_compile_features(CMakeProject_b_proto__upb_library PUBLIC cxx_std_17) +add_library(CMakeProject::b_proto__upb_library ALIAS CMakeProject_b_proto__upb_library) + +btc_protobuf( + TARGET CMakeProject_b_proto__upb_library + PROTO_TARGET CMakeProject_b_proto + LANGUAGE upb + GENERATE_EXTENSIONS ".upb.h" ".upb.c" + PROTOC_OPTIONS --experimental_allow_proto3_optional + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/0cdcec13 + PLUGIN protoc-gen-upb=$ + DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upb" +) + +# @rules_proto_test_repo//:b_proto__upbdefs_library +add_library(CMakeProject_b_proto__upbdefs_library) +set_property(TARGET CMakeProject_b_proto__upbdefs_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_b_proto__upbdefs_library PUBLIC + "CMakeProject::b_proto__minitable_library" + "Protobuf::upb_generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me" + "Protobuf::upb_port") +target_compile_features(CMakeProject_b_proto__upbdefs_library PUBLIC cxx_std_17) +add_library(CMakeProject::b_proto__upbdefs_library ALIAS CMakeProject_b_proto__upbdefs_library) + +btc_protobuf( + TARGET CMakeProject_b_proto__upbdefs_library + PROTO_TARGET CMakeProject_b_proto + LANGUAGE upbdefs + GENERATE_EXTENSIONS ".upbdefs.h" ".upbdefs.c" + PROTOC_OPTIONS --experimental_allow_proto3_optional + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/0cdcec13 + PLUGIN protoc-gen-upbdefs=$ + DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upbdefs" +) + +# proto_library(@rules_proto_test_repo//:x_proto) +add_library(CMakeProject_x_proto INTERFACE) +target_sources(CMakeProject_x_proto INTERFACE + "${PROJECT_SOURCE_DIR}/x.proto") +target_link_libraries(CMakeProject_x_proto INTERFACE + "Protobuf_any_proto") +target_include_directories(CMakeProject_x_proto INTERFACE + ${Protobuf_IMPORT_DIRS} + "${PROJECT_SOURCE_DIR}") +add_library(CMakeProject::x_proto ALIAS CMakeProject_x_proto) + # @rules_proto_test_repo//:x_proto__minitable_library add_library(CMakeProject_x_proto__minitable_library) set_property(TARGET CMakeProject_x_proto__minitable_library PROPERTY LINKER_LANGUAGE "CXX") @@ -417,9 +439,93 @@ btc_protobuf( DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upbdefs" ) +# @rules_proto_test_repo//:x_proto__cpp_library +add_library(CMakeProject_x_proto__cpp_library) +set_property(TARGET CMakeProject_x_proto__cpp_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_x_proto__cpp_library PUBLIC + "Protobuf_any_proto__cpp_library" + "protobuf::libprotobuf") +target_compile_features(CMakeProject_x_proto__cpp_library PUBLIC cxx_std_17) +add_library(CMakeProject::x_proto__cpp_library ALIAS CMakeProject_x_proto__cpp_library) + +btc_protobuf( + TARGET CMakeProject_x_proto__cpp_library + PROTO_TARGET CMakeProject_x_proto + LANGUAGE cpp + GENERATE_EXTENSIONS ".pb.h" ".pb.cc" + PROTOC_OPTIONS --experimental_allow_proto3_optional + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/db1b3834 + DEPENDENCIES "protobuf::protoc" +) + # cc_proto_library(@rules_proto_test_repo//:x_proto_cc) add_library(CMakeProject_x_proto_cc INTERFACE) target_link_libraries(CMakeProject_x_proto_cc INTERFACE "CMakeProject::x_proto__cpp_library") target_compile_features(CMakeProject_x_proto_cc INTERFACE cxx_std_17) add_library(CMakeProject::x_proto_cc ALIAS CMakeProject_x_proto_cc) + +# proto_library(@rules_proto_test_repo//:y_proto) +add_library(CMakeProject_y_proto INTERFACE) +target_sources(CMakeProject_y_proto INTERFACE + "${PROJECT_SOURCE_DIR}/src/subdir/y.proto") +target_include_directories(CMakeProject_y_proto INTERFACE + "${PROJECT_SOURCE_DIR}/src") +add_library(CMakeProject::y_proto ALIAS CMakeProject_y_proto) + +# @rules_proto_test_repo//:y_proto__cpp_library +add_library(CMakeProject_y_proto__cpp_library) +set_property(TARGET CMakeProject_y_proto__cpp_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_y_proto__cpp_library PUBLIC + "protobuf::libprotobuf") +target_compile_features(CMakeProject_y_proto__cpp_library PUBLIC cxx_std_17) +add_library(CMakeProject::y_proto__cpp_library ALIAS CMakeProject_y_proto__cpp_library) + +btc_protobuf( + TARGET CMakeProject_y_proto__cpp_library + PROTO_TARGET CMakeProject_y_proto + LANGUAGE cpp + GENERATE_EXTENSIONS ".pb.h" ".pb.cc" + PROTOC_OPTIONS --experimental_allow_proto3_optional + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/573e9085/src + DEPENDENCIES "protobuf::protoc" +) + +# @rules_proto_test_repo//:y_proto__minitable_library +add_library(CMakeProject_y_proto__minitable_library) +set_property(TARGET CMakeProject_y_proto__minitable_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_y_proto__minitable_library PUBLIC + "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") +target_compile_features(CMakeProject_y_proto__minitable_library PUBLIC cxx_std_17) +add_library(CMakeProject::y_proto__minitable_library ALIAS CMakeProject_y_proto__minitable_library) + +btc_protobuf( + TARGET CMakeProject_y_proto__minitable_library + PROTO_TARGET CMakeProject_y_proto + LANGUAGE upb_minitable + GENERATE_EXTENSIONS ".upb_minitable.h" ".upb_minitable.c" + PROTOC_OPTIONS --experimental_allow_proto3_optional + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/573e9085/src + PLUGIN protoc-gen-upb_minitable=$ + DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upb_minitable_stage1" +) + +# @rules_proto_test_repo//:y_proto__upb_library +add_library(CMakeProject_y_proto__upb_library) +set_property(TARGET CMakeProject_y_proto__upb_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_y_proto__upb_library PUBLIC + "CMakeProject::y_proto__minitable_library" + "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") +target_compile_features(CMakeProject_y_proto__upb_library PUBLIC cxx_std_17) +add_library(CMakeProject::y_proto__upb_library ALIAS CMakeProject_y_proto__upb_library) + +btc_protobuf( + TARGET CMakeProject_y_proto__upb_library + PROTO_TARGET CMakeProject_y_proto + LANGUAGE upb + GENERATE_EXTENSIONS ".upb.h" ".upb.c" + PROTOC_OPTIONS --experimental_allow_proto3_optional + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/573e9085/src + PLUGIN protoc-gen-upb=$ + DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upb" +) diff --git a/tools/cmake/bazel_to_cmake/testdata/rules_proto/src/subdir/y.proto b/tools/cmake/bazel_to_cmake/testdata/rules_proto/src/subdir/y.proto new file mode 100644 index 000000000..17c616ba3 --- /dev/null +++ b/tools/cmake/bazel_to_cmake/testdata/rules_proto/src/subdir/y.proto @@ -0,0 +1,2 @@ +// y.proto +syntax = "proto2"; diff --git a/tools/cmake/bazel_to_cmake/testdata/rules_proto/x.proto b/tools/cmake/bazel_to_cmake/testdata/rules_proto/x.proto index 424c5ba6c..b04b39bb5 100644 --- a/tools/cmake/bazel_to_cmake/testdata/rules_proto/x.proto +++ b/tools/cmake/bazel_to_cmake/testdata/rules_proto/x.proto @@ -1 +1,2 @@ -// x.proto \ No newline at end of file +// x.proto +syntax = "proto2"; diff --git a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/BUILD.bazel b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/BUILD.bazel index 1f208d70a..a046a9693 100644 --- a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/BUILD.bazel +++ b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/BUILD.bazel @@ -6,54 +6,64 @@ load( package(default_visibility = ["//visibility:public"]) -cc_library( - name = "a", - srcs = ["a.cc"], - deps = [ - ":c_upb_proto", - ":c_upb_proto_reflection", - ], +proto_library( + name = "a_proto", + srcs = ["a.proto"], ) proto_library( - name = "c_proto", - srcs = ["c.proto"], + name = "b_proto", + srcs = ["b.proto"], ) proto_library( - name = "d_proto", - srcs = ["d.proto"], + name = "ab_proto", + srcs = [ + "a.proto", + "b.proto", + ], ) proto_library( - name = "abc_protos", + name = "abc_proto", + srcs = ["c.proto"], deps = [ - ":c_proto", - ":d_proto", + ":ab_proto", ], ) +cc_proto_library( + name = "a_cc_proto", + deps = [":a_proto"], +) + upb_proto_library( - name = "c_upb_proto", - deps = [":c_proto"], + name = "a_upb_proto", + deps = [":a_proto"], ) upb_proto_reflection_library( - name = "c_upb_proto_reflection", - deps = [":c_proto"], + name = "a_upb_proto_reflection", + deps = [":a_proto"], ) -cc_proto_library( - name = "abc_protos_cc", - deps = [":abc_protos"], -) +# ... upb_proto_library( - name = "abc_protos_upb", + name = "abc_upb_proto", deps = [":abc_protos"], ) upb_proto_reflection_library( - name = "abc_protos_upbdefs", + name = "abc_upb_proto_reflection", deps = [":abc_protos"], ) + +cc_library( + name = "x", + srcs = ["x.cc"], + deps = [ + ":abc_upb_proto", + ":abc_upb_proto_reflection", + ], +) diff --git a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/a.cc b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/a.cc deleted file mode 100644 index 8de632f30..000000000 --- a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/a.cc +++ /dev/null @@ -1 +0,0 @@ -// a.cc diff --git a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/a.proto b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/a.proto new file mode 100644 index 000000000..fddb20b36 --- /dev/null +++ b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/a.proto @@ -0,0 +1 @@ +syntax = "proto2"; diff --git a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/b.proto b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/b.proto new file mode 100644 index 000000000..fddb20b36 --- /dev/null +++ b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/b.proto @@ -0,0 +1 @@ +syntax = "proto2"; diff --git a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/config.json b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/config.json index e9bd73e7c..679e878be 100644 --- a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/config.json +++ b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/config.json @@ -3,11 +3,9 @@ ".bzl_library.upb_proto_library" ], "targets": [ - "//:c_upb_proto", - "//:c_upb_proto_reflection", - "//:abc_protos_cc", - "//:abc_protos_upb", - "//:abc_protos_upbdefs" + "//:a_cc_proto", + "//:a_upb_proto", + "//:a_upb_proto_reflection", + "//:x" ] } - diff --git a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/d.proto b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/d.proto deleted file mode 100644 index 8b1e624ee..000000000 --- a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/d.proto +++ /dev/null @@ -1 +0,0 @@ -// d.proto \ No newline at end of file diff --git a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/golden/build_rules.cmake b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/golden/build_rules.cmake index 7e8df8370..5cd6be8f0 100644 --- a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/golden/build_rules.cmake +++ b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/golden/build_rules.cmake @@ -1,254 +1,137 @@ find_package(Protobuf REQUIRED) -# proto_library(@upb_proto_library_test_repo//:c_proto) -add_library(CMakeProject_c_proto INTERFACE) -target_sources(CMakeProject_c_proto INTERFACE - "${PROJECT_SOURCE_DIR}/c.proto") -target_include_directories(CMakeProject_c_proto INTERFACE +# proto_library(@upb_proto_library_test_repo//:a_proto) +add_library(CMakeProject_a_proto INTERFACE) +target_sources(CMakeProject_a_proto INTERFACE + "${PROJECT_SOURCE_DIR}/a.proto") +target_include_directories(CMakeProject_a_proto INTERFACE "${PROJECT_SOURCE_DIR}") -add_library(CMakeProject::c_proto ALIAS CMakeProject_c_proto) +add_library(CMakeProject::a_proto ALIAS CMakeProject_a_proto) -# @upb_proto_library_test_repo//:c_proto__minitable_library -add_library(CMakeProject_c_proto__minitable_library) -set_property(TARGET CMakeProject_c_proto__minitable_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_c_proto__minitable_library PUBLIC - "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") -target_compile_features(CMakeProject_c_proto__minitable_library PUBLIC cxx_std_17) -add_library(CMakeProject::c_proto__minitable_library ALIAS CMakeProject_c_proto__minitable_library) - -btc_protobuf( - TARGET CMakeProject_c_proto__minitable_library - PROTO_TARGET CMakeProject_c_proto - LANGUAGE upb_minitable - GENERATE_EXTENSIONS ".upb_minitable.h" ".upb_minitable.c" - PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/52294d82 - PLUGIN protoc-gen-upb_minitable=$ - DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upb_minitable_stage1" -) - -# @upb_proto_library_test_repo//:c_proto__upb_library -add_library(CMakeProject_c_proto__upb_library) -set_property(TARGET CMakeProject_c_proto__upb_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_c_proto__upb_library PUBLIC - "CMakeProject::c_proto__minitable_library" - "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") -target_compile_features(CMakeProject_c_proto__upb_library PUBLIC cxx_std_17) -add_library(CMakeProject::c_proto__upb_library ALIAS CMakeProject_c_proto__upb_library) - -btc_protobuf( - TARGET CMakeProject_c_proto__upb_library - PROTO_TARGET CMakeProject_c_proto - LANGUAGE upb - GENERATE_EXTENSIONS ".upb.h" ".upb.c" - PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/52294d82 - PLUGIN protoc-gen-upb=$ - DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upb" -) - -# upb_c_proto_library(@upb_proto_library_test_repo//:c_upb_proto) -add_library(CMakeProject_c_upb_proto INTERFACE) -target_link_libraries(CMakeProject_c_upb_proto INTERFACE - "CMakeProject::c_proto__upb_library") -target_compile_features(CMakeProject_c_upb_proto INTERFACE cxx_std_17) -add_library(CMakeProject::c_upb_proto ALIAS CMakeProject_c_upb_proto) - -# @upb_proto_library_test_repo//:c_proto__upbdefs_library -add_library(CMakeProject_c_proto__upbdefs_library) -set_property(TARGET CMakeProject_c_proto__upbdefs_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_c_proto__upbdefs_library PUBLIC - "CMakeProject::c_proto__minitable_library" - "Protobuf::upb_generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me" - "Protobuf::upb_port") -target_compile_features(CMakeProject_c_proto__upbdefs_library PUBLIC cxx_std_17) -add_library(CMakeProject::c_proto__upbdefs_library ALIAS CMakeProject_c_proto__upbdefs_library) - -btc_protobuf( - TARGET CMakeProject_c_proto__upbdefs_library - PROTO_TARGET CMakeProject_c_proto - LANGUAGE upbdefs - GENERATE_EXTENSIONS ".upbdefs.h" ".upbdefs.c" - PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/52294d82 - PLUGIN protoc-gen-upbdefs=$ - DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upbdefs" -) - -# upb_proto_reflection_library(@upb_proto_library_test_repo//:c_upb_proto_reflection) -add_library(CMakeProject_c_upb_proto_reflection INTERFACE) -target_link_libraries(CMakeProject_c_upb_proto_reflection INTERFACE - "CMakeProject::c_proto__upbdefs_library") -target_compile_features(CMakeProject_c_upb_proto_reflection INTERFACE cxx_std_17) -add_library(CMakeProject::c_upb_proto_reflection ALIAS CMakeProject_c_upb_proto_reflection) - -# proto_library(@upb_proto_library_test_repo//:d_proto) -add_library(CMakeProject_d_proto INTERFACE) -target_sources(CMakeProject_d_proto INTERFACE - "${PROJECT_SOURCE_DIR}/d.proto") -target_include_directories(CMakeProject_d_proto INTERFACE - "${PROJECT_SOURCE_DIR}") -add_library(CMakeProject::d_proto ALIAS CMakeProject_d_proto) - -# proto_library(@upb_proto_library_test_repo//:abc_protos) -add_library(CMakeProject_abc_protos INTERFACE) -target_link_libraries(CMakeProject_abc_protos INTERFACE - "CMakeProject::c_proto" - "CMakeProject::d_proto") -add_library(CMakeProject::abc_protos ALIAS CMakeProject_abc_protos) - -# @upb_proto_library_test_repo//:c_proto__cpp_library -add_library(CMakeProject_c_proto__cpp_library) -set_property(TARGET CMakeProject_c_proto__cpp_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_c_proto__cpp_library PUBLIC +# @upb_proto_library_test_repo//:a_proto__cpp_library +add_library(CMakeProject_a_proto__cpp_library) +set_property(TARGET CMakeProject_a_proto__cpp_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_a_proto__cpp_library PUBLIC "protobuf::libprotobuf") -target_compile_features(CMakeProject_c_proto__cpp_library PUBLIC cxx_std_17) -add_library(CMakeProject::c_proto__cpp_library ALIAS CMakeProject_c_proto__cpp_library) +target_compile_features(CMakeProject_a_proto__cpp_library PUBLIC cxx_std_17) +add_library(CMakeProject::a_proto__cpp_library ALIAS CMakeProject_a_proto__cpp_library) btc_protobuf( - TARGET CMakeProject_c_proto__cpp_library - PROTO_TARGET CMakeProject_c_proto + TARGET CMakeProject_a_proto__cpp_library + PROTO_TARGET CMakeProject_a_proto LANGUAGE cpp GENERATE_EXTENSIONS ".pb.h" ".pb.cc" PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/52294d82 + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/92f46a52 DEPENDENCIES "protobuf::protoc" ) -# @upb_proto_library_test_repo//:d_proto__cpp_library -add_library(CMakeProject_d_proto__cpp_library) -set_property(TARGET CMakeProject_d_proto__cpp_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_d_proto__cpp_library PUBLIC - "protobuf::libprotobuf") -target_compile_features(CMakeProject_d_proto__cpp_library PUBLIC cxx_std_17) -add_library(CMakeProject::d_proto__cpp_library ALIAS CMakeProject_d_proto__cpp_library) - -btc_protobuf( - TARGET CMakeProject_d_proto__cpp_library - PROTO_TARGET CMakeProject_d_proto - LANGUAGE cpp - GENERATE_EXTENSIONS ".pb.h" ".pb.cc" - PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/281ec8ac - DEPENDENCIES "protobuf::protoc" -) - -# @upb_proto_library_test_repo//:abc_protos__cpp_library -add_library(CMakeProject_abc_protos__cpp_library INTERFACE) -target_link_libraries(CMakeProject_abc_protos__cpp_library INTERFACE - "CMakeProject_c_proto__cpp_library" - "CMakeProject_d_proto__cpp_library" - "protobuf::libprotobuf") -target_compile_features(CMakeProject_abc_protos__cpp_library INTERFACE cxx_std_17) -add_library(CMakeProject::abc_protos__cpp_library ALIAS CMakeProject_abc_protos__cpp_library) - -# cc_proto_library(@upb_proto_library_test_repo//:abc_protos_cc) -add_library(CMakeProject_abc_protos_cc INTERFACE) -target_link_libraries(CMakeProject_abc_protos_cc INTERFACE - "CMakeProject::abc_protos__cpp_library") -target_compile_features(CMakeProject_abc_protos_cc INTERFACE cxx_std_17) -add_library(CMakeProject::abc_protos_cc ALIAS CMakeProject_abc_protos_cc) - -# @upb_proto_library_test_repo//:d_proto__minitable_library -add_library(CMakeProject_d_proto__minitable_library) -set_property(TARGET CMakeProject_d_proto__minitable_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_d_proto__minitable_library PUBLIC +# cc_proto_library(@upb_proto_library_test_repo//:a_cc_proto) +add_library(CMakeProject_a_cc_proto INTERFACE) +target_link_libraries(CMakeProject_a_cc_proto INTERFACE + "CMakeProject::a_proto__cpp_library") +target_compile_features(CMakeProject_a_cc_proto INTERFACE cxx_std_17) +add_library(CMakeProject::a_cc_proto ALIAS CMakeProject_a_cc_proto) + +# @upb_proto_library_test_repo//:a_proto__minitable_library +add_library(CMakeProject_a_proto__minitable_library) +set_property(TARGET CMakeProject_a_proto__minitable_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_a_proto__minitable_library PUBLIC "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") -target_compile_features(CMakeProject_d_proto__minitable_library PUBLIC cxx_std_17) -add_library(CMakeProject::d_proto__minitable_library ALIAS CMakeProject_d_proto__minitable_library) +target_compile_features(CMakeProject_a_proto__minitable_library PUBLIC cxx_std_17) +add_library(CMakeProject::a_proto__minitable_library ALIAS CMakeProject_a_proto__minitable_library) btc_protobuf( - TARGET CMakeProject_d_proto__minitable_library - PROTO_TARGET CMakeProject_d_proto + TARGET CMakeProject_a_proto__minitable_library + PROTO_TARGET CMakeProject_a_proto LANGUAGE upb_minitable GENERATE_EXTENSIONS ".upb_minitable.h" ".upb_minitable.c" PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/281ec8ac + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/92f46a52 PLUGIN protoc-gen-upb_minitable=$ DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upb_minitable_stage1" ) -# @upb_proto_library_test_repo//:abc_protos__minitable_library -add_library(CMakeProject_abc_protos__minitable_library INTERFACE) -target_link_libraries(CMakeProject_abc_protos__minitable_library INTERFACE - "CMakeProject_c_proto__minitable_library" - "CMakeProject_d_proto__minitable_library" +# @upb_proto_library_test_repo//:a_proto__upb_library +add_library(CMakeProject_a_proto__upb_library) +set_property(TARGET CMakeProject_a_proto__upb_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_a_proto__upb_library PUBLIC + "CMakeProject::a_proto__minitable_library" "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") -target_compile_features(CMakeProject_abc_protos__minitable_library INTERFACE cxx_std_17) -add_library(CMakeProject::abc_protos__minitable_library ALIAS CMakeProject_abc_protos__minitable_library) - -# @upb_proto_library_test_repo//:d_proto__upb_library -add_library(CMakeProject_d_proto__upb_library) -set_property(TARGET CMakeProject_d_proto__upb_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_d_proto__upb_library PUBLIC - "CMakeProject::d_proto__minitable_library" - "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") -target_compile_features(CMakeProject_d_proto__upb_library PUBLIC cxx_std_17) -add_library(CMakeProject::d_proto__upb_library ALIAS CMakeProject_d_proto__upb_library) +target_compile_features(CMakeProject_a_proto__upb_library PUBLIC cxx_std_17) +add_library(CMakeProject::a_proto__upb_library ALIAS CMakeProject_a_proto__upb_library) btc_protobuf( - TARGET CMakeProject_d_proto__upb_library - PROTO_TARGET CMakeProject_d_proto + TARGET CMakeProject_a_proto__upb_library + PROTO_TARGET CMakeProject_a_proto LANGUAGE upb GENERATE_EXTENSIONS ".upb.h" ".upb.c" PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/281ec8ac + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/92f46a52 PLUGIN protoc-gen-upb=$ DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upb" ) -# @upb_proto_library_test_repo//:abc_protos__upb_library -add_library(CMakeProject_abc_protos__upb_library INTERFACE) -target_link_libraries(CMakeProject_abc_protos__upb_library INTERFACE - "CMakeProject::abc_protos__minitable_library" - "CMakeProject_c_proto__upb_library" - "CMakeProject_d_proto__upb_library" - "protobuf::upb_generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me") -target_compile_features(CMakeProject_abc_protos__upb_library INTERFACE cxx_std_17) -add_library(CMakeProject::abc_protos__upb_library ALIAS CMakeProject_abc_protos__upb_library) - -# upb_c_proto_library(@upb_proto_library_test_repo//:abc_protos_upb) -add_library(CMakeProject_abc_protos_upb INTERFACE) -target_link_libraries(CMakeProject_abc_protos_upb INTERFACE - "CMakeProject::abc_protos__upb_library") -target_compile_features(CMakeProject_abc_protos_upb INTERFACE cxx_std_17) -add_library(CMakeProject::abc_protos_upb ALIAS CMakeProject_abc_protos_upb) - -# @upb_proto_library_test_repo//:d_proto__upbdefs_library -add_library(CMakeProject_d_proto__upbdefs_library) -set_property(TARGET CMakeProject_d_proto__upbdefs_library PROPERTY LINKER_LANGUAGE "CXX") -target_link_libraries(CMakeProject_d_proto__upbdefs_library PUBLIC - "CMakeProject::d_proto__minitable_library" +# upb_c_proto_library(@upb_proto_library_test_repo//:a_upb_proto) +add_library(CMakeProject_a_upb_proto INTERFACE) +target_link_libraries(CMakeProject_a_upb_proto INTERFACE + "CMakeProject::a_proto__upb_library") +target_compile_features(CMakeProject_a_upb_proto INTERFACE cxx_std_17) +add_library(CMakeProject::a_upb_proto ALIAS CMakeProject_a_upb_proto) + +# @upb_proto_library_test_repo//:a_proto__upbdefs_library +add_library(CMakeProject_a_proto__upbdefs_library) +set_property(TARGET CMakeProject_a_proto__upbdefs_library PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_a_proto__upbdefs_library PUBLIC + "CMakeProject::a_proto__minitable_library" "Protobuf::upb_generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me" "Protobuf::upb_port") -target_compile_features(CMakeProject_d_proto__upbdefs_library PUBLIC cxx_std_17) -add_library(CMakeProject::d_proto__upbdefs_library ALIAS CMakeProject_d_proto__upbdefs_library) +target_compile_features(CMakeProject_a_proto__upbdefs_library PUBLIC cxx_std_17) +add_library(CMakeProject::a_proto__upbdefs_library ALIAS CMakeProject_a_proto__upbdefs_library) btc_protobuf( - TARGET CMakeProject_d_proto__upbdefs_library - PROTO_TARGET CMakeProject_d_proto + TARGET CMakeProject_a_proto__upbdefs_library + PROTO_TARGET CMakeProject_a_proto LANGUAGE upbdefs GENERATE_EXTENSIONS ".upbdefs.h" ".upbdefs.c" PROTOC_OPTIONS --experimental_allow_proto3_optional - PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/281ec8ac + PROTOC_OUT_DIR ${PROJECT_BINARY_DIR}/92f46a52 PLUGIN protoc-gen-upbdefs=$ DEPENDENCIES "protobuf::protoc" "protobuf::protoc_gen_upbdefs" ) -# @upb_proto_library_test_repo//:abc_protos__upbdefs_library -add_library(CMakeProject_abc_protos__upbdefs_library INTERFACE) -target_link_libraries(CMakeProject_abc_protos__upbdefs_library INTERFACE - "CMakeProject::abc_protos__minitable_library" - "CMakeProject_c_proto__upbdefs_library" - "CMakeProject_d_proto__upbdefs_library" - "Protobuf::upb_generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me" - "Protobuf::upb_port") -target_compile_features(CMakeProject_abc_protos__upbdefs_library INTERFACE cxx_std_17) -add_library(CMakeProject::abc_protos__upbdefs_library ALIAS CMakeProject_abc_protos__upbdefs_library) +# upb_proto_reflection_library(@upb_proto_library_test_repo//:a_upb_proto_reflection) +add_library(CMakeProject_a_upb_proto_reflection INTERFACE) +target_link_libraries(CMakeProject_a_upb_proto_reflection INTERFACE + "CMakeProject::a_proto__upbdefs_library") +target_compile_features(CMakeProject_a_upb_proto_reflection INTERFACE cxx_std_17) +add_library(CMakeProject::a_upb_proto_reflection ALIAS CMakeProject_a_upb_proto_reflection) + +# upb_c_proto_library(@upb_proto_library_test_repo//:abc_upb_proto) +add_library(CMakeProject_abc_upb_proto INTERFACE) +target_link_libraries(CMakeProject_abc_upb_proto INTERFACE + "CMakeProject::abc_protos__upb_library") +target_compile_features(CMakeProject_abc_upb_proto INTERFACE cxx_std_17) +add_library(CMakeProject::abc_upb_proto ALIAS CMakeProject_abc_upb_proto) -# upb_proto_reflection_library(@upb_proto_library_test_repo//:abc_protos_upbdefs) -add_library(CMakeProject_abc_protos_upbdefs INTERFACE) -target_link_libraries(CMakeProject_abc_protos_upbdefs INTERFACE +# upb_proto_reflection_library(@upb_proto_library_test_repo//:abc_upb_proto_reflection) +add_library(CMakeProject_abc_upb_proto_reflection INTERFACE) +target_link_libraries(CMakeProject_abc_upb_proto_reflection INTERFACE "CMakeProject::abc_protos__upbdefs_library") -target_compile_features(CMakeProject_abc_protos_upbdefs INTERFACE cxx_std_17) -add_library(CMakeProject::abc_protos_upbdefs ALIAS CMakeProject_abc_protos_upbdefs) +target_compile_features(CMakeProject_abc_upb_proto_reflection INTERFACE cxx_std_17) +add_library(CMakeProject::abc_upb_proto_reflection ALIAS CMakeProject_abc_upb_proto_reflection) + +# cc_library(@upb_proto_library_test_repo//:x) +add_library(CMakeProject_x) +set_property(TARGET CMakeProject_x PROPERTY LINKER_LANGUAGE "CXX") +target_link_libraries(CMakeProject_x PUBLIC + "CMakeProject::abc_upb_proto" + "CMakeProject::abc_upb_proto_reflection" + "Threads::Threads" + "m") +target_include_directories(CMakeProject_x PRIVATE + "$") +target_compile_features(CMakeProject_x PUBLIC cxx_std_17) +target_sources(CMakeProject_x PRIVATE + "${PROJECT_SOURCE_DIR}/x.cc") +add_library(CMakeProject::x ALIAS CMakeProject_x) diff --git a/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/x.cc b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/x.cc new file mode 100644 index 000000000..8af7ace6b --- /dev/null +++ b/tools/cmake/bazel_to_cmake/testdata/upb_proto_library/x.cc @@ -0,0 +1 @@ +// x.cc