You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by "wasphin (via GitHub)" <gi...@apache.org> on 2026/10/17 07:17:32 UTC
[PR] Refactor CMake source and target ownership into module directories (brpc)
wasphin opened a new pull request, #3618:
URL: https://github.com/apache/brpc/pull/3618
### What problem does this PR solve?
Issue Number: N/A
Problem Summary:
The root CMake project owns source lists, production object targets and
module-specific configuration for all modules. This makes module ownership
hard to follow and expands the review surface of later packaging changes.
This extracts the two prerequisite refactoring commits from #3596. Component
libraries, package exports and the subsequent dependency-resolver rewrite are
not included.
### What is changed and the side effects?
Changed:
Please prefer **Rebase and merge** to preserve the two reviewable steps:
1. Move production source selection and protocol generation into module
directories, retaining the existing bundle and test source inputs.
2. Move production object targets, feature/dependency handling and header
installation into the owning modules. Reuse the module objects in the
existing bundles and the source sets in debug unit-test targets.
Generate `butil/config.h` in the build tree, keep common options in the root,
and scope CRC32C instruction options to the affected source files, including
debug builds. Preserve the existing RISC-V vector architecture options.
Side effects:
- Performance effects: No intended runtime change. Production sources are
compiled once and reused for the existing bundle outputs.
- Breaking backward compatibility: Existing bundle names are unchanged.
CMake no longer stages headers in `output/include`; use
`cmake --install build --prefix build/output` to obtain an installation
prefix. Make and Bazel header generation remain unchanged.
---
### Check List:
- [x] Please make sure your changes are compilable.
- [x] When providing us with a new feature, it is best to add related tests.
- [x] Please follow [Contributor Covenant Code of Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
--
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: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] Refactor CMake source and target ownership into module directories (brpc)
Posted by "wasphin (via GitHub)" <gi...@apache.org>.
wasphin merged PR #3618:
URL: https://github.com/apache/brpc/pull/3618
--
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: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] Refactor CMake source and target ownership into module directories (brpc)
Posted by "wwbmmm (via GitHub)" <gi...@apache.org>.
wwbmmm commented on code in PR #3618:
URL: https://github.com/apache/brpc/pull/3618#discussion_r4305354444
##########
test/CMakeLists.txt:
##########
@@ -220,7 +237,7 @@ set_target_properties(brpc-shared-debug PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test)
target_link_libraries(brpc-shared-debug PUBLIC brpc_test_config ${DYNAMIC_LIB})
-if(BRPC_WITH_GLOG)
+if(WITH_GLOG)
target_link_libraries(brpc-shared-debug PUBLIC ${GLOG_LIB})
Review Comment:
[replied by brpc-oncall robot] `GLOG_LIB` is only defined in src/butil's directory scope now, so this branch (and the identical one for brpc-static-debug) expands to an empty link item. glog is already part of `${DYNAMIC_LIB}`, so these `if(WITH_GLOG)` blocks are dead no-ops; please remove them (or carry glog on a target the debug bundles link) rather than leaving code that looks functional but does nothing.
##########
src/butil/CMakeLists.txt:
##########
@@ -0,0 +1,290 @@
+# 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(WITH_GLOG_VAL "0")
+if(WITH_GLOG)
+ set(WITH_GLOG_VAL "1")
+ set(BRPC_WITH_GLOG 1)
+endif()
+
+set(WITH_CPU_FREQUENCY_VAL "0")
+if(WITH_CPU_FREQUENCY)
+ set(WITH_CPU_FREQUENCY_VAL "1")
+ set(BUTIL_USE_CPU_FREQUENCY 1)
+endif()
+
+set(BUTIL_DEFINITIONS
+ BRPC_WITH_GLOG=${WITH_GLOG_VAL}
+ BUTIL_USE_CPU_FREQUENCY=${WITH_CPU_FREQUENCY_VAL})
+if(WITH_MESALINK)
+ list(APPEND BUTIL_DEFINITIONS USE_MESALINK)
+endif()
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ include(CheckFunctionExists)
+ CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
+ if(NOT HAVE_CLOCK_GETTIME)
+ list(APPEND BUTIL_DEFINITIONS NO_CLOCK_GETTIME_IN_MAC)
+ endif()
+endif()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
+get_filename_component(butil_generated_include_dir
+ "${CMAKE_CURRENT_BINARY_DIR}/.." ABSOLUTE)
+
+set(BUTIL_INCLUDE_DIRS ${GFLAGS_INCLUDE_PATH} ${PROTOBUF_INCLUDE_DIRS})
+if(WITH_GLOG)
+ find_path(GLOG_INCLUDE_PATH NAMES glog/logging.h)
+ find_library(GLOG_LIB NAMES glog)
+ if((NOT GLOG_INCLUDE_PATH) OR (NOT GLOG_LIB))
+ message(FATAL_ERROR "Fail to find glog")
+ endif()
+ list(APPEND BUTIL_INCLUDE_DIRS ${GLOG_INCLUDE_PATH})
+endif()
+
+if(WITH_MESALINK)
+ find_path(MESALINK_INCLUDE_PATH NAMES mesalink/openssl/ssl.h)
+ find_library(MESALINK_LIB NAMES mesalink)
+ if((NOT MESALINK_INCLUDE_PATH) OR (NOT MESALINK_LIB))
+ message(FATAL_ERROR "Fail to find MesaLink")
+ else()
+ message(STATUS "Found MesaLink: ${MESALINK_LIB}")
+ endif()
+ list(APPEND BUTIL_INCLUDE_DIRS ${MESALINK_INCLUDE_PATH})
+endif()
+
+if(WITH_BORINGSSL)
+ find_package(BoringSSL REQUIRED)
+ list(APPEND BUTIL_INCLUDE_DIRS ${BORINGSSL_INCLUDE_DIR})
+else()
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT OPENSSL_ROOT_DIR)
+ set(OPENSSL_ROOT_DIR
+ "/usr/local/opt/openssl" # Homebrew installed OpenSSL
+ )
+ endif()
+
+ find_package(OpenSSL REQUIRED)
+ list(APPEND BUTIL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
+endif()
+
+add_library(butil_build_config INTERFACE)
+target_link_libraries(butil_build_config INTERFACE brpc_common_config)
+target_compile_definitions(butil_build_config INTERFACE ${BUTIL_DEFINITIONS})
+target_include_directories(butil_build_config BEFORE INTERFACE
+ ${butil_generated_include_dir})
+target_include_directories(butil_build_config INTERFACE ${BUTIL_INCLUDE_DIRS})
+
+set(butil_crc32c_options)
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
+ # Only CRC32C needs the SSE4.2 intrinsics and feature macro.
+ list(APPEND butil_crc32c_options -msse4.2)
+ endif()
+endif()
+if(butil_crc32c_options)
+ set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/crc32c.cc
+ APPEND PROPERTY COMPILE_OPTIONS ${butil_crc32c_options})
+endif()
+
+# the reason why not using file(GLOB_RECURSE...) is that we want to
+# include different files on different platforms.
+set(BUTIL_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/arena.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/at_exit.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/atomicops_internals_x86_gcc.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/base64.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/base64url.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/big_endian.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/binary_printer.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/class_name.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/containers/case_ignored_flat_map.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/cpu.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/crc32c.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/alias.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/asan_invalid_access.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/crash_logging.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/debugger.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/debugger_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/dump_without_crashing.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/proc_maps_linux.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/stack_trace.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/stack_trace_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/endpoint.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/environment.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/errno.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/fast_rand.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/fd_utility.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_enumerator.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_enumerator_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_path.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_path_constants.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_watcher.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/memory_mapped_file.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/memory_mapped_file_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/scoped_file.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/scoped_temp_dir.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/temp_file.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/find_cstr.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/guid.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/guid_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/hash.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/iobuf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/iobuf_profiler.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/lazy_instance.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/location.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/logging.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/aligned_memory.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/ref_counted.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/ref_counted_memory.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/singleton.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/weak_ptr.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/popen.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/posix/file_descriptor_shuffle.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/posix/global_descriptors.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/process_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/rand_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/rand_util_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/recordio.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/safe_strerror_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/sha1_portable.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/single_iobuf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/status.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/string_compare_rvv.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/string_printf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/latin1_string_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/nullable_string16.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/safe_sprintf.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string16.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_number_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_piece.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_split.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_util_constants.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/stringprintf.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/utf_offset_string_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/utf_string_conversion_utils.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/utf_string_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/synchronization/cancellation_flag.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/synchronization/condition_variable_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/synchronization/waitable_event_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/dmg_fp/dtoa_wrapper.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/dmg_fp/g_fmt.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/dynamic_annotations/dynamic_annotations.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/icu/icu_utf.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/modp_b64/modp_b64.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/modp_b64/modp_b64_rvv.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/murmurhash3/murmurhash3.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/snappy-sinksource.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/snappy-stubs-internal.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/snappy.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/superfasthash/superfasthash.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/symbolize/demangle.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/symbolize/symbolize.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/thread_key.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/thread_local.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/non_thread_safe_impl.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/platform_thread_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/simple_thread.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_checker_impl.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_collision_warner.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_id_name_manager.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_local_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_local_storage.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_local_storage_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_restrictions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/watchdog.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/default_clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/default_tick_clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/tick_clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/time.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/time_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/unix_socket.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/version.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/zero_copy_stream_as_streambuf.cpp
+ )
+
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+set(BUTIL_SOURCES ${BUTIL_SOURCES}
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util_linux.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/sys_string_conversions_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/platform_thread_linux.cc)
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+set(BUTIL_SOURCES ${BUTIL_SOURCES}
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util_mac.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/mac/bundle_locations.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/mac/foundation_util.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/mac/scoped_mach_port.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/sys_string_conversions_mac.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/platform_thread_mac.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/time_mac.cc)
+endif()
+
+set(butil_platform_libraries)
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ set(butil_platform_libraries
+ pthread
+ "-framework CoreFoundation"
+ "-framework CoreGraphics"
+ "-framework CoreData"
+ "-framework CoreText"
+ "-framework Security"
+ "-framework Foundation"
+ "-Wl,-U,_MallocExtension_ReleaseFreeMemory"
+ "-Wl,-U,_ProfilerStart"
+ "-Wl,-U,_ProfilerStop"
+ "-Wl,-U,__Z13GetStackTracePPvii"
+ "-Wl,-U,_mallctl"
+ "-Wl,-U,_malloc_stats_print"
+ )
+endif()
+
+set(butil_libraries ${GFLAGS_LIBRARY} protobuf::libprotobuf
+ ${protobuf_ABSL_USED_TARGETS} ${CMAKE_THREAD_LIBS_INIT} dl
+ ${butil_platform_libraries})
+set(butil_private_libs "-lgflags -lprotobuf -lssl -lcrypto -ldl")
+if(WITH_BORINGSSL)
+ list(APPEND butil_libraries ${BORINGSSL_SSL_LIBRARY} ${BORINGSSL_CRYPTO_LIBRARY})
+elseif(WITH_MESALINK)
+ list(APPEND butil_libraries ${OPENSSL_CRYPTO_LIBRARY} ${MESALINK_LIB})
+else()
+ list(APPEND butil_libraries ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
+endif()
+if(WITH_GLOG)
+ list(APPEND butil_libraries ${GLOG_LIB})
+ string(APPEND butil_private_libs " -lglog")
+endif()
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ list(APPEND butil_libraries rt)
+ string(APPEND butil_private_libs " -lrt")
+endif()
+
+add_library(BUTIL_LIB OBJECT ${BUTIL_SOURCES})
+target_link_libraries(BUTIL_LIB PRIVATE butil_build_config)
+set_property(TARGET BUTIL_LIB PROPERTY POSITION_INDEPENDENT_CODE 1)
+set_property(TARGET BUTIL_LIB PROPERTY BRPC_CRC32C_COMPILE_OPTIONS "${butil_crc32c_options}")
+set_property(TARGET BUTIL_LIB PROPERTY BRPC_PLATFORM_LIBRARIES "${butil_platform_libraries}")
Review Comment:
[replied by brpc-oncall robot] `BRPC_PLATFORM_LIBRARIES` is written but never read anywhere (the Darwin frameworks are already part of `butil_libraries`). The `URMA_USE_MOCK_ENABLED`/`URMA_INCLUDE_PATH`/`URMA_BOND_INCLUDE_PATH` PARENT_SCOPE assignments in src/brpc/CMakeLists.txt are unused as well. Please drop these leftovers so module ownership stays unambiguous.
##########
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)
Review Comment:
[replied by brpc-oncall robot] Include order for this target is now `-I<build>/src -I<src> -I<build>/src/brpc` (see `CXX_INCLUDES` in `src/mcpack2pb/CMakeFiles/protoc-gen-mcpack.dir/flags.make`, same with BUILD_SHARED_LIBS=ON). Because `butil_build_config` is linked before the bundle targets, the directory holding the generated `idl_options.pb.h` ends up last, so `#include "idl_options.pb.h"` in generator.cpp can pick up a stale in-source copy written by the Make build (`src/idl_options.pb.h`, see Makefile line 294). The removed root CMakeLists deliberately put the build tree ahead of `src` for exactly this reason, so this is a regression for this target. Please make the generated header directory win here, e.g. by linking `brpc-static`/`brpc-shared` before `butil_build_config`, or by adding `target_include_directories(protoc-gen-mcpack BEFORE PRIVATE ${PROJECT_BINARY_DIR}/src/brpc)`.
--
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: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] Refactor CMake source and target ownership into module directories (brpc)
Posted by "wasphin (via GitHub)" <gi...@apache.org>.
wasphin commented on code in PR #3618:
URL: https://github.com/apache/brpc/pull/3618#discussion_r4306249020
##########
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)
Review Comment:
Fixed in ebdd972e. Removed the redundant direct butil_build_config link so the generator inherits its build settings through the selected bundle, putting generated IDL headers before source-tree headers. Verified that the old include order fails with a deliberately stale src/idl_options.pb.h containing #error, while the corrected order compiles. Both static and shared generator builds pass with that fixture present.
##########
src/butil/CMakeLists.txt:
##########
@@ -0,0 +1,290 @@
+# 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(WITH_GLOG_VAL "0")
+if(WITH_GLOG)
+ set(WITH_GLOG_VAL "1")
+ set(BRPC_WITH_GLOG 1)
+endif()
+
+set(WITH_CPU_FREQUENCY_VAL "0")
+if(WITH_CPU_FREQUENCY)
+ set(WITH_CPU_FREQUENCY_VAL "1")
+ set(BUTIL_USE_CPU_FREQUENCY 1)
+endif()
+
+set(BUTIL_DEFINITIONS
+ BRPC_WITH_GLOG=${WITH_GLOG_VAL}
+ BUTIL_USE_CPU_FREQUENCY=${WITH_CPU_FREQUENCY_VAL})
+if(WITH_MESALINK)
+ list(APPEND BUTIL_DEFINITIONS USE_MESALINK)
+endif()
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ include(CheckFunctionExists)
+ CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
+ if(NOT HAVE_CLOCK_GETTIME)
+ list(APPEND BUTIL_DEFINITIONS NO_CLOCK_GETTIME_IN_MAC)
+ endif()
+endif()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
+get_filename_component(butil_generated_include_dir
+ "${CMAKE_CURRENT_BINARY_DIR}/.." ABSOLUTE)
+
+set(BUTIL_INCLUDE_DIRS ${GFLAGS_INCLUDE_PATH} ${PROTOBUF_INCLUDE_DIRS})
+if(WITH_GLOG)
+ find_path(GLOG_INCLUDE_PATH NAMES glog/logging.h)
+ find_library(GLOG_LIB NAMES glog)
+ if((NOT GLOG_INCLUDE_PATH) OR (NOT GLOG_LIB))
+ message(FATAL_ERROR "Fail to find glog")
+ endif()
+ list(APPEND BUTIL_INCLUDE_DIRS ${GLOG_INCLUDE_PATH})
+endif()
+
+if(WITH_MESALINK)
+ find_path(MESALINK_INCLUDE_PATH NAMES mesalink/openssl/ssl.h)
+ find_library(MESALINK_LIB NAMES mesalink)
+ if((NOT MESALINK_INCLUDE_PATH) OR (NOT MESALINK_LIB))
+ message(FATAL_ERROR "Fail to find MesaLink")
+ else()
+ message(STATUS "Found MesaLink: ${MESALINK_LIB}")
+ endif()
+ list(APPEND BUTIL_INCLUDE_DIRS ${MESALINK_INCLUDE_PATH})
+endif()
+
+if(WITH_BORINGSSL)
+ find_package(BoringSSL REQUIRED)
+ list(APPEND BUTIL_INCLUDE_DIRS ${BORINGSSL_INCLUDE_DIR})
+else()
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT OPENSSL_ROOT_DIR)
+ set(OPENSSL_ROOT_DIR
+ "/usr/local/opt/openssl" # Homebrew installed OpenSSL
+ )
+ endif()
+
+ find_package(OpenSSL REQUIRED)
+ list(APPEND BUTIL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
+endif()
+
+add_library(butil_build_config INTERFACE)
+target_link_libraries(butil_build_config INTERFACE brpc_common_config)
+target_compile_definitions(butil_build_config INTERFACE ${BUTIL_DEFINITIONS})
+target_include_directories(butil_build_config BEFORE INTERFACE
+ ${butil_generated_include_dir})
+target_include_directories(butil_build_config INTERFACE ${BUTIL_INCLUDE_DIRS})
+
+set(butil_crc32c_options)
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
+ # Only CRC32C needs the SSE4.2 intrinsics and feature macro.
+ list(APPEND butil_crc32c_options -msse4.2)
+ endif()
+endif()
+if(butil_crc32c_options)
+ set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/crc32c.cc
+ APPEND PROPERTY COMPILE_OPTIONS ${butil_crc32c_options})
+endif()
+
+# the reason why not using file(GLOB_RECURSE...) is that we want to
+# include different files on different platforms.
+set(BUTIL_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/arena.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/at_exit.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/atomicops_internals_x86_gcc.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/base64.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/base64url.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/big_endian.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/binary_printer.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/class_name.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/containers/case_ignored_flat_map.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/cpu.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/crc32c.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/alias.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/asan_invalid_access.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/crash_logging.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/debugger.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/debugger_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/dump_without_crashing.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/proc_maps_linux.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/stack_trace.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/stack_trace_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/endpoint.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/environment.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/errno.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/fast_rand.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/fd_utility.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_enumerator.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_enumerator_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_path.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_path_constants.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_watcher.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/memory_mapped_file.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/memory_mapped_file_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/scoped_file.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/scoped_temp_dir.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/temp_file.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/find_cstr.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/guid.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/guid_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/hash.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/iobuf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/iobuf_profiler.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/lazy_instance.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/location.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/logging.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/aligned_memory.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/ref_counted.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/ref_counted_memory.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/singleton.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/weak_ptr.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/popen.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/posix/file_descriptor_shuffle.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/posix/global_descriptors.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/process_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/rand_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/rand_util_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/recordio.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/safe_strerror_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/sha1_portable.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/single_iobuf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/status.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/string_compare_rvv.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/string_printf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/latin1_string_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/nullable_string16.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/safe_sprintf.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string16.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_number_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_piece.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_split.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_util_constants.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/stringprintf.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/utf_offset_string_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/utf_string_conversion_utils.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/utf_string_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/synchronization/cancellation_flag.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/synchronization/condition_variable_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/synchronization/waitable_event_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/dmg_fp/dtoa_wrapper.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/dmg_fp/g_fmt.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/dynamic_annotations/dynamic_annotations.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/icu/icu_utf.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/modp_b64/modp_b64.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/modp_b64/modp_b64_rvv.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/murmurhash3/murmurhash3.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/snappy-sinksource.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/snappy-stubs-internal.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/snappy.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/superfasthash/superfasthash.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/symbolize/demangle.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/symbolize/symbolize.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/thread_key.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/thread_local.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/non_thread_safe_impl.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/platform_thread_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/simple_thread.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_checker_impl.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_collision_warner.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_id_name_manager.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_local_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_local_storage.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_local_storage_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_restrictions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/watchdog.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/default_clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/default_tick_clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/tick_clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/time.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/time_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/unix_socket.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/version.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/zero_copy_stream_as_streambuf.cpp
+ )
+
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+set(BUTIL_SOURCES ${BUTIL_SOURCES}
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util_linux.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/sys_string_conversions_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/platform_thread_linux.cc)
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+set(BUTIL_SOURCES ${BUTIL_SOURCES}
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util_mac.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/mac/bundle_locations.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/mac/foundation_util.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/mac/scoped_mach_port.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/sys_string_conversions_mac.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/platform_thread_mac.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/time_mac.cc)
+endif()
+
+set(butil_platform_libraries)
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ set(butil_platform_libraries
+ pthread
+ "-framework CoreFoundation"
+ "-framework CoreGraphics"
+ "-framework CoreData"
+ "-framework CoreText"
+ "-framework Security"
+ "-framework Foundation"
+ "-Wl,-U,_MallocExtension_ReleaseFreeMemory"
+ "-Wl,-U,_ProfilerStart"
+ "-Wl,-U,_ProfilerStop"
+ "-Wl,-U,__Z13GetStackTracePPvii"
+ "-Wl,-U,_mallctl"
+ "-Wl,-U,_malloc_stats_print"
+ )
+endif()
+
+set(butil_libraries ${GFLAGS_LIBRARY} protobuf::libprotobuf
+ ${protobuf_ABSL_USED_TARGETS} ${CMAKE_THREAD_LIBS_INIT} dl
+ ${butil_platform_libraries})
+set(butil_private_libs "-lgflags -lprotobuf -lssl -lcrypto -ldl")
+if(WITH_BORINGSSL)
+ list(APPEND butil_libraries ${BORINGSSL_SSL_LIBRARY} ${BORINGSSL_CRYPTO_LIBRARY})
+elseif(WITH_MESALINK)
+ list(APPEND butil_libraries ${OPENSSL_CRYPTO_LIBRARY} ${MESALINK_LIB})
+else()
+ list(APPEND butil_libraries ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
+endif()
+if(WITH_GLOG)
+ list(APPEND butil_libraries ${GLOG_LIB})
+ string(APPEND butil_private_libs " -lglog")
+endif()
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ list(APPEND butil_libraries rt)
+ string(APPEND butil_private_libs " -lrt")
+endif()
+
+add_library(BUTIL_LIB OBJECT ${BUTIL_SOURCES})
+target_link_libraries(BUTIL_LIB PRIVATE butil_build_config)
+set_property(TARGET BUTIL_LIB PROPERTY POSITION_INDEPENDENT_CODE 1)
+set_property(TARGET BUTIL_LIB PROPERTY BRPC_CRC32C_COMPILE_OPTIONS "${butil_crc32c_options}")
+set_property(TARGET BUTIL_LIB PROPERTY BRPC_PLATFORM_LIBRARIES "${butil_platform_libraries}")
Review Comment:
Fixed in 1672bdac. Removed the unread BRPC_PLATFORM_LIBRARIES property and all three unused URMA PARENT_SCOPE assignments. Also updated both UBRing guides in 7695deaf to configure the installation prefix before building, install the bundle, and pass the prefix explicitly in both example build sections.
##########
test/CMakeLists.txt:
##########
@@ -220,7 +237,7 @@ set_target_properties(brpc-shared-debug PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/test)
target_link_libraries(brpc-shared-debug PUBLIC brpc_test_config ${DYNAMIC_LIB})
-if(BRPC_WITH_GLOG)
+if(WITH_GLOG)
target_link_libraries(brpc-shared-debug PUBLIC ${GLOG_LIB})
Review Comment:
Fixed in 1672bdac. Removed the redundant WITH_GLOG blocks from both debug bundles. Configured unit-test and fuzz targets with WITH_GLOG=ON and verified that the generated shared-debug and static-debug consumer/fuzzer link commands still include glog through DYNAMIC_LIB.
--
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: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] Refactor CMake source and target ownership into module directories (brpc)
Posted by "chenBright (via GitHub)" <gi...@apache.org>.
chenBright commented on code in PR #3618:
URL: https://github.com/apache/brpc/pull/3618#discussion_r4307346069
##########
src/CMakeLists.txt:
##########
@@ -15,86 +15,60 @@
# specific language governing permissions and limitations
# under the License.
-add_library(BUTIL_LIB OBJECT ${BUTIL_SOURCES})
-add_library(SOURCES_LIB OBJECT ${SOURCES})
-add_dependencies(SOURCES_LIB PROTO_LIB)
-target_link_libraries(BUTIL_LIB PRIVATE brpc_common_config)
-target_link_libraries(SOURCES_LIB PRIVATE brpc_common_config)
+add_library(brpc_bundle_dependencies INTERFACE)
+
+add_subdirectory(butil)
+add_subdirectory(bvar)
+add_subdirectory(bthread)
+add_subdirectory(json2pb)
+add_subdirectory(mcpack2pb)
+add_subdirectory(brpc)
+
+# Modules report their bundle dependencies after applying their own options.
+set(DYNAMIC_LIB)
+set(component_private_libs)
+foreach(component BUTIL BVAR BTHREAD JSON2PB MCPACK2PB BRPC)
+ get_target_property(component_libraries ${component}_LIB BRPC_BUNDLE_LIBRARIES)
+ if(component_libraries)
+ list(APPEND DYNAMIC_LIB ${component_libraries})
+ endif()
+ get_target_property(component_pkgconfig ${component}_LIB BRPC_PRIVATE_LIBS)
+ if(component_pkgconfig)
+ list(APPEND component_private_libs "${component_pkgconfig}")
+ endif()
+endforeach()
+string(JOIN " " BRPC_PRIVATE_LIBS ${component_private_libs})
-# shared library needs POSITION_INDEPENDENT_CODE
-set_property(TARGET ${SOURCES_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1)
-set_property(TARGET ${BUTIL_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1)
+target_link_libraries(brpc_bundle_dependencies INTERFACE ${DYNAMIC_LIB})
+# Keep legacy debug tests and pkg-config generation supplied by the bundle.
+set(DYNAMIC_LIB ${DYNAMIC_LIB} PARENT_SCOPE)
+set(BRPC_PRIVATE_LIBS "${BRPC_PRIVATE_LIBS}" PARENT_SCOPE)
+
+set(BRPC_SOURCE_OBJECTS)
+foreach(component BVAR BTHREAD JSON2PB MCPACK2PB BRPC)
+ list(APPEND BRPC_SOURCE_OBJECTS $<TARGET_OBJECTS:${component}_LIB>)
+endforeach()
add_library(brpc-static STATIC $<TARGET_OBJECTS:BUTIL_LIB>
- $<TARGET_OBJECTS:SOURCES_LIB>
+ ${BRPC_SOURCE_OBJECTS}
$<TARGET_OBJECTS:PROTO_LIB>)
-target_link_libraries(brpc-static PUBLIC brpc_common_config)
-
-function(check_thrift_version target_arg)
- #use thrift command to get version
- execute_process(
- COMMAND thrift --version
- OUTPUT_VARIABLE THRIFT_VERSION_OUTPUT
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
-
- string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" THRIFT_VERSION ${THRIFT_VERSION_OUTPUT})
- string(REGEX REPLACE "\\." ";" THRIFT_VERSION_LIST ${THRIFT_VERSION})
-
- list(GET THRIFT_VERSION_LIST 0 THRIFT_MAJOR_VERSION)
- list(GET THRIFT_VERSION_LIST 1 THRIFT_MINOR_VERSION)
-
- if (THRIFT_MAJOR_VERSION EQUAL 0 AND THRIFT_MINOR_VERSION LESS 11)
- message(STATUS "Thrift version is less than 0.11.0")
- target_compile_definitions(${target_arg} PRIVATE _THRIFT_VERSION_LOWER_THAN_0_11_0_)
- else()
- message(STATUS "Thrift version is equal to or greater than 0.11.0")
- endif()
-endfunction()
-
-
-if(WITH_THRIFT)
- target_link_libraries(brpc-static PRIVATE ${THRIFT_LIB})
- check_thrift_version(brpc-static)
-endif()
+target_link_libraries(brpc-static PUBLIC brpc_build_config)
Review Comment:
With WITH_THRIFT=ON, the previous implementation explicitly linked ${THRIFT_LIB} to brpc-static. The refactor moves this dependency into brpc_runtime_dependencies, but neither that interface nor brpc_bundle_dependencies is linked to the static target.
Downstream projects that supply the other dependencies and rely on the existing transitive Thrift linkage will now encounter undefined Thrift symbols. In-tree tools can hide this regression because they also link ${DYNAMIC_LIB}.
##########
src/butil/CMakeLists.txt:
##########
@@ -0,0 +1,289 @@
+# 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(WITH_GLOG_VAL "0")
+if(WITH_GLOG)
+ set(WITH_GLOG_VAL "1")
+ set(BRPC_WITH_GLOG 1)
+endif()
+
+set(WITH_CPU_FREQUENCY_VAL "0")
+if(WITH_CPU_FREQUENCY)
+ set(WITH_CPU_FREQUENCY_VAL "1")
+ set(BUTIL_USE_CPU_FREQUENCY 1)
+endif()
+
+set(BUTIL_DEFINITIONS
+ BRPC_WITH_GLOG=${WITH_GLOG_VAL}
+ BUTIL_USE_CPU_FREQUENCY=${WITH_CPU_FREQUENCY_VAL})
+if(WITH_MESALINK)
+ list(APPEND BUTIL_DEFINITIONS USE_MESALINK)
+endif()
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ include(CheckFunctionExists)
+ CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
+ if(NOT HAVE_CLOCK_GETTIME)
+ list(APPEND BUTIL_DEFINITIONS NO_CLOCK_GETTIME_IN_MAC)
+ endif()
+endif()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h @ONLY)
+get_filename_component(butil_generated_include_dir
+ "${CMAKE_CURRENT_BINARY_DIR}/.." ABSOLUTE)
+
+set(BUTIL_INCLUDE_DIRS ${GFLAGS_INCLUDE_PATH} ${PROTOBUF_INCLUDE_DIRS})
+if(WITH_GLOG)
+ find_path(GLOG_INCLUDE_PATH NAMES glog/logging.h)
+ find_library(GLOG_LIB NAMES glog)
+ if((NOT GLOG_INCLUDE_PATH) OR (NOT GLOG_LIB))
+ message(FATAL_ERROR "Fail to find glog")
+ endif()
+ list(APPEND BUTIL_INCLUDE_DIRS ${GLOG_INCLUDE_PATH})
+endif()
+
+if(WITH_MESALINK)
+ find_path(MESALINK_INCLUDE_PATH NAMES mesalink/openssl/ssl.h)
+ find_library(MESALINK_LIB NAMES mesalink)
+ if((NOT MESALINK_INCLUDE_PATH) OR (NOT MESALINK_LIB))
+ message(FATAL_ERROR "Fail to find MesaLink")
+ else()
+ message(STATUS "Found MesaLink: ${MESALINK_LIB}")
+ endif()
+ list(APPEND BUTIL_INCLUDE_DIRS ${MESALINK_INCLUDE_PATH})
+endif()
+
+if(WITH_BORINGSSL)
+ find_package(BoringSSL REQUIRED)
+ list(APPEND BUTIL_INCLUDE_DIRS ${BORINGSSL_INCLUDE_DIR})
+else()
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT OPENSSL_ROOT_DIR)
+ set(OPENSSL_ROOT_DIR
+ "/usr/local/opt/openssl" # Homebrew installed OpenSSL
+ )
+ endif()
+
+ find_package(OpenSSL REQUIRED)
+ list(APPEND BUTIL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
+endif()
+
+add_library(butil_build_config INTERFACE)
+target_link_libraries(butil_build_config INTERFACE brpc_common_config)
+target_compile_definitions(butil_build_config INTERFACE ${BUTIL_DEFINITIONS})
+target_include_directories(butil_build_config BEFORE INTERFACE
+ ${butil_generated_include_dir})
+target_include_directories(butil_build_config INTERFACE ${BUTIL_INCLUDE_DIRS})
+
+set(butil_crc32c_options)
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
+ # Only CRC32C needs the SSE4.2 intrinsics and feature macro.
+ list(APPEND butil_crc32c_options -msse4.2)
+ endif()
+endif()
+if(butil_crc32c_options)
+ set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/crc32c.cc
+ APPEND PROPERTY COMPILE_OPTIONS ${butil_crc32c_options})
+endif()
+
+# the reason why not using file(GLOB_RECURSE...) is that we want to
+# include different files on different platforms.
+set(BUTIL_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/arena.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/at_exit.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/atomicops_internals_x86_gcc.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/base64.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/base64url.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/big_endian.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/binary_printer.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/class_name.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/containers/case_ignored_flat_map.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/cpu.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/crc32c.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/alias.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/asan_invalid_access.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/crash_logging.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/debugger.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/debugger_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/dump_without_crashing.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/proc_maps_linux.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/stack_trace.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/debug/stack_trace_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/endpoint.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/environment.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/errno.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/fast_rand.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/fd_utility.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_enumerator.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_enumerator_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_path.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_path_constants.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/file_watcher.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/memory_mapped_file.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/memory_mapped_file_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/scoped_file.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/scoped_temp_dir.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/files/temp_file.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/find_cstr.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/guid.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/guid_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/hash.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/iobuf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/iobuf_profiler.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/lazy_instance.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/location.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/logging.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/aligned_memory.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/ref_counted.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/ref_counted_memory.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/singleton.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/memory/weak_ptr.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/popen.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/posix/file_descriptor_shuffle.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/posix/global_descriptors.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/process_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/rand_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/rand_util_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/recordio.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/safe_strerror_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/sha1_portable.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/single_iobuf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/status.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/string_compare_rvv.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/string_printf.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/latin1_string_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/nullable_string16.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/safe_sprintf.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string16.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_number_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_piece.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_split.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_util.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/string_util_constants.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/stringprintf.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/utf_offset_string_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/utf_string_conversion_utils.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/utf_string_conversions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/synchronization/cancellation_flag.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/synchronization/condition_variable_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/synchronization/waitable_event_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/dmg_fp/dtoa_wrapper.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/dmg_fp/g_fmt.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/dynamic_annotations/dynamic_annotations.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/icu/icu_utf.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/modp_b64/modp_b64.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/modp_b64/modp_b64_rvv.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/murmurhash3/murmurhash3.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/snappy-sinksource.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/snappy-stubs-internal.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy/snappy.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/superfasthash/superfasthash.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/symbolize/demangle.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/third_party/symbolize/symbolize.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/thread_key.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/thread_local.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/non_thread_safe_impl.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/platform_thread_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/simple_thread.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_checker_impl.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_collision_warner.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_id_name_manager.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_local_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_local_storage.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_local_storage_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/thread_restrictions.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/watchdog.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/default_clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/default_tick_clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/tick_clock.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/time.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/time_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/unix_socket.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/version.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/zero_copy_stream_as_streambuf.cpp
+ )
+
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+set(BUTIL_SOURCES ${BUTIL_SOURCES}
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util_linux.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/sys_string_conversions_posix.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/platform_thread_linux.cc)
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+set(BUTIL_SOURCES ${BUTIL_SOURCES}
+ ${CMAKE_CURRENT_SOURCE_DIR}/file_util_mac.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/mac/bundle_locations.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/mac/foundation_util.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/mac/scoped_mach_port.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/strings/sys_string_conversions_mac.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/threading/platform_thread_mac.mm
+ ${CMAKE_CURRENT_SOURCE_DIR}/time/time_mac.cc)
+endif()
+
+set(butil_platform_libraries)
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ set(butil_platform_libraries
+ pthread
+ "-framework CoreFoundation"
+ "-framework CoreGraphics"
+ "-framework CoreData"
+ "-framework CoreText"
+ "-framework Security"
+ "-framework Foundation"
+ "-Wl,-U,_MallocExtension_ReleaseFreeMemory"
+ "-Wl,-U,_ProfilerStart"
+ "-Wl,-U,_ProfilerStop"
+ "-Wl,-U,__Z13GetStackTracePPvii"
+ "-Wl,-U,_mallctl"
+ "-Wl,-U,_malloc_stats_print"
+ )
+endif()
+
+set(butil_libraries ${GFLAGS_LIBRARY} protobuf::libprotobuf
+ ${protobuf_ABSL_USED_TARGETS} ${CMAKE_THREAD_LIBS_INIT} dl
+ ${butil_platform_libraries})
+set(butil_private_libs "-lgflags -lprotobuf -lssl -lcrypto -ldl")
+if(WITH_BORINGSSL)
+ list(APPEND butil_libraries ${BORINGSSL_SSL_LIBRARY} ${BORINGSSL_CRYPTO_LIBRARY})
+elseif(WITH_MESALINK)
+ list(APPEND butil_libraries ${OPENSSL_CRYPTO_LIBRARY} ${MESALINK_LIB})
+else()
+ list(APPEND butil_libraries ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
+endif()
+if(WITH_GLOG)
+ list(APPEND butil_libraries ${GLOG_LIB})
+ string(APPEND butil_private_libs " -lglog")
Review Comment:
Appending glog changes the generated brpc.pc ordering from -lglog -lgflags … to -lgflags … -lglog.
With static glog/gflags and GNU ld, a client that only includes butil/logging.h and calls LOG(INFO) may first introduce gflags references when libglog.a is scanned. Since libgflags.a has already been processed, this leaves google::FlagRegisterer unresolved.
--
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: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] Refactor CMake source and target ownership into module directories (brpc)
Posted by "wasphin (via GitHub)" <gi...@apache.org>.
wasphin commented on code in PR #3618:
URL: https://github.com/apache/brpc/pull/3618#discussion_r4302750947
##########
example/ubring_performance/CMakeLists.txt:
##########
@@ -100,7 +95,7 @@ include_directories(${OPENSSL_INCLUDE_DIR})
set(DYNAMIC_LIB
${CMAKE_THREAD_LIBS_INIT}
${GFLAGS_LIBRARY}
- ${PROTOBUF_LIBRARIES}
+ protobuf::libprotobuf
Review Comment:
Fixed in 9e13e32e. Aligned the example’s minimum CMake version and policy range with the root project and other examples. Configuration and both executable builds pass without the compatibility override.
--
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: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] Refactor CMake source and target ownership into module directories (brpc)
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3618:
URL: https://github.com/apache/brpc/pull/3618#discussion_r4301882234
##########
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:
This helper still discovers the brpc installation by searching for `output/include`, but this PR removes the `output/include` staging step from the top-level CMake build. A fresh in-tree build therefore leaves `OUTPUT_PATH` empty and the examples fall back to unrelated system headers/libraries (or fail with `Fail to find brpc`). Switch this lookup to an explicit installed prefix (or otherwise pass the install location) so the examples remain usable after the staging directory is removed.
##########
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:
This standalone example has the same stale `output/include` discovery as the shared example helper. Since the refactored CMake build no longer creates that directory, configuring this example after building brpc in-tree cannot find the just-built headers/library and may silently select system installations. Accept an explicit install prefix (or update the lookup to the installed tree) instead of relying on the removed staging directory.
##########
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:
`src/mcpack2pb` is processed before `src/CMakeLists.txt` creates `brpc-static` and `brpc-shared` (those targets are added only after all module subdirectories). CMake requires the target named by `target_link_libraries` to already exist, so configuration fails here with “Cannot specify link libraries for target ... which is not built by this project.” Move these generator link statements after the bundle targets are created, or otherwise link the generator through targets available at this point.
--
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: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] Refactor CMake source and target ownership into module directories (brpc)
Posted by "wasphin (via GitHub)" <gi...@apache.org>.
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: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org
Re: [PR] Refactor CMake source and target ownership into module directories (brpc)
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #3618:
URL: https://github.com/apache/brpc/pull/3618#discussion_r4302607831
##########
example/ubring_performance/CMakeLists.txt:
##########
@@ -100,7 +95,7 @@ include_directories(${OPENSSL_INCLUDE_DIR})
set(DYNAMIC_LIB
${CMAKE_THREAD_LIBS_INIT}
${GFLAGS_LIBRARY}
- ${PROTOBUF_LIBRARIES}
+ protobuf::libprotobuf
Review Comment:
This example still declares support for CMake 2.8.10, but the legacy FindProtobuf module on those CMake versions does not define the imported target `protobuf::libprotobuf`. It is then passed to the linker as a literal library name and the example fails to link; keep `${PROTOBUF_LIBRARIES}` here or raise the example's minimum CMake version.
--
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: dev-unsubscribe@brpc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org