Skip to content

Commit b29745e

Browse files
committed
fix compile bug
1 parent 5bdf2fb commit b29745e

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

cmake/cinn/core.cmake

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ function(cinn_cc_test TARGET_NAME)
7373
add_executable(${TARGET_NAME} ${cinn_cc_test_SRCS})
7474
get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES)
7575
target_link_libraries(${TARGET_NAME} ${os_dependency_modules}
76-
cinn_gtest_main gtest glog ${cinn_cc_test_DEPS})
77-
add_dependencies(${TARGET_NAME} cinn_gtest_main gtest glog
76+
paddle_gtest_main gtest glog ${cinn_cc_test_DEPS})
77+
if(WITH_SHARED_PHI)
78+
target_link_libraries(${TARGET_NAME} -Wl,--as-needed phi_core phi_gpu
79+
-Wl,--no-as-needed)
80+
endif()
81+
add_dependencies(${TARGET_NAME} paddle_gtest_main gtest glog
7882
${cinn_cc_test_DEPS})
7983

8084
add_test(
@@ -159,13 +163,18 @@ function(cinn_nv_test TARGET_NAME)
159163
target_link_libraries(
160164
${TARGET_NAME}
161165
${cinn_nv_test_DEPS}
162-
cinn_gtest_main
166+
paddle_gtest_main
163167
gtest
164168
${os_dependency_modules}
165169
${CUDNN_LIBRARY}
166170
${CUBLAS_LIBRARIES}
167171
${CUDA_LIBRARIES})
168-
add_dependencies(${TARGET_NAME} ${cinn_nv_test_DEPS} cinn_gtest_main gtest)
172+
if(WITH_SHARED_PHI)
173+
target_link_libraries(${TARGET_NAME} -Wl,--as-needed phi_core phi_gpu
174+
-Wl,--no-as-needed)
175+
endif()
176+
add_dependencies(${TARGET_NAME} ${cinn_nv_test_DEPS} paddlec_gtest_main
177+
gtest)
169178
common_link(${TARGET_NAME})
170179
add_test(
171180
NAME ${TARGET_NAME}

cmake/generic.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,9 @@ function(paddle_test_build TARGET_NAME)
599599
target_link_libraries(${TARGET_NAME} ${PYTHON_LIBRARIES})
600600
endif()
601601
if(WITH_CINN)
602-
target_link_libraries(${TARGET_NAME} $<TARGET_LINKER_FILE:cinnapi>
603-
cinn_transforms)
602+
target_link_libraries(${TARGET_NAME} -Wl,--as-needed cinnapi
603+
-Wl,--no-as-needed)
604+
target_link_libraries(${TARGET_NAME} cinn_transforms)
604605
add_dependencies(${TARGET_NAME} cinnapi)
605606
endif()
606607
if(WITH_XPU)

0 commit comments

Comments
 (0)