Various CMake improvements #565
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: The changes are best viewed individually because the first commit has a bit of a messy diff.
1. add_subdirectory vs. find_package
The first commit makes sure that these two methods for including pybind11 are 100% interchangeable. This involves adding a
BUILD_INTERFACE
and a namespaced alias for the interface library.Tests are added to ensure this. To avoid quadrupling some files, the directory structure was changed a bit. This yields a messy diff, but the changes are straightforward:
Before:
After:
Renamed
test_install
target totest_cmake_build
because it's now also testing the non-installed subdirectory build.2. pybind11_add_module and docs
See the documentation for this one. Everything about
pybind11_add_module
is pulled into one subsection and some duplicate function explanations are removed from other parts of the text. Same thing for configuration variables: consolidated to one subsection.3. Rename pybind11::pybind11 -> pybind11::module
Embedding the interpreter could use a future target called
pybind11::embedded
, so it might be good to make room for it already. Hence, this proposed rename for the extension module target.cc @loriab
4. make check
Runs all available tests with a common target name to help out packaging as suggested in #442 (comment). Could be expanded with embedded tests in the future. Individual targets remain for selective testing.