Skip to content

Commit 5d6783f

Browse files
authored
Merge pull request #13954 from typhoonzero/core_so_donot_depend_libpython
core.so do not link libpython test=develop
2 parents 0e24138 + 726b91e commit 5d6783f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cmake/generic.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,13 @@ function(cc_library TARGET_NAME)
261261
add_dependencies(${TARGET_NAME} mklml)
262262
target_link_libraries(${TARGET_NAME} "-L${MKLML_LIB_DIR} -liomp5 -Wl,--as-needed")
263263
endif()
264+
# remove link to python, see notes at:
265+
# https://github.com/pybind/pybind11/blob/master/docs/compiling.rst#building-manually
266+
if("${cc_library_DEPS};" MATCHES "python;")
267+
list(REMOVE_ITEM cc_library_DEPS python)
268+
add_dependencies(${TARGET_NAME} python)
269+
target_link_libraries(${TARGET_NAME} "-Wl,-undefined,dynamic_lookup")
270+
endif()
264271
target_link_libraries(${TARGET_NAME} ${cc_library_DEPS})
265272
add_dependencies(${TARGET_NAME} ${cc_library_DEPS})
266273
endif()

0 commit comments

Comments
 (0)