wasphin commented on code in PR #3618:
URL: https://github.com/apache/brpc/pull/3618#discussion_r4302511677


##########
src/mcpack2pb/CMakeLists.txt:
##########
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set(MCPACK2PB_SOURCES
+    ${CMAKE_CURRENT_SOURCE_DIR}/field_type.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/mcpack2pb.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/parser.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/serializer.cpp)
+
+add_library(MCPACK2PB_LIB OBJECT ${MCPACK2PB_SOURCES})
+target_link_libraries(MCPACK2PB_LIB PRIVATE butil_build_config)
+set_property(TARGET MCPACK2PB_LIB PROPERTY POSITION_INDEPENDENT_CODE 1)
+
+if(TARGET protobuf::libprotoc)
+    set(PROTOC_LIB protobuf::libprotoc)
+else()
+    find_library(PROTOC_LIB NAMES protoc)
+endif()
+if(NOT PROTOC_LIB)
+    message(FATAL_ERROR "Fail to find protoc lib")
+endif()
+
+# Legacy bundles/tests retain protoc linkage; the runtime component does not.
+set_property(TARGET MCPACK2PB_LIB PROPERTY BRPC_BUNDLE_LIBRARIES 
"${PROTOC_LIB}")
+set_property(TARGET MCPACK2PB_LIB PROPERTY BRPC_PRIVATE_LIBS "-lprotoc")
+
+add_executable(protoc-gen-mcpack generator.cpp)
+set_target_properties(protoc-gen-mcpack PROPERTIES
+    RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/bin)
+target_link_libraries(protoc-gen-mcpack PRIVATE butil_build_config)
+if(BUILD_SHARED_LIBS)
+    target_link_libraries(protoc-gen-mcpack PRIVATE brpc-shared 
brpc_bundle_dependencies)
+else()
+    target_link_libraries(protoc-gen-mcpack PRIVATE brpc-static 
brpc_bundle_dependencies)

Review Comment:
   `protoc-gen-mcpack` already exists when this call executes. The bundle names 
are link items, which CMake resolves during generation after processing the 
parent directory. Both static and shared bundle/generator builds pass, 
including after the latest rebase. No change is needed here.



##########
example/cmake/BrpcExample.cmake:
##########
@@ -29,7 +29,7 @@ endfunction()
 
 macro(brpc_example_find_common_deps out_libs)
     execute_process(
-        COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex 
\".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"
+        COMMAND bash -c "find ${CMAKE_CURRENT_SOURCE_DIR}/../.. -type d -regex 
\".*output/include$\" | head -n1 | xargs dirname | tr -d '\n'"

Review Comment:
   Fixed in 22edf80c. Removed the staging-directory search and now honor the 
caller’s CMAKE_PREFIX_PATH. Updated both getting-started guides with the 
install-before-use workflow and verified the echo example builds against the 
specified prefix.



##########
example/ubring_performance/CMakeLists.txt:
##########
@@ -21,7 +21,7 @@ project(ubring_performance C CXX)
 option(LINK_SO "Whether examples are linked dynamically" OFF)
 
 execute_process(
-    COMMAND bash -c "find ${PROJECT_SOURCE_DIR}/../.. -type d -regex 
'.*output/include$' | head -n1 | xargs dirname | tr -d '\n'"
+    COMMAND bash -c "find ${CMAKE_CURRENT_SOURCE_DIR}/../.. -type d -regex 
'.*output/include$' | head -n1 | xargs dirname | tr -d '\n'"

Review Comment:
   Fixed in 22edf80c. Removed the staging-directory search and stopped 
overwriting CMAKE_PREFIX_PATH. Verified both client and server build against 
the explicitly supplied installation prefix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to