From 6c8097b1b81e526f13f769b3967a8b3fb2242f92 Mon Sep 17 00:00:00 2001 From: Alan Frindell Date: Thu, 12 Mar 2026 13:38:41 -0700 Subject: [PATCH] Fix CMake BUILD_SHARED_LIBS=ON support (#601) Summary: Pull Request resolved: https://github.com/facebook/proxygen/pull/601 The granular CMake refactoring in D91009064 broke shared library builds. 1. `proxygen_add_library()` creates INTERFACE targets for shared builds, but `lib/CMakeLists.txt` called `target_include_directories(... PUBLIC ...)` on them. CMake only allows INTERFACE properties on INTERFACE targets. These calls were redundant since `proxygen_add_library()` already sets the same include directories. 2. In `proxygen_resolve_deferred_dependencies()`, `_obj` targets could fall through to linking against plain INTERFACE wrapper targets, which link to the monolithic `proxygen` shared library. Since `proxygen` is built from those same `_obj` targets, this creates a dependency cycle. Skip deps without an `_obj` version for `_obj` targets in shared builds. Reviewed By: jbeshay Differential Revision: D96253183 fbshipit-source-id: 1b0a1728c014b8475834e31ff09bbed7bd912948 --- cmake/ProxygenFunctions.cmake | 2 ++ proxygen/lib/CMakeLists.txt | 12 ------------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/cmake/ProxygenFunctions.cmake b/cmake/ProxygenFunctions.cmake index 7db4b04d3..a5027ce25 100644 --- a/cmake/ProxygenFunctions.cmake +++ b/cmake/ProxygenFunctions.cmake @@ -434,6 +434,8 @@ function(proxygen_resolve_deferred_dependencies) # link to _obj for include path propagation if(BUILD_SHARED_LIBS AND _target MATCHES "_obj$" AND TARGET ${_dep}_obj) list(APPEND _valid_deps ${_dep}_obj) + elseif(BUILD_SHARED_LIBS AND _target MATCHES "_obj$") + # No _obj version exists; skip to avoid cycle through monolithic library elseif(TARGET ${_dep}) list(APPEND _valid_deps ${_dep}) endif() diff --git a/proxygen/lib/CMakeLists.txt b/proxygen/lib/CMakeLists.txt index 37905e515..a1cc4bbfc 100644 --- a/proxygen/lib/CMakeLists.txt +++ b/proxygen/lib/CMakeLists.txt @@ -114,12 +114,6 @@ proxygen_add_library(proxygen_http_http_common_headers proxygen-generated Folly::folly_range ) -target_include_directories(proxygen_http_http_common_headers PUBLIC - $ - $ - $ -) - proxygen_add_library(proxygen_utils_trace_event_types SRCS ${PROXYGEN_GENERATED_ROOT}/proxygen/lib/utils/TraceEventType.cpp @@ -128,12 +122,6 @@ proxygen_add_library(proxygen_utils_trace_event_types proxygen-generated Folly::folly_conv ) -target_include_directories(proxygen_utils_trace_event_types PUBLIC - $ - $ - $ -) - # Granular library for http_parser proxygen_add_library(proxygen_external_http_parser SRCS