feat: new FindPython support (#2370)

* feat: FindPython support

* refactor: rename to PYBIND11_FINDPYTHON

* docs: Caps fixes

* feat: NOPYTHON mode

* test: check simple call

* docs: add changelog/upgrade guide

* feat: Support Python3 and Python2

* refactor: Use targets in tests

* fix: support CMake 3.4+

* feat: classic search also finds virtual environments

* docs: some updates from @wjakob's review

* fix: wrong name for QUIET mode variable, reported by @skoslowski

* refactor: cleaner output messaging

* fix: support debug Python's in FindPython mode too

* fixup! refactor: cleaner output messaging

* fix: missing pybind11_FOUND and pybind11_INCLUDE_DIR restored to subdir mode

* fix: nicer reporting of Python / PyPy

* fix: out-of-order variable fix

* docs: minor last-minute cleanup
This commit is contained in:
Henry Schreiner
2020-08-19 12:26:26 -04:00
committed by GitHub
parent 69821d9e75
commit 1729aae96f
24 changed files with 1117 additions and 395 deletions

View File

@@ -1,10 +1,11 @@
if(${PYTHON_MODULE_EXTENSION} MATCHES "pypy")
if("${PYTHON_MODULE_EXTENSION}" MATCHES "pypy" OR "${Python_INTERPRETER_ID}" STREQUAL "PyPy")
add_custom_target(cpptest) # Dummy target on PyPy. Embedding is not supported.
set(_suppress_unused_variable_warning "${DOWNLOAD_CATCH}")
return()
endif()
find_package(Catch 2.13.0)
if(CATCH_FOUND)
message(STATUS "Building interpreter tests using Catch v${CATCH_VERSION}")
else()
@@ -13,14 +14,12 @@ else()
return()
endif()
find_package(Threads REQUIRED)
add_executable(test_embed catch.cpp test_interpreter.cpp)
target_include_directories(test_embed SYSTEM PRIVATE "${CATCH_INCLUDE_DIR}")
pybind11_enable_warnings(test_embed)
target_link_libraries(test_embed PRIVATE pybind11::embed)
find_package(Threads REQUIRED)
target_link_libraries(test_embed PUBLIC Threads::Threads)
target_link_libraries(test_embed PRIVATE pybind11::embed Catch2::Catch2 Threads::Threads)
add_custom_target(
cpptest