diff --git a/cmake/generic.cmake b/cmake/generic.cmake index e4cd6ac73bf71fa9f6767a834996d73761a4a688..f7b7c73d4deed1affa69a794ea6b940d12e0a589 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 7f2a5d7d39c0e1cfc4e8a1dd9be1b275e1d5d63e..5e7e0f07ab6efa94ff41735ff38461de73e7dc9d 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()