Skip to content

Commit 933fb35

Browse files
authored
fix(build): map missing *_shared deps to *_static in static-only builds (alibaba#125)
* fix(build): map missing *_shared deps to *_static in static-only builds * style(cmake): format BuildUtils dependency mapping for cmake-format
1 parent 4a5759e commit 933fb35

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

cmake_modules/BuildUtils.cmake

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,19 @@ function(add_paimon_lib LIB_NAME)
5555
# Necessary to make static linking into other shared libraries work properly
5656
set_property(TARGET ${LIB_NAME}_objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
5757
if(ARG_DEPENDENCIES)
58-
# Avoid add_dependencies on non-existent targets (e.g. when building static only).
58+
# In static-only builds, some dependency names are still declared as
59+
# *_shared. Map them to *_static when the shared target is unavailable.
5960
set(_paimon_objlib_deps)
6061
foreach(_paimon_dep IN LISTS ARG_DEPENDENCIES)
61-
if(TARGET ${_paimon_dep})
62-
list(APPEND _paimon_objlib_deps ${_paimon_dep})
62+
set(_paimon_mapped_dep "${_paimon_dep}")
63+
if(NOT TARGET ${_paimon_mapped_dep} AND _paimon_dep MATCHES "_shared$")
64+
string(REGEX REPLACE "_shared$" "_static" _paimon_mapped_dep
65+
"${_paimon_dep}")
6366
endif()
67+
if(TARGET ${_paimon_mapped_dep})
68+
list(APPEND _paimon_objlib_deps ${_paimon_mapped_dep})
69+
endif()
70+
unset(_paimon_mapped_dep)
6471
endforeach()
6572
if(_paimon_objlib_deps)
6673
add_dependencies(${LIB_NAME}_objlib ${_paimon_objlib_deps})

0 commit comments

Comments
 (0)