Duplicate symbol in op_library (operator/reader, operator/detection)
Created by: carlushuang
https://github.com/PaddlePaddle/Paddle/pull/14413
@typhoonzero @luotao1
I found out an symbol duplication issue in ob_library cmake system due to above PR. All operators are registered in OP_LIBRARY value in cmake, and when you call op_library() function, it will automatically insert to OP_LIBRARY list as defined in cmake/operators.cmake.
function(op_library TARGET)
...
set(OP_LIBRARY ${TARGET} ${OP_LIBRARY} CACHE INTERNAL "op libs")
...
endfunction()
However, in operators/reader/CMakeLists.txt and operators/detection/CMakeLists.txt, they all do a manually register in OP_LIBRARY
# in operators/detection/CMakeLists.txt
foreach(src ${LOCAL_DETECTION_LIBS})
set(OP_LIBRARY ${src} ${OP_LIBRARY} CACHE INTERNAL "op libs")
endforeach()
Hence, operators in reader and detection may registered twice in OP_LIBRARY list, and result in link twice the static library.
Maybe the manual register in operators/detection/CMakeLists.txt and operators/reader/CMakeLists.txt may removed?