@@ -17,42 +17,33 @@ if(APPLE)
17
17
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pessimizing-move" )
18
18
endif (APPLE )
19
19
20
- function (inference_api_test TARGET_NAME TEST_SRC )
20
+ function (inference_api_test TARGET_NAME )
21
21
set (options "" )
22
22
set (oneValueArgs "" )
23
23
set (multiValueArgs ARGS )
24
24
cmake_parse_arguments (inference_test "${options} " "${oneValueArgs} " "${multiValueArgs} " ${ARGN} )
25
25
26
26
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/ )
28
31
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} " )
34
34
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 ()
46
35
endfunction (inference_api_test )
47
36
48
37
49
38
cc_library (paddle_inference_api
50
39
SRCS paddle_inference_api.cc paddle_inference_api_impl.cc
51
40
DEPS ${FLUID_CORE_MODULES} ${GLOB_OP_LIB} )
52
41
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 )
56
46
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