You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.2 KiB

  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. find_package(Catch 1.9.3)
  7. if(NOT CATCH_FOUND)
  8. message(STATUS "Catch not detected. Interpreter tests will be skipped. Install Catch headers"
  9. " manually or use `cmake -DDOWNLOAD_CATCH=1` to fetch them automatically.")
  10. return()
  11. endif()
  12. add_executable(test_embed
  13. catch.cpp
  14. test_interpreter.cpp
  15. )
  16. target_include_directories(test_embed PRIVATE ${CATCH_INCLUDE_DIR})
  17. pybind11_enable_warnings(test_embed)
  18. if(NOT CMAKE_VERSION VERSION_LESS 3.0)
  19. target_link_libraries(test_embed PRIVATE pybind11::embed)
  20. else()
  21. target_include_directories(test_embed PRIVATE ${PYBIND11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
  22. target_compile_options(test_embed PRIVATE ${PYBIND11_CPP_STANDARD})
  23. target_link_libraries(test_embed PRIVATE ${PYTHON_LIBRARIES})
  24. endif()
  25. find_package(Threads REQUIRED)
  26. target_link_libraries(test_embed PUBLIC ${CMAKE_THREAD_LIBS_INIT})
  27. add_custom_target(cpptest COMMAND $<TARGET_FILE:test_embed>
  28. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  29. add_dependencies(check cpptest)