Skip to content

Commit 86efecb

Browse files
authored
Build: add dependencies for test_paddle_inference_api_impl. (#11064)
* Build: add test_word2vec test_image_classification as dependencies of test_paddle_inference_api_impl. * Fix build error when WITH_TESTING is OFF.
1 parent 4fb7cc7 commit 86efecb

File tree

1 file changed

+14
-23
lines changed

1 file changed

+14
-23
lines changed

paddle/contrib/inference/CMakeLists.txt

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,33 @@ if(APPLE)
1717
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pessimizing-move")
1818
endif(APPLE)
1919

20-
function(inference_api_test TARGET_NAME TEST_SRC)
20+
function(inference_api_test TARGET_NAME)
2121
set(options "")
2222
set(oneValueArgs "")
2323
set(multiValueArgs ARGS)
2424
cmake_parse_arguments(inference_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
2525

2626
set(PYTHON_TESTS_DIR ${PADDLE_BINARY_DIR}/python/paddle/fluid/tests)
27-
set(arg_list "")
27+
cc_test(test_paddle_inference_${TARGET_NAME}
28+
SRCS test_paddle_inference_${TARGET_NAME}.cc
29+
DEPS paddle_fluid_api paddle_inference_api
30+
ARGS --dirname=${PYTHON_TESTS_DIR}/book/)
2831
if(inference_test_ARGS)
29-
foreach(arg ${inference_test_ARGS})
30-
list(APPEND arg_list "_${arg}")
31-
endforeach()
32-
else()
33-
list(APPEND arg_list "_")
32+
set_tests_properties(test_paddle_inference_${TARGET_NAME}
33+
PROPERTIES DEPENDS "${inference_test_ARGS}")
3434
endif()
35-
foreach(arg ${arg_list})
36-
string(REGEX REPLACE "^_$" "" arg "${arg}")
37-
cc_test(${TARGET_NAME}
38-
SRCS ${TEST_SRC}
39-
DEPS paddle_fluid_api paddle_inference_api
40-
ARGS --dirname=${PYTHON_TESTS_DIR}/book/)
41-
# TODO(panyx0178): Figure out how to add word2vec and image_classification
42-
# as deps.
43-
# set_tests_properties(${TARGET_NAME}
44-
# PROPERTIES DEPENDS ${DEP_TEST})
45-
endforeach()
4635
endfunction(inference_api_test)
4736

4837

4938
cc_library(paddle_inference_api
5039
SRCS paddle_inference_api.cc paddle_inference_api_impl.cc
5140
DEPS ${FLUID_CORE_MODULES} ${GLOB_OP_LIB})
5241

53-
cc_test(test_paddle_inference_api
54-
SRCS test_paddle_inference_api.cc
55-
DEPS paddle_inference_api)
42+
if(WITH_TESTING)
43+
cc_test(test_paddle_inference_api
44+
SRCS test_paddle_inference_api.cc
45+
DEPS paddle_inference_api)
5646

57-
inference_api_test(test_paddle_inference_api_impl
58-
test_paddle_inference_api_impl.cc)
47+
inference_api_test(api_impl
48+
ARGS test_word2vec test_image_classification)
49+
endif()

0 commit comments

Comments
 (0)