-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.cmake
More file actions
42 lines (41 loc) · 1.87 KB
/
build.cmake
File metadata and controls
42 lines (41 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function(
create_paddle_tests
BIN_PREFIX
TEST_SRC_FILES
TARGET_FOLDER
DEPS_LIBRARIES
INCLUDE_DIR
USE_PADDLE_API)
# Optional named-keyword args (parsed after positional arg USE_PADDLE_API):
# EXTRA_DEFS -- extra compile definitions (e.g. PADDLE_WITH_CUDA) EXTRA_INCS
# -- extra include directories
cmake_parse_arguments(PARSE_ARGV 6 _CPT "" "" "EXTRA_DEFS;EXTRA_INCS")
foreach(_test_file ${TEST_SRC_FILES})
get_filename_component(_file_name ${_test_file} NAME_WE)
set(_test_name ${BIN_PREFIX}${_file_name})
add_executable(${_test_name} ${_test_file} ${TEST_BASE_FILES}
${PROJECT_SOURCE_DIR}/src/file_manager.cpp)
add_dependencies(${_test_name} "googletest.git")
target_link_libraries(
${_test_name} gtest gtest_main ${CMAKE_THREAD_LIBS_INIT}
${DEPS_LIBRARIES} ${Python3_LIBRARIES})
target_include_directories(${_test_name} PRIVATE ${Python3_INCLUDE_DIRS})
target_include_directories(${_test_name} PRIVATE ${INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/src)
target_include_directories(${_test_name} PRIVATE ${PROJECT_SOURCE_DIR}/src)
message(STATUS "include dir: ${INCLUDE_DIR}")
target_compile_definitions(${_test_name}
PRIVATE USE_PADDLE_API=${USE_PADDLE_API})
if(_CPT_EXTRA_DEFS)
target_compile_definitions(${_test_name} PRIVATE ${_CPT_EXTRA_DEFS})
endif()
if(_CPT_EXTRA_INCS)
target_include_directories(${_test_name} PRIVATE ${_CPT_EXTRA_INCS})
endif()
message(STATUS "USE_PADDLE_API: ${USE_PADDLE_API}")
add_test(NAME ${_test_name} COMMAND ${_test_name})
set_tests_properties(${_test_name} PROPERTIES TIMEOUT 5)
set_target_properties(${_test_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY
"${TARGET_FOLDER}")
endforeach()
endfunction()