blob: 6e255c5b132aed8fc60d6e41bbb3395ddf207ae9 (
plain)
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
|
set(EXAMPLES_API_PYTHON
exceptions
)
find_package(PythonInterp REQUIRED)
# Find Python bindings in the corresponding python-*/site-packages directory.
# Lookup Python module directory and store path in PYTHON_MODULE_PATH.
execute_process(COMMAND
${PYTHON_EXECUTABLE} -c
"from distutils.sysconfig import get_python_lib;\
print(get_python_lib(plat_specific=True,\
prefix='${CMAKE_PREFIX_PATH}/../..'))"
OUTPUT_VARIABLE PYTHON_MODULE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
foreach(example ${EXAMPLES_API_PYTHON})
set(example_test example/api/python/${example})
add_test(
NAME ${example_test}
COMMAND
"${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/api/python/${example}.py"
)
set_tests_properties(${example_test} PROPERTIES
LABELS "example"
ENVIRONMENT PYTHONPATH=${PYTHON_MODULE_PATH})
endforeach()
|