CMakeLists.txt 1.34 KB
Newer Older
Baptiste Esteban's avatar
Baptiste Esteban committed
1
# Python module for testing
2
pybind11_add_module(pylena_test pylena_test.cpp)
3
target_link_libraries(pylena_test PRIVATE Pylene Pylene-numpy)
Baptiste Esteban's avatar
Baptiste Esteban committed
4
target_include_directories(pylena_test PRIVATE ${CONAN_INCLUDE_DIRS_PYBIND11} ${PYTHON_INCLUDE_DIRS}) # TO REMOVE WHEN cmake_find_package FOR PYBIND11 WILL BE FIXED
5
add_dependencies(build-tests pylena_test)
6

Baptiste Esteban's avatar
Baptiste Esteban committed
7
8
# Dummy extension for testing
pybind11_add_module(pylena_extension extension_pylena_numpy.cpp)
9
target_link_libraries(pylena_extension PRIVATE Pylene Pylene-numpy)
Baptiste Esteban's avatar
Baptiste Esteban committed
10
target_include_directories(pylena_extension PRIVATE ${CONAN_INCLUDE_DIRS_PYBIND11} ${PYTHON_INCLUDE_DIRS}) # TO REMOVE WHEN cmake_find_package FOR PYBIND11 WILL BE FIXED
11
add_dependencies(build-tests pylena_extension)
Baptiste Esteban's avatar
Baptiste Esteban committed
12

13
# Copy a script to launch ASAN for python extensions
14
15
16
17
18
set(SANITIZE_SCRIPT "")
if (UNIX AND NOT CYGWIN)
    set(SANITIZE_SCRIPT "asan-pylena-test")
    file(COPY ${SANITIZE_SCRIPT} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()
Baptiste Esteban's avatar
Baptiste Esteban committed
19

20
21
22
23
24
25
26
27
function(add_python_test filename)
    file(COPY ${filename} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endfunction(add_python_test)

# PYTHON FILES TO MOVE HERE
add_python_test(test_pylena_numpy.py)

add_test(NAME test_python
28
29
        COMMAND ${SANITIZE_SCRIPT} ${PYTHON_EXECUTABLE} -m unittest discover
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
30
set_tests_properties(test_python PROPERTIES LABELS UnitTests)