CMakeLists.txt 1.4 KB
Newer Older
X
Xin Pan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
function(train_test TARGET_NAME)
    set(options "")
    set(oneValueArgs "")
    set(multiValueArgs ARGS)
    cmake_parse_arguments(train_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

    set(arg_list "")
    if(train_test_ARGS)
        foreach(arg ${train_test_ARGS})
            list(APPEND arg_list "_${arg}")
        endforeach()
    else()
        list(APPEND arg_list "_")
    endif()
    foreach(arg ${arg_list})
        string(REGEX REPLACE "^_$" "" arg "${arg}")
17 18 19 20 21 22 23 24 25 26 27
        if (NOT APPLE AND NOT WIN32)
            cc_test(test_train_${TARGET_NAME}${arg}
                    SRCS test_train_${TARGET_NAME}.cc
                    DEPS paddle_fluid_shared
                    ARGS --dirname=${PYTHON_TESTS_DIR}/book/${TARGET_NAME}${arg}.train.model/)
        else()
            cc_test(test_train_${TARGET_NAME}${arg}
                    SRCS test_train_${TARGET_NAME}.cc
                    DEPS paddle_fluid_api
                    ARGS --dirname=${PYTHON_TESTS_DIR}/book/${TARGET_NAME}${arg}.train.model/)
        endif()
X
Xin Pan 已提交
28
        set_tests_properties(test_train_${TARGET_NAME}${arg}
29
                PROPERTIES FIXTURES_REQUIRED test_${TARGET_NAME}_infer_model)
30 31 32 33
        if(NOT WIN32 AND NOT APPLE)
            set_tests_properties(test_train_${TARGET_NAME}${arg}
                    PROPERTIES TIMEOUT 150)
        endif()
X
Xin Pan 已提交
34 35 36 37
    endforeach()
endfunction(train_test)


X
Xin Pan 已提交
38 39 40
if(WITH_TESTING)
  train_test(recognize_digits ARGS mlp conv)
endif()