From cd59c10ce768ea2e782350d9cfb7720a218bb071 Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Fri, 4 Nov 2022 09:38:41 +0800 Subject: [PATCH] fix cc_library link python lib (#47605) * fix cc_library link python lib --- cmake/generic.cmake | 3 +-- paddle/fluid/pybind/CMakeLists.txt | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmake/generic.cmake b/cmake/generic.cmake index e4cd6ac73bf..f7b7c73d4de 100644 --- a/cmake/generic.cmake +++ b/cmake/generic.cmake @@ -388,8 +388,7 @@ function(cc_library TARGET_NAME) target_link_libraries(${TARGET_NAME} "-Wl,-undefined,dynamic_lookup") endif() endif() - target_link_libraries(${TARGET_NAME} ${cc_library_DEPS} - ${PYTHON_LIBRARIES}) + target_link_libraries(${TARGET_NAME} ${cc_library_DEPS}) common_link(${TARGET_NAME}) endif() diff --git a/paddle/fluid/pybind/CMakeLists.txt b/paddle/fluid/pybind/CMakeLists.txt index 7f2a5d7d39c..5e7e0f07ab6 100755 --- a/paddle/fluid/pybind/CMakeLists.txt +++ b/paddle/fluid/pybind/CMakeLists.txt @@ -296,6 +296,10 @@ if(WITH_PYTHON) list(APPEND OP_FUNCTION_GENERETOR_DEPS cncl_context) endif() + if(NOT ((NOT WITH_PYTHON) AND ON_INFER)) + list(APPEND OP_FUNCTION_GENERETOR_DEPS ${PYTHON_LIBRARIES}) + endif() + add_executable(op_function_generator op_function_generator.cc) target_link_libraries(op_function_generator ${OP_FUNCTION_GENERETOR_DEPS}) add_executable(eager_legacy_op_function_generator @@ -650,4 +654,6 @@ if(WITH_PYTHON) get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES) target_link_libraries(${SHARD_LIB_NAME} ${os_dependency_modules}) add_dependencies(${SHARD_LIB_NAME} op_function_generator_cmd) + + target_link_libraries(${SHARD_LIB_NAME} ${PYTHON_LIBRARIES}) endif() -- GitLab