2016-08-12 11:50:00 +00:00
|
|
|
# CMakeLists.txt -- Build system for the pybind11 modules
|
2015-07-05 18:05:44 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch>
|
|
|
|
#
|
|
|
|
# All rights reserved. Use of this source code is governed by a
|
|
|
|
# BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
2020-08-19 16:26:26 +00:00
|
|
|
cmake_minimum_required(VERSION 3.4)
|
2015-07-05 18:05:44 +00:00
|
|
|
|
2021-10-26 18:50:34 +00:00
|
|
|
# The `cmake_minimum_required(VERSION 3.4...3.22)` syntax does not work with
|
2020-08-01 02:45:19 +00:00
|
|
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
|
|
|
# the behavior using the following workaround:
|
2021-10-26 18:50:34 +00:00
|
|
|
if(${CMAKE_VERSION} VERSION_LESS 3.22)
|
2020-07-30 20:20:10 +00:00
|
|
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
2017-08-30 12:17:54 +00:00
|
|
|
else()
|
2021-10-26 18:50:34 +00:00
|
|
|
cmake_policy(VERSION 3.22)
|
2017-08-30 12:17:54 +00:00
|
|
|
endif()
|
2015-07-05 18:05:44 +00:00
|
|
|
|
2021-11-18 15:01:24 +00:00
|
|
|
# Avoid infinite recursion if tests include this as a subdirectory
|
|
|
|
if(DEFINED PYBIND11_MASTER_PROJECT)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2020-07-28 04:43:12 +00:00
|
|
|
# Extract project version from source
|
2020-07-30 20:20:10 +00:00
|
|
|
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/pybind11/detail/common.h"
|
|
|
|
pybind11_version_defines REGEX "#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) ")
|
2020-07-28 04:43:12 +00:00
|
|
|
|
|
|
|
foreach(ver ${pybind11_version_defines})
|
2020-07-30 20:20:10 +00:00
|
|
|
if(ver MATCHES [[#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$]])
|
|
|
|
set(PYBIND11_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}")
|
|
|
|
endif()
|
2020-07-28 04:43:12 +00:00
|
|
|
endforeach()
|
|
|
|
|
2020-09-16 21:13:41 +00:00
|
|
|
if(PYBIND11_VERSION_PATCH MATCHES [[\.([a-zA-Z0-9]+)$]])
|
2020-08-01 02:45:19 +00:00
|
|
|
set(pybind11_VERSION_TYPE "${CMAKE_MATCH_1}")
|
2020-07-30 20:04:26 +00:00
|
|
|
endif()
|
2020-09-16 21:13:41 +00:00
|
|
|
string(REGEX MATCH "^[0-9]+" PYBIND11_VERSION_PATCH "${PYBIND11_VERSION_PATCH}")
|
2020-07-30 20:04:26 +00:00
|
|
|
|
2020-07-28 04:43:12 +00:00
|
|
|
project(
|
2020-07-30 20:20:10 +00:00
|
|
|
pybind11
|
|
|
|
LANGUAGES CXX
|
|
|
|
VERSION "${PYBIND11_VERSION_MAJOR}.${PYBIND11_VERSION_MINOR}.${PYBIND11_VERSION_PATCH}")
|
2020-07-28 04:43:12 +00:00
|
|
|
|
|
|
|
# Standard includes
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
include(CMakeDependentOption)
|
|
|
|
|
2020-08-19 16:26:26 +00:00
|
|
|
if(NOT pybind11_FIND_QUIETLY)
|
|
|
|
message(STATUS "pybind11 v${pybind11_VERSION} ${pybind11_VERSION_TYPE}")
|
|
|
|
endif()
|
2020-07-30 20:04:26 +00:00
|
|
|
|
2016-05-22 22:12:37 +00:00
|
|
|
# Check if pybind11 is being used directly or via add_subdirectory
|
2021-11-18 15:01:24 +00:00
|
|
|
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
2020-08-19 17:11:57 +00:00
|
|
|
### Warn if not an out-of-source builds
|
|
|
|
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
|
|
|
set(lines
|
|
|
|
"You are building in-place. If that is not what you intended to "
|
|
|
|
"do, you can clean the source directory with:\n"
|
|
|
|
"rm -r CMakeCache.txt CMakeFiles/ cmake_uninstall.cmake pybind11Config.cmake "
|
|
|
|
"pybind11ConfigVersion.cmake tests/CMakeFiles/\n")
|
|
|
|
message(AUTHOR_WARNING ${lines})
|
|
|
|
endif()
|
|
|
|
|
2020-07-30 20:20:10 +00:00
|
|
|
set(PYBIND11_MASTER_PROJECT ON)
|
2020-08-19 16:26:26 +00:00
|
|
|
|
|
|
|
if(OSX AND CMAKE_VERSION VERSION_LESS 3.7)
|
|
|
|
# Bug in macOS CMake < 3.7 is unable to download catch
|
|
|
|
message(WARNING "CMAKE 3.7+ needed on macOS to download catch, and newer HIGHLY recommended")
|
|
|
|
elseif(WINDOWS AND CMAKE_VERSION VERSION_LESS 3.8)
|
|
|
|
# Only tested with 3.8+ in CI.
|
|
|
|
message(WARNING "CMAKE 3.8+ tested on Windows, previous versions untested")
|
|
|
|
endif()
|
|
|
|
|
2020-07-30 20:20:10 +00:00
|
|
|
message(STATUS "CMake ${CMAKE_VERSION}")
|
2020-07-28 04:43:12 +00:00
|
|
|
|
2020-07-30 20:20:10 +00:00
|
|
|
if(CMAKE_CXX_STANDARD)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
2021-01-19 23:48:22 +00:00
|
|
|
|
|
|
|
set(pybind11_system "")
|
2021-11-18 15:01:24 +00:00
|
|
|
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
2020-07-28 04:43:12 +00:00
|
|
|
else()
|
2020-07-30 20:20:10 +00:00
|
|
|
set(PYBIND11_MASTER_PROJECT OFF)
|
|
|
|
set(pybind11_system SYSTEM)
|
2016-05-29 10:35:16 +00:00
|
|
|
endif()
|
2016-05-22 22:12:37 +00:00
|
|
|
|
2020-08-01 02:45:19 +00:00
|
|
|
# Options
|
2016-05-26 20:53:38 +00:00
|
|
|
option(PYBIND11_INSTALL "Install pybind11 header files?" ${PYBIND11_MASTER_PROJECT})
|
2020-07-28 04:43:12 +00:00
|
|
|
option(PYBIND11_TEST "Build pybind11 test suite?" ${PYBIND11_MASTER_PROJECT})
|
2020-08-19 16:26:26 +00:00
|
|
|
option(PYBIND11_NOPYTHON "Disable search for Python" OFF)
|
2021-09-20 11:57:38 +00:00
|
|
|
set(PYBIND11_INTERNALS_VERSION
|
|
|
|
""
|
|
|
|
CACHE STRING "Override the ABI version, may be used to enable the unstable ABI.")
|
2020-08-01 02:45:19 +00:00
|
|
|
|
2020-07-28 04:43:12 +00:00
|
|
|
cmake_dependent_option(
|
2020-07-30 20:20:10 +00:00
|
|
|
USE_PYTHON_INCLUDE_DIR
|
|
|
|
"Install pybind11 headers in Python include directory instead of default installation prefix"
|
|
|
|
OFF "PYBIND11_INSTALL" OFF)
|
2020-07-28 04:43:12 +00:00
|
|
|
|
2020-08-19 16:26:26 +00:00
|
|
|
cmake_dependent_option(PYBIND11_FINDPYTHON "Force new FindPython" OFF
|
|
|
|
"NOT CMAKE_VERSION VERSION_LESS 3.12" OFF)
|
|
|
|
|
2020-07-28 04:43:12 +00:00
|
|
|
# NB: when adding a header don't forget to also add it to setup.py
|
|
|
|
set(PYBIND11_HEADERS
|
|
|
|
include/pybind11/detail/class.h
|
|
|
|
include/pybind11/detail/common.h
|
|
|
|
include/pybind11/detail/descr.h
|
|
|
|
include/pybind11/detail/init.h
|
|
|
|
include/pybind11/detail/internals.h
|
2021-02-23 02:38:18 +00:00
|
|
|
include/pybind11/detail/type_caster_base.h
|
2020-07-28 04:43:12 +00:00
|
|
|
include/pybind11/detail/typeid.h
|
|
|
|
include/pybind11/attr.h
|
|
|
|
include/pybind11/buffer_info.h
|
|
|
|
include/pybind11/cast.h
|
|
|
|
include/pybind11/chrono.h
|
|
|
|
include/pybind11/common.h
|
|
|
|
include/pybind11/complex.h
|
|
|
|
include/pybind11/options.h
|
|
|
|
include/pybind11/eigen.h
|
First draft of Eigen::Tensor support (#4201)
* First draft of Eigen::Tensor support
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix build errors
* Weird allocator stuff?
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Remove unused + additional allocator junk
* Disable warning
* Use constexpr
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* clang tidy fixes
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Resolve comments
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Remove auto constexpr function
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Try again for older C++
* Oops forgot constexpr
* Move to new files as suggested
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix weird tests
* Fix nits
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Oops, forgot import
* Fix clang 3.6 bug
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* More comprehensive test suite
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Refactor allocators to make things more clear
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Switch to std::copy
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Switch to DSizes instead of array
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Address feedback
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix python + dummy c++ change to trigger build
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Alignment
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add include guard
* Forgot inline
* Fix compiler warning
* Remove bad test
* Better type signatures
* Add guards to make compiler requirements more explicit
* style: pre-commit fixes
* Force rerun of tests due to flake
* style: pre-commit fixes
* Keep pragmas & all related comments together, add PLEASE KEEP IN SYNC
* Move headers out of detail
* style: pre-commit fixes
* Fix cmake
* Improve casting
* style: pre-commit fixes
* Add a ton more tests + refactor
* Improve names
* style: pre-commit fixes
* Update include/pybind11/eigen/tensor.h
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
* Fix tests
* style: pre-commit fixes
* Update
* Add a test to verify that strange numpy arrays work
* Fix dumb compiler warning
* Better tests
* Better tests
* Fix tests
* style: pre-commit fixes
* More test fixes
* style: pre-commit fixes
* A ton more test coverage
* Fix tests
* style: pre-commit fixes
* style: pre-commit fixes
* Add back constexpr
* Another test
* style: pre-commit fixes
* Improve tests
* Whoops
* Less magic numbers
* Update tests/test_eigen_tensor.py
Co-authored-by: Sergiu Deitsch <sergiud@users.noreply.github.com>
* Update tests/test_eigen_tensor.py
Co-authored-by: Sergiu Deitsch <sergiud@users.noreply.github.com>
* style: pre-commit fixes
* Fix tests
* style: pre-commit fixes
* Fix memory leak
* style: pre-commit fixes
* Fix order
* style: pre-commit fixes
* Add test to make sure unsafe casts fail
* Minor bug fix to work on 32 bit machines
* Implement convert flag
* style: pre-commit fixes
* Switch to correct TensorMap const use
* style: pre-commit fixes
* Support older versions of eigen
* Weird c++ compilers
* Fix Eigen bug
* Fix another eigen bug
* Yet another eigen bug
* Potential flakes?
* style: pre-commit fixes
* Rerun tests with dummy exception to find out what is going on
* Another dummy test run
* Ablate more
* Found the broken test?
* One step closer
* one step further
* Double check
* one thing at a time
* Give up and disable the test
* Clang lies about being gcc
* Oops, fix matrix test
* style: pre-commit fixes
* Add tests to verify scalar conversions
* style: pre-commit fixes
* Fix nits
* Support no_array
* Fix tests
* style: pre-commit fixes
* Silence compiler warning
* Improve build system for ancient compilers
* Make clang happy
* Make gcc happy
* Implement Skylion's suggestions
* Fix warning
* Inline const pointer check
* Implement suggestions
* style: pre-commit fixes
* Improve tests
* Typo
* style: pre-commit fixes
* Support Google's build environment
* style: pre-commit fixes
* Update include/pybind11/eigen/tensor.h
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
* style: pre-commit fixes
* Test cleanup per Skylion
* Switch to remvove_cv_t
* Cleaner test
* style: pre-commit fixes
* Remove tensor from eigen.h, update tests
* style: pre-commit fixes
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: Sergiu Deitsch <sergiud@users.noreply.github.com>
2022-10-18 23:54:16 +00:00
|
|
|
include/pybind11/eigen/matrix.h
|
|
|
|
include/pybind11/eigen/tensor.h
|
2020-07-28 04:43:12 +00:00
|
|
|
include/pybind11/embed.h
|
|
|
|
include/pybind11/eval.h
|
2021-02-23 03:15:40 +00:00
|
|
|
include/pybind11/gil.h
|
2020-08-01 19:24:30 +00:00
|
|
|
include/pybind11/iostream.h
|
2020-07-28 04:43:12 +00:00
|
|
|
include/pybind11/functional.h
|
|
|
|
include/pybind11/numpy.h
|
|
|
|
include/pybind11/operators.h
|
|
|
|
include/pybind11/pybind11.h
|
|
|
|
include/pybind11/pytypes.h
|
|
|
|
include/pybind11/stl.h
|
2021-07-08 16:02:48 +00:00
|
|
|
include/pybind11/stl_bind.h
|
|
|
|
include/pybind11/stl/filesystem.h)
|
2020-07-30 20:04:26 +00:00
|
|
|
|
2020-08-01 19:24:30 +00:00
|
|
|
# Compare with grep and warn if mismatched
|
|
|
|
if(PYBIND11_MASTER_PROJECT AND NOT CMAKE_VERSION VERSION_LESS 3.12)
|
|
|
|
file(
|
|
|
|
GLOB_RECURSE _pybind11_header_check
|
|
|
|
LIST_DIRECTORIES false
|
|
|
|
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
CONFIGURE_DEPENDS "include/pybind11/*.h")
|
|
|
|
set(_pybind11_here_only ${PYBIND11_HEADERS})
|
|
|
|
set(_pybind11_disk_only ${_pybind11_header_check})
|
|
|
|
list(REMOVE_ITEM _pybind11_here_only ${_pybind11_header_check})
|
|
|
|
list(REMOVE_ITEM _pybind11_disk_only ${PYBIND11_HEADERS})
|
|
|
|
if(_pybind11_here_only)
|
|
|
|
message(AUTHOR_WARNING "PYBIND11_HEADERS has extra files:" ${_pybind11_here_only})
|
|
|
|
endif()
|
|
|
|
if(_pybind11_disk_only)
|
|
|
|
message(AUTHOR_WARNING "PYBIND11_HEADERS is missing files:" ${_pybind11_disk_only})
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-07-30 20:04:26 +00:00
|
|
|
|
2020-08-01 19:24:30 +00:00
|
|
|
# CMake 3.12 added list(TRANSFORM <list> PREPEND
|
2020-07-28 04:43:12 +00:00
|
|
|
# But we can't use it yet
|
2020-07-30 20:20:10 +00:00
|
|
|
string(REPLACE "include/" "${CMAKE_CURRENT_SOURCE_DIR}/include/" PYBIND11_HEADERS
|
|
|
|
"${PYBIND11_HEADERS}")
|
2016-05-28 09:08:16 +00:00
|
|
|
|
2020-11-03 01:45:54 +00:00
|
|
|
# Cache variable so this can be used in parent projects
|
|
|
|
set(pybind11_INCLUDE_DIR
|
2020-07-30 20:20:10 +00:00
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/include"
|
2020-11-03 01:45:54 +00:00
|
|
|
CACHE INTERNAL "Directory where pybind11 headers are located")
|
|
|
|
|
|
|
|
# Backward compatible variable for add_subdirectory mode
|
|
|
|
if(NOT PYBIND11_MASTER_PROJECT)
|
|
|
|
set(PYBIND11_INCLUDE_DIR
|
|
|
|
"${pybind11_INCLUDE_DIR}"
|
|
|
|
CACHE INTERNAL "")
|
|
|
|
endif()
|
2017-02-14 12:16:14 +00:00
|
|
|
|
2020-07-28 04:43:12 +00:00
|
|
|
# Note: when creating targets, you cannot use if statements at configure time -
|
|
|
|
# you need generator expressions, because those will be placed in the target file.
|
2020-07-30 20:04:26 +00:00
|
|
|
# You can also place ifs *in* the Config.in, but not here.
|
2020-07-28 04:43:12 +00:00
|
|
|
|
2020-08-19 16:26:26 +00:00
|
|
|
# This section builds targets, but does *not* touch Python
|
2021-01-19 23:49:03 +00:00
|
|
|
# Non-IMPORT targets cannot be defined twice
|
|
|
|
if(NOT TARGET pybind11_headers)
|
|
|
|
# Build the headers-only target (no Python included):
|
|
|
|
# (long name used here to keep this from clashing in subdirectory mode)
|
|
|
|
add_library(pybind11_headers INTERFACE)
|
|
|
|
add_library(pybind11::pybind11_headers ALIAS pybind11_headers) # to match exported target
|
|
|
|
add_library(pybind11::headers ALIAS pybind11_headers) # easier to use/remember
|
|
|
|
|
|
|
|
target_include_directories(
|
|
|
|
pybind11_headers ${pybind11_system} INTERFACE $<BUILD_INTERFACE:${pybind11_INCLUDE_DIR}>
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
|
|
|
|
|
|
|
target_compile_features(pybind11_headers INTERFACE cxx_inheriting_constructors cxx_user_literals
|
|
|
|
cxx_right_angle_brackets)
|
2021-09-20 11:57:38 +00:00
|
|
|
if(NOT "${PYBIND11_INTERNALS_VERSION}" STREQUAL "")
|
|
|
|
target_compile_definitions(
|
|
|
|
pybind11_headers INTERFACE "PYBIND11_INTERNALS_VERSION=${PYBIND11_INTERNALS_VERSION}")
|
|
|
|
endif()
|
2021-01-19 23:49:03 +00:00
|
|
|
else()
|
|
|
|
# It is invalid to install a target twice, too.
|
|
|
|
set(PYBIND11_INSTALL OFF)
|
|
|
|
endif()
|
2020-07-28 04:43:12 +00:00
|
|
|
|
2020-08-19 16:26:26 +00:00
|
|
|
include("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11Common.cmake")
|
2022-08-09 04:02:45 +00:00
|
|
|
# https://github.com/jtojnar/cmake-snips/#concatenating-paths-when-building-pkg-config-files
|
|
|
|
# TODO: cmake 3.20 adds the cmake_path() function, which obsoletes this snippet
|
|
|
|
include("${CMAKE_CURRENT_SOURCE_DIR}/tools/JoinPaths.cmake")
|
2020-07-28 04:43:12 +00:00
|
|
|
|
2020-08-19 16:26:26 +00:00
|
|
|
# Relative directory setting
|
|
|
|
if(USE_PYTHON_INCLUDE_DIR AND DEFINED Python_INCLUDE_DIRS)
|
|
|
|
file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${Python_INCLUDE_DIRS})
|
|
|
|
elseif(USE_PYTHON_INCLUDE_DIR AND DEFINED PYTHON_INCLUDE_DIR)
|
|
|
|
file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_INCLUDE_DIRS})
|
2016-12-13 15:55:38 +00:00
|
|
|
endif()
|
|
|
|
|
2020-07-28 04:43:12 +00:00
|
|
|
if(PYBIND11_INSTALL)
|
2020-11-03 01:45:54 +00:00
|
|
|
install(DIRECTORY ${pybind11_INCLUDE_DIR}/pybind11 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2020-07-30 20:20:10 +00:00
|
|
|
set(PYBIND11_CMAKECONFIG_INSTALL_DIR
|
2020-10-13 17:08:54 +00:00
|
|
|
"${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}"
|
2020-07-30 20:20:10 +00:00
|
|
|
CACHE STRING "install path for pybind11Config.cmake")
|
|
|
|
|
2021-07-27 21:23:52 +00:00
|
|
|
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
|
|
set(pybind11_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
|
|
|
|
else()
|
|
|
|
set(pybind11_INCLUDEDIR "\$\{PACKAGE_PREFIX_DIR\}/${CMAKE_INSTALL_INCLUDEDIR}")
|
|
|
|
endif()
|
|
|
|
|
2020-07-30 20:20:10 +00:00
|
|
|
configure_package_config_file(
|
|
|
|
tools/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
|
|
|
INSTALL_DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
|
|
|
|
|
|
|
|
if(CMAKE_VERSION VERSION_LESS 3.14)
|
|
|
|
# Remove CMAKE_SIZEOF_VOID_P from ConfigVersion.cmake since the library does
|
|
|
|
# not depend on architecture specific settings or libraries.
|
|
|
|
set(_PYBIND11_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
|
|
|
|
unset(CMAKE_SIZEOF_VOID_P)
|
|
|
|
|
|
|
|
write_basic_package_version_file(
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
|
|
|
VERSION ${PROJECT_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion)
|
|
|
|
|
|
|
|
set(CMAKE_SIZEOF_VOID_P ${_PYBIND11_CMAKE_SIZEOF_VOID_P})
|
|
|
|
else()
|
|
|
|
# CMake 3.14+ natively supports header-only libraries
|
|
|
|
write_basic_package_version_file(
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
|
|
|
VERSION ${PROJECT_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion ARCH_INDEPENDENT)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
install(
|
|
|
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
2020-08-19 16:26:26 +00:00
|
|
|
tools/FindPythonLibsNew.cmake
|
|
|
|
tools/pybind11Common.cmake
|
|
|
|
tools/pybind11Tools.cmake
|
|
|
|
tools/pybind11NewTools.cmake
|
2020-07-30 20:20:10 +00:00
|
|
|
DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
|
|
|
|
|
|
|
|
if(NOT PYBIND11_EXPORT_NAME)
|
|
|
|
set(PYBIND11_EXPORT_NAME "${PROJECT_NAME}Targets")
|
|
|
|
endif()
|
|
|
|
|
2020-08-22 13:06:01 +00:00
|
|
|
install(TARGETS pybind11_headers EXPORT "${PYBIND11_EXPORT_NAME}")
|
2020-07-30 20:20:10 +00:00
|
|
|
|
|
|
|
install(
|
|
|
|
EXPORT "${PYBIND11_EXPORT_NAME}"
|
|
|
|
NAMESPACE "pybind11::"
|
|
|
|
DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
|
2020-07-31 01:16:50 +00:00
|
|
|
|
2022-08-09 04:02:45 +00:00
|
|
|
# pkg-config support
|
|
|
|
if(NOT prefix_for_pc_file)
|
|
|
|
set(prefix_for_pc_file "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
endif()
|
|
|
|
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11.pc.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/pybind11.pc" @ONLY)
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pybind11.pc"
|
|
|
|
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig/")
|
|
|
|
|
2020-07-31 08:16:40 +00:00
|
|
|
# Uninstall target
|
|
|
|
if(PYBIND11_MASTER_PROJECT)
|
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake_uninstall.cmake.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
2020-07-31 01:16:50 +00:00
|
|
|
|
2020-07-31 08:16:40 +00:00
|
|
|
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
|
|
|
endif()
|
2020-07-31 01:16:50 +00:00
|
|
|
endif()
|
2020-08-01 02:45:19 +00:00
|
|
|
|
2020-08-18 12:34:18 +00:00
|
|
|
# BUILD_TESTING takes priority, but only if this is the master project
|
|
|
|
if(PYBIND11_MASTER_PROJECT AND DEFINED BUILD_TESTING)
|
|
|
|
if(BUILD_TESTING)
|
2020-08-19 16:26:26 +00:00
|
|
|
if(_pybind11_nopython)
|
|
|
|
message(FATAL_ERROR "Cannot activate tests in NOPYTHON mode")
|
|
|
|
else()
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|
2020-08-18 12:34:18 +00:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if(PYBIND11_TEST)
|
2020-08-19 16:26:26 +00:00
|
|
|
if(_pybind11_nopython)
|
|
|
|
message(FATAL_ERROR "Cannot activate tests in NOPYTHON mode")
|
|
|
|
else()
|
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|
2020-08-18 12:34:18 +00:00
|
|
|
endif()
|
2020-08-01 02:45:19 +00:00
|
|
|
endif()
|
2020-08-19 16:26:26 +00:00
|
|
|
|
|
|
|
# Better symmetry with find_package(pybind11 CONFIG) mode.
|
|
|
|
if(NOT PYBIND11_MASTER_PROJECT)
|
|
|
|
set(pybind11_FOUND
|
|
|
|
TRUE
|
2020-11-03 01:45:54 +00:00
|
|
|
CACHE INTERNAL "True if pybind11 and all required components found on the system")
|
2020-08-19 16:26:26 +00:00
|
|
|
endif()
|