Skip to content

Commit 2e9b271

Browse files
committed
Skip non-namespaced BUILD_INTERFACE targets in dependency export
Updates the dependency export logic to only process BUILD_INTERFACE targets that are namespaced (external dependencies). Non-namespaced BUILD_INTERFACE targets, which are local build targets, are now skipped to avoid incorrect dependency tracking.
1 parent 9e5228e commit 2e9b271

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cmake/cpp-library-install.cmake

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,17 @@ function(_cpp_library_generate_dependencies OUTPUT_VAR TARGET_NAME NAMESPACE)
6060
# When re-exporting dependencies from external packages, they must be wrapped in BUILD_INTERFACE
6161
# to avoid CMake export errors, but we still want to track them for find_dependency()
6262
if(LIB MATCHES "^\\$<BUILD_INTERFACE:([^>]+)>$")
63-
set(LIB "${CMAKE_MATCH_1}")
64-
message(DEBUG "cpp-library: Extracted ${LIB} from BUILD_INTERFACE generator expression")
63+
set(EXTRACTED_TARGET "${CMAKE_MATCH_1}")
64+
# Only process if it's a namespaced target (external dependency)
65+
# Non-namespaced targets in BUILD_INTERFACE are local build targets
66+
if(EXTRACTED_TARGET MATCHES "::")
67+
set(LIB "${EXTRACTED_TARGET}")
68+
message(DEBUG "cpp-library: Extracted ${LIB} from BUILD_INTERFACE generator expression")
69+
else()
70+
# Skip non-namespaced BUILD_INTERFACE targets (local build targets)
71+
message(DEBUG "cpp-library: Skipping non-namespaced BUILD_INTERFACE target: ${EXTRACTED_TARGET}")
72+
continue()
73+
endif()
6574
elseif(LIB MATCHES "^\\$<")
6675
# Skip other generator expressions (INSTALL_INTERFACE, etc.)
6776
continue()

0 commit comments

Comments
 (0)