From 86efecb93c988119ce4dabbbb38bd3cd095622f9 Mon Sep 17 00:00:00 2001 From: Lei Wang Date: Thu, 31 May 2018 19:15:36 -0700 Subject: [PATCH] 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. --- paddle/contrib/inference/CMakeLists.txt | 37 ++++++++++--------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/paddle/contrib/inference/CMakeLists.txt b/paddle/contrib/inference/CMakeLists.txt index 3beb93c4e7f..6847f7db7fc 100644 --- a/paddle/contrib/inference/CMakeLists.txt +++ b/paddle/contrib/inference/CMakeLists.txt @@ -17,32 +17,21 @@ if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pessimizing-move") endif(APPLE) -function(inference_api_test TARGET_NAME TEST_SRC) +function(inference_api_test TARGET_NAME) set(options "") set(oneValueArgs "") set(multiValueArgs ARGS) cmake_parse_arguments(inference_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) set(PYTHON_TESTS_DIR ${PADDLE_BINARY_DIR}/python/paddle/fluid/tests) - set(arg_list "") + cc_test(test_paddle_inference_${TARGET_NAME} + SRCS test_paddle_inference_${TARGET_NAME}.cc + DEPS paddle_fluid_api paddle_inference_api + ARGS --dirname=${PYTHON_TESTS_DIR}/book/) if(inference_test_ARGS) - foreach(arg ${inference_test_ARGS}) - list(APPEND arg_list "_${arg}") - endforeach() - else() - list(APPEND arg_list "_") + set_tests_properties(test_paddle_inference_${TARGET_NAME} + PROPERTIES DEPENDS "${inference_test_ARGS}") endif() - foreach(arg ${arg_list}) - string(REGEX REPLACE "^_$" "" arg "${arg}") - cc_test(${TARGET_NAME} - SRCS ${TEST_SRC} - DEPS paddle_fluid_api paddle_inference_api - ARGS --dirname=${PYTHON_TESTS_DIR}/book/) - # TODO(panyx0178): Figure out how to add word2vec and image_classification - # as deps. - # set_tests_properties(${TARGET_NAME} - # PROPERTIES DEPENDS ${DEP_TEST}) - endforeach() endfunction(inference_api_test) @@ -50,9 +39,11 @@ cc_library(paddle_inference_api SRCS paddle_inference_api.cc paddle_inference_api_impl.cc DEPS ${FLUID_CORE_MODULES} ${GLOB_OP_LIB}) -cc_test(test_paddle_inference_api - SRCS test_paddle_inference_api.cc - DEPS paddle_inference_api) +if(WITH_TESTING) + cc_test(test_paddle_inference_api + SRCS test_paddle_inference_api.cc + DEPS paddle_inference_api) -inference_api_test(test_paddle_inference_api_impl - test_paddle_inference_api_impl.cc) + inference_api_test(api_impl + ARGS test_word2vec test_image_classification) +endif() -- GitLab