@@ -116,6 +116,20 @@ function(find_fluid_modules TARGET_NAME)
116116 endif ()
117117endfunction (find_fluid_modules)
118118
119+ set_property (GLOBAL PROPERTY PTEN_MODULES "" )
120+ # find all pten modules is used for paddle static library
121+ # for building inference libs
122+ function (find_pten_modules TARGET_NAME)
123+ get_filename_component (__target_path ${TARGET_NAME} ABSOLUTE )
124+ string (REGEX REPLACE "^${PADDLE_SOURCE_DIR} /" "" __target_path ${__target_path} )
125+ string (FIND "${__target_path} " "pten" pos)
126+ if (pos GREATER 1)
127+ get_property (pten_modules GLOBAL PROPERTY PTEN_MODULES)
128+ set (pten_modules ${pten_modules} ${TARGET_NAME} )
129+ set_property (GLOBAL PROPERTY PTEN_MODULES "${pten_modules} " )
130+ endif ()
131+ endfunction (find_pten_modules)
132+
119133function (common_link TARGET_NAME)
120134 if (WITH_PROFILER)
121135 target_link_libraries (${TARGET_NAME} gperftools::profiler)
@@ -310,6 +324,7 @@ function(cc_library TARGET_NAME)
310324 else ()
311325 add_library (${TARGET_NAME} STATIC ${cc_library_SRCS} )
312326 find_fluid_modules(${TARGET_NAME} )
327+ find_pten_modules(${TARGET_NAME} )
313328 endif ()
314329 if (cc_library_DEPS)
315330 # Don't need link libwarpctc.so
@@ -482,6 +497,7 @@ function(nv_library TARGET_NAME)
482497 else ()
483498 add_library (${TARGET_NAME} STATIC ${nv_library_SRCS} )
484499 find_fluid_modules(${TARGET_NAME} )
500+ find_pten_modules(${TARGET_NAME} )
485501 endif ()
486502 if (nv_library_DEPS)
487503 add_dependencies (${TARGET_NAME} ${nv_library_DEPS} )
@@ -572,6 +588,7 @@ function(hip_library TARGET_NAME)
572588 else ()
573589 hip_add_library(${TARGET_NAME} STATIC ${hip_library_SRCS} )
574590 find_fluid_modules(${TARGET_NAME} )
591+ find_pten_modules(${TARGET_NAME} )
575592 endif ()
576593 if (hip_library_DEPS)
577594 add_dependencies (${TARGET_NAME} ${hip_library_DEPS} )
0 commit comments