Dean Moldovan | 9693a5c | 2017-03-23 17:27:32 +0100 | [diff] [blame] | 1 | if(${PYTHON_MODULE_EXTENSION} MATCHES "pypy") |
| 2 | add_custom_target(cpptest) # Dummy target on PyPy. Embedding is not supported. |
| 3 | set(_suppress_unused_variable_warning "${DOWNLOAD_CATCH}") |
| 4 | return() |
| 5 | endif() |
| 6 | |
| 7 | find_package(Catch 1.9.3) |
| 8 | if(NOT CATCH_FOUND) |
| 9 | message(STATUS "Catch not detected. Interpreter tests will be skipped. Install Catch headers" |
| 10 | " manually or use `cmake -DDOWNLOAD_CATCH=1` to fetch them automatically.") |
| 11 | return() |
| 12 | endif() |
| 13 | |
| 14 | add_executable(test_embed |
| 15 | catch.cpp |
| 16 | test_interpreter.cpp |
| 17 | ) |
| 18 | target_include_directories(test_embed PRIVATE ${CATCH_INCLUDE_DIR}) |
| 19 | pybind11_enable_warnings(test_embed) |
| 20 | |
| 21 | if(NOT CMAKE_VERSION VERSION_LESS 3.0) |
| 22 | target_link_libraries(test_embed PRIVATE pybind11::embed) |
| 23 | else() |
| 24 | target_include_directories(test_embed PRIVATE ${PYBIND11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS}) |
| 25 | target_compile_options(test_embed PRIVATE ${PYBIND11_CPP_STANDARD}) |
| 26 | target_link_libraries(test_embed PRIVATE ${PYTHON_LIBRARIES}) |
| 27 | endif() |
| 28 | |
| 29 | add_custom_target(cpptest COMMAND $<TARGET_FILE:test_embed> |
| 30 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 31 | add_dependencies(check cpptest) |