forked from luxonis/depthai-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
36 lines (29 loc) · 1.14 KB
/
CMakeLists.txt
File metadata and controls
36 lines (29 loc) · 1.14 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
set(TARGET_TEST_MODULE "depthai_pybind11_tests")
# Specify path separator
set(SYS_PATH_SEPARATOR ";")
if(UNIX)
set(SYS_PATH_SEPARATOR ":")
endif()
set(PYBIND11_TEST_FILES
"xlink_exceptions_test.cpp"
)
string(REPLACE ".cpp" ".py" PYBIND11_PYTEST_FILES "${PYBIND11_TEST_FILES}")
# Create the binding library at the end
pybind11_add_module(${TARGET_TEST_MODULE} THIN_LTO ${TARGET_TEST_MODULE}.cpp ${PYBIND11_TEST_FILES})
# A single command to compile and run the tests
add_custom_target(
pytest COMMAND
${CMAKE_COMMAND} -E env
# Python path (to find compiled modules)
"PYTHONPATH=$<TARGET_FILE_DIR:${TARGET_NAME}>${SYS_PATH_SEPARATOR}$<TARGET_FILE_DIR:${TARGET_TEST_MODULE}>${SYS_PATH_SEPARATOR}$ENV{PYTHONPATH}"
# ASAN in case of sanitizers
${ASAN_ENVIRONMENT_VARS}
${PYTHON_EXECUTABLE} -m pytest ${PYBIND11_PYTEST_FILES}
DEPENDS
${TARGET_TEST_MODULE} # Compiled tests
${TARGET_NAME} # DepthAI Python Library
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}"
USES_TERMINAL
)
# Link to depthai
target_link_libraries(${TARGET_TEST_MODULE} PRIVATE pybind11::pybind11 depthai::core)