aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/tools
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/pybind11/tools')
-rw-r--r--3rdparty/pybind11/tools/FindCatch.cmake21
-rw-r--r--3rdparty/pybind11/tools/FindEigen3.cmake28
-rw-r--r--3rdparty/pybind11/tools/FindPythonLibsNew.cmake199
-rwxr-xr-x3rdparty/pybind11/tools/check-style.sh38
-rw-r--r--3rdparty/pybind11/tools/cmake_uninstall.cmake.in23
-rw-r--r--3rdparty/pybind11/tools/libsize.py6
-rwxr-xr-x3rdparty/pybind11/tools/mkdoc.py379
-rw-r--r--3rdparty/pybind11/tools/pybind11Common.cmake393
-rw-r--r--3rdparty/pybind11/tools/pybind11Config.cmake.in310
-rw-r--r--3rdparty/pybind11/tools/pybind11NewTools.cmake246
-rw-r--r--3rdparty/pybind11/tools/pybind11Tools.cmake309
-rw-r--r--3rdparty/pybind11/tools/pyproject.toml3
-rw-r--r--3rdparty/pybind11/tools/setup_global.py.in63
-rw-r--r--3rdparty/pybind11/tools/setup_main.py.in36
14 files changed, 1291 insertions, 763 deletions
diff --git a/3rdparty/pybind11/tools/FindCatch.cmake b/3rdparty/pybind11/tools/FindCatch.cmake
index 9d490c5a..4d6bffcf 100644
--- a/3rdparty/pybind11/tools/FindCatch.cmake
+++ b/3rdparty/pybind11/tools/FindCatch.cmake
@@ -19,9 +19,14 @@ endif()
# Extract the version number from catch.hpp
function(_get_catch_version)
- file(STRINGS "${CATCH_INCLUDE_DIR}/catch.hpp" version_line REGEX "Catch v.*" LIMIT_COUNT 1)
+ file(
+ STRINGS "${CATCH_INCLUDE_DIR}/catch.hpp" version_line
+ REGEX "Catch v.*"
+ LIMIT_COUNT 1)
if(version_line MATCHES "Catch v([0-9]+)\\.([0-9]+)\\.([0-9]+)")
- set(CATCH_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" PARENT_SCOPE)
+ set(CATCH_VERSION
+ "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}"
+ PARENT_SCOPE)
endif()
endfunction()
@@ -34,11 +39,16 @@ function(_download_catch version destination_dir)
if(error)
message(FATAL_ERROR "Could not download ${url}")
endif()
- set(CATCH_INCLUDE_DIR "${destination_dir}" CACHE INTERNAL "")
+ set(CATCH_INCLUDE_DIR
+ "${destination_dir}"
+ CACHE INTERNAL "")
endfunction()
# Look for catch locally
-find_path(CATCH_INCLUDE_DIR NAMES catch.hpp PATH_SUFFIXES catch)
+find_path(
+ CATCH_INCLUDE_DIR
+ NAMES catch.hpp
+ PATH_SUFFIXES catch2)
if(CATCH_INCLUDE_DIR)
_get_catch_version()
endif()
@@ -54,4 +64,7 @@ if(NOT CATCH_VERSION OR CATCH_VERSION VERSION_LESS ${Catch_FIND_VERSION})
endif()
endif()
+add_library(Catch2::Catch2 IMPORTED INTERFACE)
+set_property(TARGET Catch2::Catch2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CATCH_INCLUDE_DIR}")
+
set(CATCH_FOUND TRUE)
diff --git a/3rdparty/pybind11/tools/FindEigen3.cmake b/3rdparty/pybind11/tools/FindEigen3.cmake
index 9c546a05..98ab43d9 100644
--- a/3rdparty/pybind11/tools/FindEigen3.cmake
+++ b/3rdparty/pybind11/tools/FindEigen3.cmake
@@ -26,17 +26,21 @@ if(NOT Eigen3_FIND_VERSION)
set(Eigen3_FIND_VERSION_PATCH 0)
endif(NOT Eigen3_FIND_VERSION_PATCH)
- set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
+ set(Eigen3_FIND_VERSION
+ "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
endif(NOT Eigen3_FIND_VERSION)
macro(_eigen3_check_version)
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
- string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
+ string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match
+ "${_eigen3_version_header}")
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
- string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
+ string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match
+ "${_eigen3_version_header}")
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
- string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
+ string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match
+ "${_eigen3_version_header}")
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
@@ -53,20 +57,19 @@ macro(_eigen3_check_version)
endif(NOT EIGEN3_VERSION_OK)
endmacro(_eigen3_check_version)
-if (EIGEN3_INCLUDE_DIR)
+if(EIGEN3_INCLUDE_DIR)
# in cache already
_eigen3_check_version()
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
-else (EIGEN3_INCLUDE_DIR)
+else(EIGEN3_INCLUDE_DIR)
- find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
- PATHS
- ${CMAKE_INSTALL_PREFIX}/include
- ${KDE4_INCLUDE_DIR}
- PATH_SUFFIXES eigen3 eigen
- )
+ find_path(
+ EIGEN3_INCLUDE_DIR
+ NAMES signature_of_eigen3_matrix_library
+ PATHS ${CMAKE_INSTALL_PREFIX}/include ${KDE4_INCLUDE_DIR}
+ PATH_SUFFIXES eigen3 eigen)
if(EIGEN3_INCLUDE_DIR)
_eigen3_check_version()
@@ -78,4 +81,3 @@ else (EIGEN3_INCLUDE_DIR)
mark_as_advanced(EIGEN3_INCLUDE_DIR)
endif(EIGEN3_INCLUDE_DIR)
-
diff --git a/3rdparty/pybind11/tools/FindPythonLibsNew.cmake b/3rdparty/pybind11/tools/FindPythonLibsNew.cmake
index 9ea6036e..b7125912 100644
--- a/3rdparty/pybind11/tools/FindPythonLibsNew.cmake
+++ b/3rdparty/pybind11/tools/FindPythonLibsNew.cmake
@@ -52,58 +52,92 @@
# Checking for the extension makes sure that `LibsNew` was found and not just `Libs`.
if(PYTHONLIBS_FOUND AND PYTHON_MODULE_EXTENSION)
- return()
+ return()
+endif()
+
+if(PythonLibsNew_FIND_QUIETLY)
+ set(_pythonlibs_quiet QUIET)
endif()
-# Use the Python interpreter to find the libs.
if(PythonLibsNew_FIND_REQUIRED)
- find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} REQUIRED)
-else()
- find_package(PythonInterp ${PythonLibsNew_FIND_VERSION})
+ set(_pythonlibs_required REQUIRED)
+endif()
+
+# Check to see if the `python` command is present and from a virtual
+# environment, conda, or GHA activation - if it is, try to use that.
+
+if(NOT DEFINED PYTHON_EXECUTABLE)
+ if(DEFINED ENV{VIRTUAL_ENV})
+ find_program(
+ PYTHON_EXECUTABLE python
+ PATHS "$ENV{VIRTUAL_ENV}" "$ENV{VIRTUAL_ENV}/bin"
+ NO_DEFAULT_PATH)
+ elseif(DEFINED ENV{CONDA_PREFIX})
+ find_program(
+ PYTHON_EXECUTABLE python
+ PATHS "$ENV{CONDA_PREFIX}" "$ENV{CONDA_PREFIX}/bin"
+ NO_DEFAULT_PATH)
+ elseif(DEFINED ENV{pythonLocation})
+ find_program(
+ PYTHON_EXECUTABLE python
+ PATHS "$ENV{pythonLocation}" "$ENV{pythonLocation}/bin"
+ NO_DEFAULT_PATH)
+ endif()
+ if(NOT PYTHON_EXECUTABLE)
+ unset(PYTHON_EXECUTABLE)
+ endif()
endif()
+# Use the Python interpreter to find the libs.
+if(NOT PythonLibsNew_FIND_VERSION)
+ set(PythonLibsNew_FIND_VERSION "")
+endif()
+
+find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} ${_pythonlibs_required}
+ ${_pythonlibs_quiet})
+
if(NOT PYTHONINTERP_FOUND)
- set(PYTHONLIBS_FOUND FALSE)
- set(PythonLibsNew_FOUND FALSE)
- return()
+ set(PYTHONLIBS_FOUND FALSE)
+ set(PythonLibsNew_FOUND FALSE)
+ return()
endif()
-# According to http://stackoverflow.com/questions/646518/python-how-to-detect-debug-interpreter
+# According to https://stackoverflow.com/questions/646518/python-how-to-detect-debug-interpreter
# testing whether sys has the gettotalrefcount function is a reliable, cross-platform
# way to detect a CPython debug interpreter.
#
# The library suffix is from the config var LDVERSION sometimes, otherwise
# VERSION. VERSION will typically be like "2.7" on unix, and "27" on windows.
-execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
- "from distutils import sysconfig as s;import sys;import struct;
+execute_process(
+ COMMAND
+ "${PYTHON_EXECUTABLE}" "-c" "from distutils import sysconfig as s;import sys;import struct;
print('.'.join(str(v) for v in sys.version_info));
print(sys.prefix);
print(s.get_python_inc(plat_specific=True));
print(s.get_python_lib(plat_specific=True));
-print(s.get_config_var('SO'));
+print(s.get_config_var('EXT_SUFFIX') or s.get_config_var('SO'));
print(hasattr(sys, 'gettotalrefcount')+0);
print(struct.calcsize('@P'));
print(s.get_config_var('LDVERSION') or s.get_config_var('VERSION'));
print(s.get_config_var('LIBDIR') or '');
print(s.get_config_var('MULTIARCH') or '');
"
- RESULT_VARIABLE _PYTHON_SUCCESS
- OUTPUT_VARIABLE _PYTHON_VALUES
- ERROR_VARIABLE _PYTHON_ERROR_VALUE)
+ RESULT_VARIABLE _PYTHON_SUCCESS
+ OUTPUT_VARIABLE _PYTHON_VALUES
+ ERROR_VARIABLE _PYTHON_ERROR_VALUE)
if(NOT _PYTHON_SUCCESS MATCHES 0)
- if(PythonLibsNew_FIND_REQUIRED)
- message(FATAL_ERROR
- "Python config failure:\n${_PYTHON_ERROR_VALUE}")
- endif()
- set(PYTHONLIBS_FOUND FALSE)
- set(PythonLibsNew_FOUND FALSE)
- return()
+ if(PythonLibsNew_FIND_REQUIRED)
+ message(FATAL_ERROR "Python config failure:\n${_PYTHON_ERROR_VALUE}")
+ endif()
+ set(PYTHONLIBS_FOUND FALSE)
+ set(PythonLibsNew_FOUND FALSE)
+ return()
endif()
# Convert the process output into a list
if(WIN32)
- string(REGEX REPLACE "\\\\" "/" _PYTHON_VALUES ${_PYTHON_VALUES})
+ string(REGEX REPLACE "\\\\" "/" _PYTHON_VALUES ${_PYTHON_VALUES})
endif()
string(REGEX REPLACE ";" "\\\\;" _PYTHON_VALUES ${_PYTHON_VALUES})
string(REGEX REPLACE "\n" ";" _PYTHON_VALUES ${_PYTHON_VALUES})
@@ -121,16 +155,15 @@ list(GET _PYTHON_VALUES 9 PYTHON_MULTIARCH)
# Make sure the Python has the same pointer-size as the chosen compiler
# Skip if CMAKE_SIZEOF_VOID_P is not defined
if(CMAKE_SIZEOF_VOID_P AND (NOT "${PYTHON_SIZEOF_VOID_P}" STREQUAL "${CMAKE_SIZEOF_VOID_P}"))
- if(PythonLibsNew_FIND_REQUIRED)
- math(EXPR _PYTHON_BITS "${PYTHON_SIZEOF_VOID_P} * 8")
- math(EXPR _CMAKE_BITS "${CMAKE_SIZEOF_VOID_P} * 8")
- message(FATAL_ERROR
- "Python config failure: Python is ${_PYTHON_BITS}-bit, "
- "chosen compiler is ${_CMAKE_BITS}-bit")
- endif()
- set(PYTHONLIBS_FOUND FALSE)
- set(PythonLibsNew_FOUND FALSE)
- return()
+ if(PythonLibsNew_FIND_REQUIRED)
+ math(EXPR _PYTHON_BITS "${PYTHON_SIZEOF_VOID_P} * 8")
+ math(EXPR _CMAKE_BITS "${CMAKE_SIZEOF_VOID_P} * 8")
+ message(FATAL_ERROR "Python config failure: Python is ${_PYTHON_BITS}-bit, "
+ "chosen compiler is ${_CMAKE_BITS}-bit")
+ endif()
+ set(PYTHONLIBS_FOUND FALSE)
+ set(PythonLibsNew_FOUND FALSE)
+ return()
endif()
# The built-in FindPython didn't always give the version numbers
@@ -138,65 +171,85 @@ string(REGEX REPLACE "\\." ";" _PYTHON_VERSION_LIST ${_PYTHON_VERSION_LIST})
list(GET _PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
list(GET _PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR)
list(GET _PYTHON_VERSION_LIST 2 PYTHON_VERSION_PATCH)
+set(PYTHON_VERSION "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}")
# Make sure all directory separators are '/'
string(REGEX REPLACE "\\\\" "/" PYTHON_PREFIX "${PYTHON_PREFIX}")
string(REGEX REPLACE "\\\\" "/" PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}")
string(REGEX REPLACE "\\\\" "/" PYTHON_SITE_PACKAGES "${PYTHON_SITE_PACKAGES}")
-if(CMAKE_HOST_WIN32 AND NOT (MINGW AND DEFINED ENV{MSYSTEM}))
- set(PYTHON_LIBRARY
- "${PYTHON_PREFIX}/libs/Python${PYTHON_LIBRARY_SUFFIX}.lib")
-
- # when run in a venv, PYTHON_PREFIX points to it. But the libraries remain in the
- # original python installation. They may be found relative to PYTHON_INCLUDE_DIR.
- if(NOT EXISTS "${PYTHON_LIBRARY}")
- get_filename_component(_PYTHON_ROOT ${PYTHON_INCLUDE_DIR} DIRECTORY)
- set(PYTHON_LIBRARY
- "${_PYTHON_ROOT}/libs/Python${PYTHON_LIBRARY_SUFFIX}.lib")
- endif()
+if(CMAKE_HOST_WIN32)
+ set(PYTHON_LIBRARY "${PYTHON_PREFIX}/libs/python${PYTHON_LIBRARY_SUFFIX}.lib")
- # raise an error if the python libs are still not found.
- if(NOT EXISTS "${PYTHON_LIBRARY}")
- message(FATAL_ERROR "Python libraries not found")
- endif()
+ # when run in a venv, PYTHON_PREFIX points to it. But the libraries remain in the
+ # original python installation. They may be found relative to PYTHON_INCLUDE_DIR.
+ if(NOT EXISTS "${PYTHON_LIBRARY}")
+ get_filename_component(_PYTHON_ROOT ${PYTHON_INCLUDE_DIR} DIRECTORY)
+ set(PYTHON_LIBRARY "${_PYTHON_ROOT}/libs/python${PYTHON_LIBRARY_SUFFIX}.lib")
+ endif()
-else()
+ # if we are in MSYS & MINGW, and we didn't find windows python lib, look for system python lib
+ if(DEFINED ENV{MSYSTEM}
+ AND MINGW
+ AND NOT EXISTS "${PYTHON_LIBRARY}")
if(PYTHON_MULTIARCH)
- set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}/${PYTHON_MULTIARCH}" "${PYTHON_LIBDIR}")
+ set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}/${PYTHON_MULTIARCH}" "${PYTHON_LIBDIR}")
else()
- set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}")
- endif()
- #message(STATUS "Searching for Python libs in ${_PYTHON_LIBS_SEARCH}")
- # Probably this needs to be more involved. It would be nice if the config
- # information the python interpreter itself gave us were more complete.
- find_library(PYTHON_LIBRARY
- NAMES "python${PYTHON_LIBRARY_SUFFIX}"
- PATHS ${_PYTHON_LIBS_SEARCH}
- NO_DEFAULT_PATH)
-
- # If all else fails, just set the name/version and let the linker figure out the path.
- if(NOT PYTHON_LIBRARY)
- set(PYTHON_LIBRARY python${PYTHON_LIBRARY_SUFFIX})
+ set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}")
endif()
+ unset(PYTHON_LIBRARY)
+ find_library(
+ PYTHON_LIBRARY
+ NAMES "python${PYTHON_LIBRARY_SUFFIX}"
+ PATHS ${_PYTHON_LIBS_SEARCH}
+ NO_DEFAULT_PATH)
+ endif()
+
+ # raise an error if the python libs are still not found.
+ if(NOT EXISTS "${PYTHON_LIBRARY}")
+ message(FATAL_ERROR "Python libraries not found")
+ endif()
+
+else()
+ if(PYTHON_MULTIARCH)
+ set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}/${PYTHON_MULTIARCH}" "${PYTHON_LIBDIR}")
+ else()
+ set(_PYTHON_LIBS_SEARCH "${PYTHON_LIBDIR}")
+ endif()
+ #message(STATUS "Searching for Python libs in ${_PYTHON_LIBS_SEARCH}")
+ # Probably this needs to be more involved. It would be nice if the config
+ # information the python interpreter itself gave us were more complete.
+ find_library(
+ PYTHON_LIBRARY
+ NAMES "python${PYTHON_LIBRARY_SUFFIX}"
+ PATHS ${_PYTHON_LIBS_SEARCH}
+ NO_DEFAULT_PATH)
+
+ # If all else fails, just set the name/version and let the linker figure out the path.
+ if(NOT PYTHON_LIBRARY)
+ set(PYTHON_LIBRARY python${PYTHON_LIBRARY_SUFFIX})
+ endif()
endif()
-MARK_AS_ADVANCED(
- PYTHON_LIBRARY
- PYTHON_INCLUDE_DIR
-)
+mark_as_advanced(PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the
# cache entries because they are meant to specify the location of a single
# library. We now set the variables listed by the documentation for this
# module.
-SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
-SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
-SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")
+set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
+set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
+if(NOT PYTHON_DEBUG_LIBRARY)
+ set(PYTHON_DEBUG_LIBRARY "")
+endif()
+set(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")
-find_package_message(PYTHON
- "Found PythonLibs: ${PYTHON_LIBRARY}"
- "${PYTHON_EXECUTABLE}${PYTHON_VERSION}")
+find_package_message(PYTHON "Found PythonLibs: ${PYTHON_LIBRARY}"
+ "${PYTHON_EXECUTABLE}${PYTHON_VERSION_STRING}")
set(PYTHONLIBS_FOUND TRUE)
set(PythonLibsNew_FOUND TRUE)
+
+if(NOT PYTHON_MODULE_PREFIX)
+ set(PYTHON_MODULE_PREFIX "")
+endif()
diff --git a/3rdparty/pybind11/tools/check-style.sh b/3rdparty/pybind11/tools/check-style.sh
index 0a9f7d24..f7af2a41 100755
--- a/3rdparty/pybind11/tools/check-style.sh
+++ b/3rdparty/pybind11/tools/check-style.sh
@@ -4,45 +4,19 @@
#
# This script currently checks for
#
-# 1. use of tabs instead of spaces
-# 2. MSDOS-style CRLF endings
-# 3. trailing spaces
-# 4. missing space between keyword and parenthesis, e.g.: for(, if(, while(
-# 5. Missing space between right parenthesis and brace, e.g. 'for (...){'
-# 6. opening brace on its own line. It should always be on the same line as the
+# 1. missing space between keyword and parenthesis, e.g.: for(, if(, while(
+# 2. Missing space between right parenthesis and brace, e.g. 'for (...){'
+# 3. opening brace on its own line. It should always be on the same line as the
# if/while/for/do statement.
#
-# Invoke as: tools/check-style.sh
+# Invoke as: tools/check-style.sh <filenames>
#
check_style_errors=0
IFS=$'\n'
-found="$( GREP_COLORS='mt=41' GREP_COLOR='41' grep $'\t' include tests/*.{cpp,py,h} docs/*.rst -rn --color=always )"
-if [ -n "$found" ]; then
- # The mt=41 sets a red background for matched tabs:
- echo -e '\033[31;01mError: found tab characters in the following files:\033[0m'
- check_style_errors=1
- echo "$found" | sed -e 's/^/ /'
-fi
-
-
-found="$( grep -IUlr $'\r' include tests/*.{cpp,py,h} docs/*.rst --color=always )"
-if [ -n "$found" ]; then
- echo -e '\033[31;01mError: found CRLF characters in the following files:\033[0m'
- check_style_errors=1
- echo "$found" | sed -e 's/^/ /'
-fi
-
-found="$(GREP_COLORS='mt=41' GREP_COLOR='41' grep '[[:blank:]]\+$' include tests/*.{cpp,py,h} docs/*.rst -rn --color=always )"
-if [ -n "$found" ]; then
- # The mt=41 sets a red background for matched trailing spaces
- echo -e '\033[31;01mError: found trailing spaces in the following files:\033[0m'
- check_style_errors=1
- echo "$found" | sed -e 's/^/ /'
-fi
-found="$(grep '\<\(if\|for\|while\|catch\)(\|){' include tests/*.{cpp,h} -rn --color=always)"
+found="$(grep '\<\(if\|for\|while\|catch\)(\|){' $@ -rn --color=always)"
if [ -n "$found" ]; then
echo -e '\033[31;01mError: found the following coding style problems:\033[0m'
check_style_errors=1
@@ -60,7 +34,7 @@ last && /^\s*{/ {
last=""
}
{ last = /(if|for|while|catch|switch)\s*\(.*\)\s*$/ ? $0 : "" }
-' $(find include -type f) tests/*.{cpp,h} docs/*.rst)"
+' $(find include -type f) $@)"
if [ -n "$found" ]; then
check_style_errors=1
echo -e '\033[31;01mError: braces should occur on the same line as the if/while/.. statement. Found issues in the following files:\033[0m'
diff --git a/3rdparty/pybind11/tools/cmake_uninstall.cmake.in b/3rdparty/pybind11/tools/cmake_uninstall.cmake.in
new file mode 100644
index 00000000..1e5d2bb8
--- /dev/null
+++ b/3rdparty/pybind11/tools/cmake_uninstall.cmake.in
@@ -0,0 +1,23 @@
+# Source: https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake
+
+if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
+endif()
+
+file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+ message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+ if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ exec_program(
+ "@CMAKE_COMMAND@" ARGS
+ "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval)
+ if(NOT "${rm_retval}" STREQUAL 0)
+ message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+ endif()
+ else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif()
+endforeach()
diff --git a/3rdparty/pybind11/tools/libsize.py b/3rdparty/pybind11/tools/libsize.py
index 5dcb8b0d..589c317f 100644
--- a/3rdparty/pybind11/tools/libsize.py
+++ b/3rdparty/pybind11/tools/libsize.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from __future__ import print_function, division
import os
import sys
@@ -18,7 +19,7 @@ if not os.path.exists(lib):
libsize = os.path.getsize(lib)
-print("------", os.path.basename(lib), "file size:", libsize, end='')
+print("------", os.path.basename(lib), "file size:", libsize, end="")
if os.path.exists(save):
with open(save) as sf:
@@ -33,6 +34,5 @@ if os.path.exists(save):
else:
print()
-with open(save, 'w') as sf:
+with open(save, "w") as sf:
sf.write(str(libsize))
-
diff --git a/3rdparty/pybind11/tools/mkdoc.py b/3rdparty/pybind11/tools/mkdoc.py
deleted file mode 100755
index 44164af3..00000000
--- a/3rdparty/pybind11/tools/mkdoc.py
+++ /dev/null
@@ -1,379 +0,0 @@
-#!/usr/bin/env python3
-#
-# Syntax: mkdoc.py [-I<path> ..] [.. a list of header files ..]
-#
-# Extract documentation from C++ header files to use it in Python bindings
-#
-
-import os
-import sys
-import platform
-import re
-import textwrap
-
-from clang import cindex
-from clang.cindex import CursorKind
-from collections import OrderedDict
-from glob import glob
-from threading import Thread, Semaphore
-from multiprocessing import cpu_count
-
-RECURSE_LIST = [
- CursorKind.TRANSLATION_UNIT,
- CursorKind.NAMESPACE,
- CursorKind.CLASS_DECL,
- CursorKind.STRUCT_DECL,
- CursorKind.ENUM_DECL,
- CursorKind.CLASS_TEMPLATE
-]
-
-PRINT_LIST = [
- CursorKind.CLASS_DECL,
- CursorKind.STRUCT_DECL,
- CursorKind.ENUM_DECL,
- CursorKind.ENUM_CONSTANT_DECL,
- CursorKind.CLASS_TEMPLATE,
- CursorKind.FUNCTION_DECL,
- CursorKind.FUNCTION_TEMPLATE,
- CursorKind.CONVERSION_FUNCTION,
- CursorKind.CXX_METHOD,
- CursorKind.CONSTRUCTOR,
- CursorKind.FIELD_DECL
-]
-
-PREFIX_BLACKLIST = [
- CursorKind.TRANSLATION_UNIT
-]
-
-CPP_OPERATORS = {
- '<=': 'le', '>=': 'ge', '==': 'eq', '!=': 'ne', '[]': 'array',
- '+=': 'iadd', '-=': 'isub', '*=': 'imul', '/=': 'idiv', '%=':
- 'imod', '&=': 'iand', '|=': 'ior', '^=': 'ixor', '<<=': 'ilshift',
- '>>=': 'irshift', '++': 'inc', '--': 'dec', '<<': 'lshift', '>>':
- 'rshift', '&&': 'land', '||': 'lor', '!': 'lnot', '~': 'bnot',
- '&': 'band', '|': 'bor', '+': 'add', '-': 'sub', '*': 'mul', '/':
- 'div', '%': 'mod', '<': 'lt', '>': 'gt', '=': 'assign', '()': 'call'
-}
-
-CPP_OPERATORS = OrderedDict(
- sorted(CPP_OPERATORS.items(), key=lambda t: -len(t[0])))
-
-job_count = cpu_count()
-job_semaphore = Semaphore(job_count)
-
-
-class NoFilenamesError(ValueError):
- pass
-
-
-def d(s):
- return s if isinstance(s, str) else s.decode('utf8')
-
-
-def sanitize_name(name):
- name = re.sub(r'type-parameter-0-([0-9]+)', r'T\1', name)
- for k, v in CPP_OPERATORS.items():
- name = name.replace('operator%s' % k, 'operator_%s' % v)
- name = re.sub('<.*>', '', name)
- name = ''.join([ch if ch.isalnum() else '_' for ch in name])
- name = re.sub('_$', '', re.sub('_+', '_', name))
- return '__doc_' + name
-
-
-def process_comment(comment):
- result = ''
-
- # Remove C++ comment syntax
- leading_spaces = float('inf')
- for s in comment.expandtabs(tabsize=4).splitlines():
- s = s.strip()
- if s.startswith('/*'):
- s = s[2:].lstrip('*')
- elif s.endswith('*/'):
- s = s[:-2].rstrip('*')
- elif s.startswith('///'):
- s = s[3:]
- if s.startswith('*'):
- s = s[1:]
- if len(s) > 0:
- leading_spaces = min(leading_spaces, len(s) - len(s.lstrip()))
- result += s + '\n'
-
- if leading_spaces != float('inf'):
- result2 = ""
- for s in result.splitlines():
- result2 += s[leading_spaces:] + '\n'
- result = result2
-
- # Doxygen tags
- cpp_group = '([\w:]+)'
- param_group = '([\[\w:\]]+)'
-
- s = result
- s = re.sub(r'\\c\s+%s' % cpp_group, r'``\1``', s)
- s = re.sub(r'\\a\s+%s' % cpp_group, r'*\1*', s)
- s = re.sub(r'\\e\s+%s' % cpp_group, r'*\1*', s)
- s = re.sub(r'\\em\s+%s' % cpp_group, r'*\1*', s)
- s = re.sub(r'\\b\s+%s' % cpp_group, r'**\1**', s)
- s = re.sub(r'\\ingroup\s+%s' % cpp_group, r'', s)
- s = re.sub(r'\\param%s?\s+%s' % (param_group, cpp_group),
- r'\n\n$Parameter ``\2``:\n\n', s)
- s = re.sub(r'\\tparam%s?\s+%s' % (param_group, cpp_group),
- r'\n\n$Template parameter ``\2``:\n\n', s)
-
- for in_, out_ in {
- 'return': 'Returns',
- 'author': 'Author',
- 'authors': 'Authors',
- 'copyright': 'Copyright',
- 'date': 'Date',
- 'remark': 'Remark',
- 'sa': 'See also',
- 'see': 'See also',
- 'extends': 'Extends',
- 'throw': 'Throws',
- 'throws': 'Throws'
- }.items():
- s = re.sub(r'\\%s\s*' % in_, r'\n\n$%s:\n\n' % out_, s)
-
- s = re.sub(r'\\details\s*', r'\n\n', s)
- s = re.sub(r'\\brief\s*', r'', s)
- s = re.sub(r'\\short\s*', r'', s)
- s = re.sub(r'\\ref\s*', r'', s)
-
- s = re.sub(r'\\code\s?(.*?)\s?\\endcode',
- r"```\n\1\n```\n", s, flags=re.DOTALL)
-
- # HTML/TeX tags
- s = re.sub(r'<tt>(.*?)</tt>', r'``\1``', s, flags=re.DOTALL)
- s = re.sub(r'<pre>(.*?)</pre>', r"```\n\1\n```\n", s, flags=re.DOTALL)
- s = re.sub(r'<em>(.*?)</em>', r'*\1*', s, flags=re.DOTALL)
- s = re.sub(r'<b>(.*?)</b>', r'**\1**', s, flags=re.DOTALL)
- s = re.sub(r'\\f\$(.*?)\\f\$', r'$\1$', s, flags=re.DOTALL)
- s = re.sub(r'<li>', r'\n\n* ', s)
- s = re.sub(r'</?ul>', r'', s)
- s = re.sub(r'</li>', r'\n\n', s)
-
- s = s.replace('``true``', '``True``')
- s = s.replace('``false``', '``False``')
-
- # Re-flow text
- wrapper = textwrap.TextWrapper()
- wrapper.expand_tabs = True
- wrapper.replace_whitespace = True
- wrapper.drop_whitespace = True
- wrapper.width = 70
- wrapper.initial_indent = wrapper.subsequent_indent = ''
-
- result = ''
- in_code_segment = False
- for x in re.split(r'(```)', s):
- if x == '```':
- if not in_code_segment:
- result += '```\n'
- else:
- result += '\n```\n\n'
- in_code_segment = not in_code_segment
- elif in_code_segment:
- result += x.strip()
- else:
- for y in re.split(r'(?: *\n *){2,}', x):
- wrapped = wrapper.fill(re.sub(r'\s+', ' ', y).strip())
- if len(wrapped) > 0 and wrapped[0] == '$':
- result += wrapped[1:] + '\n'
- wrapper.initial_indent = \
- wrapper.subsequent_indent = ' ' * 4
- else:
- if len(wrapped) > 0:
- result += wrapped + '\n\n'
- wrapper.initial_indent = wrapper.subsequent_indent = ''
- return result.rstrip().lstrip('\n')
-
-
-def extract(filename, node, prefix, output):
- if not (node.location.file is None or
- os.path.samefile(d(node.location.file.name), filename)):
- return 0
- if node.kind in RECURSE_LIST:
- sub_prefix = prefix
- if node.kind not in PREFIX_BLACKLIST:
- if len(sub_prefix) > 0:
- sub_prefix += '_'
- sub_prefix += d(node.spelling)
- for i in node.get_children():
- extract(filename, i, sub_prefix, output)
- if node.kind in PRINT_LIST:
- comment = d(node.raw_comment) if node.raw_comment is not None else ''
- comment = process_comment(comment)
- sub_prefix = prefix
- if len(sub_prefix) > 0:
- sub_prefix += '_'
- if len(node.spelling) > 0:
- name = sanitize_name(sub_prefix + d(node.spelling))
- output.append((name, filename, comment))
-
-
-class ExtractionThread(Thread):
- def __init__(self, filename, parameters, output):
- Thread.__init__(self)
- self.filename = filename
- self.parameters = parameters
- self.output = output
- job_semaphore.acquire()
-
- def run(self):
- print('Processing "%s" ..' % self.filename, file=sys.stderr)
- try:
- index = cindex.Index(
- cindex.conf.lib.clang_createIndex(False, True))
- tu = index.parse(self.filename, self.parameters)
- extract(self.filename, tu.cursor, '', self.output)
- finally:
- job_semaphore.release()
-
-
-def read_args(args):
- parameters = []
- filenames = []
- if "-x" not in args:
- parameters.extend(['-x', 'c++'])
- if not any(it.startswith("-std=") for it in args):
- parameters.append('-std=c++11')
-
- if platform.system() == 'Darwin':
- dev_path = '/Applications/Xcode.app/Contents/Developer/'
- lib_dir = dev_path + 'Toolchains/XcodeDefault.xctoolchain/usr/lib/'
- sdk_dir = dev_path + 'Platforms/MacOSX.platform/Developer/SDKs'
- libclang = lib_dir + 'libclang.dylib'
-
- if os.path.exists(libclang):
- cindex.Config.set_library_path(os.path.dirname(libclang))
-
- if os.path.exists(sdk_dir):
- sysroot_dir = os.path.join(sdk_dir, next(os.walk(sdk_dir))[1][0])
- parameters.append('-isysroot')
- parameters.append(sysroot_dir)
- elif platform.system() == 'Linux':
- # clang doesn't find its own base includes by default on Linux,
- # but different distros install them in different paths.
- # Try to autodetect, preferring the highest numbered version.
- def clang_folder_version(d):
- return [int(ver) for ver in re.findall(r'(?<!lib)(?<!\d)\d+', d)]
- clang_include_dir = max((
- path
- for libdir in ['lib64', 'lib', 'lib32']
- for path in glob('/usr/%s/clang/*/include' % libdir)
- if os.path.isdir(path)
- ), default=None, key=clang_folder_version)
- if clang_include_dir:
- parameters.extend(['-isystem', clang_include_dir])
-
- for item in args:
- if item.startswith('-'):
- parameters.append(item)
- else:
- filenames.append(item)
-
- if len(filenames) == 0:
- raise NoFilenamesError("args parameter did not contain any filenames")
-
- return parameters, filenames
-
-
-def extract_all(args):
- parameters, filenames = read_args(args)
- output = []
- for filename in filenames:
- thr = ExtractionThread(filename, parameters, output)
- thr.start()
-
- print('Waiting for jobs to finish ..', file=sys.stderr)
- for i in range(job_count):
- job_semaphore.acquire()
-
- return output
-
-
-def write_header(comments, out_file=sys.stdout):
- print('''/*
- This file contains docstrings for the Python bindings.
- Do not edit! These were automatically extracted by mkdoc.py
- */
-
-#define __EXPAND(x) x
-#define __COUNT(_1, _2, _3, _4, _5, _6, _7, COUNT, ...) COUNT
-#define __VA_SIZE(...) __EXPAND(__COUNT(__VA_ARGS__, 7, 6, 5, 4, 3, 2, 1))
-#define __CAT1(a, b) a ## b
-#define __CAT2(a, b) __CAT1(a, b)
-#define __DOC1(n1) __doc_##n1
-#define __DOC2(n1, n2) __doc_##n1##_##n2
-#define __DOC3(n1, n2, n3) __doc_##n1##_##n2##_##n3
-#define __DOC4(n1, n2, n3, n4) __doc_##n1##_##n2##_##n3##_##n4
-#define __DOC5(n1, n2, n3, n4, n5) __doc_##n1##_##n2##_##n3##_##n4##_##n5
-#define __DOC6(n1, n2, n3, n4, n5, n6) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6
-#define __DOC7(n1, n2, n3, n4, n5, n6, n7) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7
-#define DOC(...) __EXPAND(__EXPAND(__CAT2(__DOC, __VA_SIZE(__VA_ARGS__)))(__VA_ARGS__))
-
-#if defined(__GNUG__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#endif
-''', file=out_file)
-
-
- name_ctr = 1
- name_prev = None
- for name, _, comment in list(sorted(comments, key=lambda x: (x[0], x[1]))):
- if name == name_prev:
- name_ctr += 1
- name = name + "_%i" % name_ctr
- else:
- name_prev = name
- name_ctr = 1
- print('\nstatic const char *%s =%sR"doc(%s)doc";' %
- (name, '\n' if '\n' in comment else ' ', comment), file=out_file)
-
- print('''
-#if defined(__GNUG__)
-#pragma GCC diagnostic pop
-#endif
-''', file=out_file)
-
-
-def mkdoc(args):
- args = list(args)
- out_path = None
- for idx, arg in enumerate(args):
- if arg.startswith("-o"):
- args.remove(arg)
- try:
- out_path = arg[2:] or args.pop(idx)
- except IndexError:
- print("-o flag requires an argument")
- exit(-1)
- break
-
- comments = extract_all(args)
-
- if out_path:
- try:
- with open(out_path, 'w') as out_file:
- write_header(comments, out_file)
- except:
- # In the event of an error, don't leave a partially-written
- # output file.
- try:
- os.unlink(out_path)
- except:
- pass
- raise
- else:
- write_header(comments)
-
-
-if __name__ == '__main__':
- try:
- mkdoc(sys.argv[1:])
- except NoFilenamesError:
- print('Syntax: %s [.. a list of header files ..]' % sys.argv[0])
- exit(-1)
diff --git a/3rdparty/pybind11/tools/pybind11Common.cmake b/3rdparty/pybind11/tools/pybind11Common.cmake
new file mode 100644
index 00000000..3c05c682
--- /dev/null
+++ b/3rdparty/pybind11/tools/pybind11Common.cmake
@@ -0,0 +1,393 @@
+#[======================================================[.rst
+
+Adds the following targets::
+
+ pybind11::pybind11 - link to headers and pybind11
+ pybind11::module - Adds module links
+ pybind11::embed - Adds embed links
+ pybind11::lto - Link time optimizations (manual selection)
+ pybind11::thin_lto - Link time optimizations (manual selection)
+ pybind11::python_link_helper - Adds link to Python libraries
+ pybind11::python2_no_register - Avoid warning/error with Python 2 + C++14/7
+ pybind11::windows_extras - MSVC bigobj and mp for building multithreaded
+ pybind11::opt_size - avoid optimizations that increase code size
+
+Adds the following functions::
+
+ pybind11_strip(target) - strip target after building on linux/macOS
+ pybind11_find_import(module) - See if a module is installed.
+
+#]======================================================]
+
+# CMake 3.10 has an include_guard command, but we can't use that yet
+if(TARGET pybind11::lto)
+ return()
+endif()
+
+# If we are in subdirectory mode, all IMPORTED targets must be GLOBAL. If we
+# are in CONFIG mode, they should be "normal" targets instead.
+# In CMake 3.11+ you can promote a target to global after you create it,
+# which might be simpler than this check.
+get_property(
+ is_config
+ TARGET pybind11::headers
+ PROPERTY IMPORTED)
+if(NOT is_config)
+ set(optional_global GLOBAL)
+endif()
+
+# If not run in Python mode, we still would like this to at least
+# include pybind11's include directory:
+set(pybind11_INCLUDE_DIRS
+ "${pybind11_INCLUDE_DIR}"
+ CACHE INTERNAL "Include directory for pybind11 (Python not requested)")
+
+# --------------------- Shared targets ----------------------------
+
+# Build an interface library target:
+add_library(pybind11::pybind11 IMPORTED INTERFACE ${optional_global})
+set_property(
+ TARGET pybind11::pybind11
+ APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES pybind11::headers)
+
+# Build a module target:
+add_library(pybind11::module IMPORTED INTERFACE ${optional_global})
+set_property(
+ TARGET pybind11::module
+ APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES pybind11::pybind11)
+
+# Build an embed library target:
+add_library(pybind11::embed IMPORTED INTERFACE ${optional_global})
+set_property(
+ TARGET pybind11::embed
+ APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES pybind11::pybind11)
+
+# ----------------------- no register ----------------------
+
+# Workaround for Python 2.7 and C++17 (C++14 as a warning) incompatibility
+# This adds the flags -Wno-register and -Wno-deprecated-register if the compiler
+# is Clang 3.9+ or AppleClang and the compile language is CXX, or /wd5033 for MSVC (all languages,
+# since MSVC didn't recognize COMPILE_LANGUAGE until CMake 3.11+).
+
+add_library(pybind11::python2_no_register INTERFACE IMPORTED ${optional_global})
+set(clang_4plus
+ "$<AND:$<CXX_COMPILER_ID:Clang>,$<NOT:$<VERSION_LESS:$<CXX_COMPILER_VERSION>,3.9>>>")
+set(no_register "$<OR:${clang_4plus},$<CXX_COMPILER_ID:AppleClang>>")
+
+if(MSVC AND CMAKE_VERSION VERSION_LESS 3.11)
+ set(cxx_no_register "${no_register}")
+else()
+ set(cxx_no_register "$<AND:$<COMPILE_LANGUAGE:CXX>,${no_register}>")
+endif()
+
+set(msvc "$<CXX_COMPILER_ID:MSVC>")
+
+set_property(
+ TARGET pybind11::python2_no_register
+ PROPERTY INTERFACE_COMPILE_OPTIONS
+ "$<${cxx_no_register}:-Wno-register;-Wno-deprecated-register>" "$<${msvc}:/wd5033>")
+
+# --------------------------- link helper ---------------------------
+
+add_library(pybind11::python_link_helper IMPORTED INTERFACE ${optional_global})
+
+if(CMAKE_VERSION VERSION_LESS 3.13)
+ # In CMake 3.11+, you can set INTERFACE properties via the normal methods, and
+ # this would be simpler.
+ set_property(
+ TARGET pybind11::python_link_helper
+ APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES "$<$<PLATFORM_ID:Darwin>:-undefined dynamic_lookup>")
+else()
+ # link_options was added in 3.13+
+ # This is safer, because you are ensured the deduplication pass in CMake will not consider
+ # these separate and remove one but not the other.
+ set_property(
+ TARGET pybind11::python_link_helper
+ APPEND
+ PROPERTY INTERFACE_LINK_OPTIONS "$<$<PLATFORM_ID:Darwin>:LINKER:-undefined,dynamic_lookup>")
+endif()
+
+# ------------------------ Windows extras -------------------------
+
+add_library(pybind11::windows_extras IMPORTED INTERFACE ${optional_global})
+
+if(MSVC)
+ # /MP enables multithreaded builds (relevant when there are many files), /bigobj is
+ # needed for bigger binding projects due to the limit to 64k addressable sections
+ set_property(
+ TARGET pybind11::windows_extras
+ APPEND
+ PROPERTY INTERFACE_COMPILE_OPTIONS /bigobj)
+
+ if(CMAKE_VERSION VERSION_LESS 3.11)
+ set_property(
+ TARGET pybind11::windows_extras
+ APPEND
+ PROPERTY INTERFACE_COMPILE_OPTIONS $<$<NOT:$<CONFIG:Debug>>:/MP>)
+ else()
+ # Only set these options for C++ files. This is important so that, for
+ # instance, projects that include other types of source files like CUDA
+ # .cu files don't get these options propagated to nvcc since that would
+ # cause the build to fail.
+ set_property(
+ TARGET pybind11::windows_extras
+ APPEND
+ PROPERTY INTERFACE_COMPILE_OPTIONS $<$<NOT:$<CONFIG:Debug>>:$<$<COMPILE_LANGUAGE:CXX>:/MP>>)
+ endif()
+endif()
+
+# ----------------------- Optimize binary size --------------------------
+
+add_library(pybind11::opt_size IMPORTED INTERFACE ${optional_global})
+
+if(MSVC)
+ set(PYBIND11_OPT_SIZE /Os)
+else()
+ set(PYBIND11_OPT_SIZE -Os)
+endif()
+
+set_property(
+ TARGET pybind11::opt_size
+ APPEND
+ PROPERTY INTERFACE_COMPILE_OPTIONS $<$<CONFIG:Release>:${PYBIND11_OPT_SIZE}>
+ $<$<CONFIG:MinSizeRel>:${PYBIND11_OPT_SIZE}>
+ $<$<CONFIG:RelWithDebInfo>:${PYBIND11_OPT_SIZE}>)
+
+# ----------------------- Legacy option --------------------------
+
+# Warn or error if old variable name used
+if(PYBIND11_CPP_STANDARD)
+ string(REGEX MATCH [[..$]] VAL "${PYBIND11_CPP_STANDARD}")
+ if(CMAKE_CXX_STANDARD)
+ if(NOT CMAKE_CXX_STANDARD STREQUAL VAL)
+ message(WARNING "CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} does not match "
+ "PYBIND11_CPP_STANDARD=${PYBIND11_CPP_STANDARD}, "
+ "please remove PYBIND11_CPP_STANDARD from your cache")
+ endif()
+ else()
+ set(supported_standards 11 14 17 20)
+ if("${VAL}" IN_LIST supported_standards)
+ message(WARNING "USE -DCMAKE_CXX_STANDARD=${VAL} instead of PYBIND11_CPP_STANDARD")
+ set(CMAKE_CXX_STANDARD
+ ${VAL}
+ CACHE STRING "From PYBIND11_CPP_STANDARD")
+ else()
+ message(FATAL_ERROR "PYBIND11_CPP_STANDARD should be replaced with CMAKE_CXX_STANDARD "
+ "(last two chars: ${VAL} not understood as a valid CXX std)")
+ endif()
+ endif()
+endif()
+
+# --------------------- Python specifics -------------------------
+
+# Check to see which Python mode we are in, new, old, or no python
+if(PYBIND11_NOPYTHON)
+ set(_pybind11_nopython ON)
+elseif(
+ PYBIND11_FINDPYTHON
+ OR Python_FOUND
+ OR Python2_FOUND
+ OR Python3_FOUND)
+ # New mode
+ include("${CMAKE_CURRENT_LIST_DIR}/pybind11NewTools.cmake")
+
+else()
+
+ # Classic mode
+ include("${CMAKE_CURRENT_LIST_DIR}/pybind11Tools.cmake")
+
+endif()
+
+# --------------------- pybind11_find_import -------------------------------
+
+if(NOT _pybind11_nopython)
+ # Check to see if modules are importable. Use REQUIRED to force an error if
+ # one of the modules is not found. <package_name>_FOUND will be set if the
+ # package was found (underscores replace dashes if present). QUIET will hide
+ # the found message, and VERSION will require a minimum version. A successful
+ # find will cache the result.
+ function(pybind11_find_import PYPI_NAME)
+ # CMake variables need underscores (PyPI doesn't care)
+ string(REPLACE "-" "_" NORM_PYPI_NAME "${PYPI_NAME}")
+
+ # Return if found previously
+ if(${NORM_PYPI_NAME}_FOUND)
+ return()
+ endif()
+
+ set(options "REQUIRED;QUIET")
+ set(oneValueArgs "VERSION")
+ cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "" ${ARGN})
+
+ if(ARG_REQUIRED)
+ set(status_level FATAL_ERROR)
+ else()
+ set(status_level WARNING)
+ endif()
+
+ execute_process(
+ COMMAND
+ ${${_Python}_EXECUTABLE} -c
+ "from pkg_resources import get_distribution; print(get_distribution('${PYPI_NAME}').version)"
+ RESULT_VARIABLE RESULT_PRESENT
+ OUTPUT_VARIABLE PKG_VERSION
+ ERROR_QUIET)
+
+ string(STRIP "${PKG_VERSION}" PKG_VERSION)
+
+ # If a result is present, this failed
+ if(RESULT_PRESENT)
+ set(${NORM_PYPI_NAME}_FOUND
+ ${NORM_PYPI_NAME}-NOTFOUND
+ CACHE INTERNAL "")
+ # Always warn or error
+ message(
+ ${status_level}
+ "Missing: ${PYPI_NAME} ${ARG_VERSION}\nTry: ${${_Python}_EXECUTABLE} -m pip install ${PYPI_NAME}"
+ )
+ else()
+ if(ARG_VERSION AND PKG_VERSION VERSION_LESS ARG_VERSION)
+ message(
+ ${status_level}
+ "Version incorrect: ${PYPI_NAME} ${PKG_VERSION} found, ${ARG_VERSION} required - try upgrading"
+ )
+ else()
+ set(${NORM_PYPI_NAME}_FOUND
+ YES
+ CACHE INTERNAL "")
+ set(${NORM_PYPI_NAME}_VERSION
+ ${PKG_VERSION}
+ CACHE INTERNAL "")
+ endif()
+ if(NOT ARG_QUIET)
+ message(STATUS "Found ${PYPI_NAME} ${PKG_VERSION}")
+ endif()
+ endif()
+ if(NOT ARG_VERSION OR (NOT PKG_VERSION VERSION_LESS ARG_VERSION))
+ # We have successfully found a good version, cache to avoid calling again.
+ endif()
+ endfunction()
+endif()
+
+# --------------------- LTO -------------------------------
+
+include(CheckCXXCompilerFlag)
+
+# Checks whether the given CXX/linker flags can compile and link a cxx file.
+# cxxflags and linkerflags are lists of flags to use. The result variable is a
+# unique variable name for each set of flags: the compilation result will be
+# cached base on the result variable. If the flags work, sets them in
+# cxxflags_out/linkerflags_out internal cache variables (in addition to
+# ${result}).
+function(_pybind11_return_if_cxx_and_linker_flags_work result cxxflags linkerflags cxxflags_out
+ linkerflags_out)
+ set(CMAKE_REQUIRED_LIBRARIES ${linkerflags})
+ check_cxx_compiler_flag("${cxxflags}" ${result})
+ if(${result})
+ set(${cxxflags_out}
+ "${cxxflags}"
+ PARENT_SCOPE)
+ set(${linkerflags_out}
+ "${linkerflags}"
+ PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(_pybind11_generate_lto target prefer_thin_lto)
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+ set(cxx_append "")
+ set(linker_append "")
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT APPLE)
+ # Clang Gold plugin does not support -Os; append -O3 to MinSizeRel builds to override it
+ set(linker_append ";$<$<CONFIG:MinSizeRel>:-O3>")
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ set(cxx_append ";-fno-fat-lto-objects")
+ endif()
+
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND prefer_thin_lto)
+ _pybind11_return_if_cxx_and_linker_flags_work(
+ HAS_FLTO_THIN "-flto=thin${cxx_append}" "-flto=thin${linker_append}"
+ PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
+ endif()
+
+ if(NOT HAS_FLTO_THIN)
+ _pybind11_return_if_cxx_and_linker_flags_work(
+ HAS_FLTO "-flto${cxx_append}" "-flto${linker_append}" PYBIND11_LTO_CXX_FLAGS
+ PYBIND11_LTO_LINKER_FLAGS)
+ endif()
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
+ # Intel equivalent to LTO is called IPO
+ _pybind11_return_if_cxx_and_linker_flags_work(HAS_INTEL_IPO "-ipo" "-ipo"
+ PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
+ elseif(MSVC)
+ # cmake only interprets libraries as linker flags when they start with a - (otherwise it
+ # converts /LTCG to \LTCG as if it was a Windows path). Luckily MSVC supports passing flags
+ # with - instead of /, even if it is a bit non-standard:
+ _pybind11_return_if_cxx_and_linker_flags_work(HAS_MSVC_GL_LTCG "/GL" "-LTCG"
+ PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
+ endif()
+
+ # Enable LTO flags if found, except for Debug builds
+ if(PYBIND11_LTO_CXX_FLAGS)
+ # CONFIG takes multiple values in CMake 3.19+, until then we have to use OR
+ set(is_debug "$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>")
+ set(not_debug "$<NOT:${is_debug}>")
+ set(cxx_lang "$<COMPILE_LANGUAGE:CXX>")
+ if(MSVC AND CMAKE_VERSION VERSION_LESS 3.11)
+ set(genex "${not_debug}")
+ else()
+ set(genex "$<AND:${not_debug},${cxx_lang}>")
+ endif()
+ set_property(
+ TARGET ${target}
+ APPEND
+ PROPERTY INTERFACE_COMPILE_OPTIONS "$<${genex}:${PYBIND11_LTO_CXX_FLAGS}>")
+ if(CMAKE_PROJECT_NAME STREQUAL "pybind11")
+ message(STATUS "${target} enabled")
+ endif()
+ else()
+ if(CMAKE_PROJECT_NAME STREQUAL "pybind11")
+ message(STATUS "${target} disabled (not supported by the compiler and/or linker)")
+ endif()
+ endif()
+
+ if(PYBIND11_LTO_LINKER_FLAGS)
+ if(CMAKE_VERSION VERSION_LESS 3.11)
+ set_property(
+ TARGET ${target}
+ APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES "$<${not_debug}:${PYBIND11_LTO_LINKER_FLAGS}>")
+ else()
+ set_property(
+ TARGET ${target}
+ APPEND
+ PROPERTY INTERFACE_LINK_OPTIONS "$<${not_debug}:${PYBIND11_LTO_LINKER_FLAGS}>")
+ endif()
+ endif()
+endfunction()
+
+add_library(pybind11::lto IMPORTED INTERFACE ${optional_global})
+_pybind11_generate_lto(pybind11::lto FALSE)
+
+add_library(pybind11::thin_lto IMPORTED INTERFACE ${optional_global})
+_pybind11_generate_lto(pybind11::thin_lto TRUE)
+
+# ---------------------- pybind11_strip -----------------------------
+
+function(pybind11_strip target_name)
+ # Strip unnecessary sections of the binary on Linux/macOS
+ if(CMAKE_STRIP)
+ if(APPLE)
+ set(x_opt -x)
+ endif()
+
+ add_custom_command(
+ TARGET ${target_name}
+ POST_BUILD
+ COMMAND ${CMAKE_STRIP} ${x_opt} $<TARGET_FILE:${target_name}>)
+ endif()
+endfunction()
diff --git a/3rdparty/pybind11/tools/pybind11Config.cmake.in b/3rdparty/pybind11/tools/pybind11Config.cmake.in
index 8a7272ff..9808f3d2 100644
--- a/3rdparty/pybind11/tools/pybind11Config.cmake.in
+++ b/3rdparty/pybind11/tools/pybind11Config.cmake.in
@@ -1,104 +1,232 @@
-# pybind11Config.cmake
-# --------------------
-#
-# PYBIND11 cmake module.
-# This module sets the following variables in your project::
-#
-# pybind11_FOUND - true if pybind11 and all required components found on the system
-# pybind11_VERSION - pybind11 version in format Major.Minor.Release
-# pybind11_INCLUDE_DIRS - Directories where pybind11 and python headers are located.
-# pybind11_INCLUDE_DIR - Directory where pybind11 headers are located.
-# pybind11_DEFINITIONS - Definitions necessary to use pybind11, namely USING_pybind11.
-# pybind11_LIBRARIES - compile flags and python libraries (as needed) to link against.
-# pybind11_LIBRARY - empty.
-# CMAKE_MODULE_PATH - appends location of accompanying FindPythonLibsNew.cmake and
-# pybind11Tools.cmake modules.
-#
-#
-# Available components: None
-#
-#
-# Exported targets::
-#
-# If pybind11 is found, this module defines the following :prop_tgt:`IMPORTED`
-# interface library targets::
-#
-# pybind11::module - for extension modules
-# pybind11::embed - for embedding the Python interpreter
-#
-# Python headers, libraries (as needed by platform), and the C++ standard
-# are attached to the target. Set PythonLibsNew variables to influence
-# python detection and PYBIND11_CPP_STANDARD (-std=c++11 or -std=c++14) to
-# influence standard setting. ::
-#
-# find_package(pybind11 CONFIG REQUIRED)
-# message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
-#
-# # Create an extension module
-# add_library(mylib MODULE main.cpp)
-# target_link_libraries(mylib pybind11::module)
-#
-# # Or embed the Python interpreter into an executable
-# add_executable(myexe main.cpp)
-# target_link_libraries(myexe pybind11::embed)
-#
-# Suggested usage::
-#
-# find_package with version info is not recommended except for release versions. ::
-#
-# find_package(pybind11 CONFIG)
-# find_package(pybind11 2.0 EXACT CONFIG REQUIRED)
-#
-#
-# The following variables can be set to guide the search for this package::
-#
-# pybind11_DIR - CMake variable, set to directory containing this Config file
-# CMAKE_PREFIX_PATH - CMake variable, set to root directory of this package
-# PATH - environment variable, set to bin directory of this package
-# CMAKE_DISABLE_FIND_PACKAGE_pybind11 - CMake variable, disables
-# find_package(pybind11) when not REQUIRED, perhaps to force internal build
+#[=============================================================================[.rst:
-@PACKAGE_INIT@
+pybind11Config.cmake
+####################
+
+Exported variables
+==================
+
+This module sets the following variables in your project:
+
+``pybind11_FOUND``
+ true if pybind11 and all required components found on the system
+``pybind11_VERSION``
+ pybind11 version in format Major.Minor.Release
+``pybind11_VERSION_TYPE``
+ pybind11 version type (dev, release)
+``pybind11_INCLUDE_DIRS``
+ Directories where pybind11 and python headers are located.
+``pybind11_INCLUDE_DIR``
+ Directory where pybind11 headers are located.
+``pybind11_DEFINITIONS``
+ Definitions necessary to use pybind11, namely USING_pybind11.
+``pybind11_LIBRARIES``
+ Compile flags and python libraries (as needed) to link against.
+``pybind11_LIBRARY``
+ Empty.
+
+Available components: None
+
+
+Exported targets
+================
+
+If pybind11 is found, this module defines the following ``IMPORTED``
+interface library targets:
+
+``pybind11::module``
+ for extension modules.
+``pybind11::embed``
+ for embedding the Python interpreter.
+
+Python headers, libraries (as needed by platform), and the C++ standard
+are attached to the target.
+
+Advanced targets are also supplied - these are primary for users building
+complex applications, and they are available in all modes:
+
+``pybind11::headers``
+ Just the pybind11 headers and minimum compile requirements.
+``pybind11::pybind11``
+ Python headers too.
+``pybind11::python_link_helper``
+ Just the "linking" part of ``pybind11:module``, for CMake < 3.15.
+``pybind11::python2_no_register``
+ Quiets the warning/error when mixing C++14+ and Python 2, also included in ``pybind11::module``.
+``pybind11::thin_lto``
+ An alternative to ``INTERPROCEDURAL_OPTIMIZATION``.
+``pybind11::lto``
+ An alternative to ``INTERPROCEDURAL_OPTIMIZATION`` (also avoids thin LTO on clang).
+``pybind11::windows_extras``
+ Adds bigobj and mp for MSVC.
+
+Modes
+=====
+
+There are two modes provided; classic, which is built on the old Python
+discovery packages in CMake, or the new FindPython mode, which uses FindPython
+from 3.12+ forward (3.15+ _highly_ recommended).
+
+New FindPython mode
+^^^^^^^^^^^^^^^^^^^
+
+To activate this mode, either call ``find_package(Python COMPONENTS Interpreter Development)``
+before finding this package, or set the ``PYBIND11_FINDPYTHON`` variable to ON. In this mode,
+you can either use the basic targets, or use the FindPython tools:
+
+.. code-block:: cmake
+
+ find_package(Python COMPONENTS Interpreter Development)
+ find_package(pybind11 CONFIG)
+
+ # pybind11 method:
+ pybind11_add_module(MyModule1 src1.cpp)
+
+ # Python method:
+ Python_add_library(MyModule2 src2.cpp)
+ target_link_libraries(MyModule2 pybind11::headers)
+ set_target_properties(MyModule2 PROPERTIES
+ INTERPROCEDURAL_OPTIMIZATION ON
+ CXX__VISIBILITY_PRESET ON
+ VISIBLITY_INLINES_HIDDEN ON)
+
+If you build targets yourself, you may be interested in stripping the output
+for reduced size; this is the one other feature that the helper function gives you.
+
+Classic mode
+^^^^^^^^^^^^
+
+Set PythonLibsNew variables to influence python detection and
+CMAKE_CXX_STANDARD to influence standard setting.
+
+.. code-block:: cmake
+
+ find_package(pybind11 CONFIG REQUIRED)
+
+ # Create an extension module
+ add_library(mylib MODULE main.cpp)
+ target_link_libraries(mylib PUBLIC pybind11::module)
+
+ # Or embed the Python interpreter into an executable
+ add_executable(myexe main.cpp)
+ target_link_libraries(myexe PUBLIC pybind11::embed)
-set(PN pybind11)
-# location of pybind11/pybind11.h
-set(${PN}_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
+Hints
+=====
-set(${PN}_LIBRARY "")
-set(${PN}_DEFINITIONS USING_${PN})
+The following variables can be set to guide the search for this package:
-check_required_components(${PN})
+``pybind11_DIR``
+ CMake variable, set to directory containing this Config file.
+``CMAKE_PREFIX_PATH``
+ CMake variable, set to root directory of this package.
+``PATH``
+ Environment variable, set to bin directory of this package.
+``CMAKE_DISABLE_FIND_PACKAGE_pybind11``
+ CMake variable, disables ``find_package(pybind11)`` when not ``REQUIRED``,
+ perhaps to force internal build.
-# make detectable the FindPythonLibsNew.cmake module
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
+Commands
+========
-include(pybind11Tools)
+pybind11_add_module
+^^^^^^^^^^^^^^^^^^^
-if(NOT (CMAKE_VERSION VERSION_LESS 3.0))
-#-----------------------------------------------------------------------------
-# Don't include targets if this file is being picked up by another
-# project which has already built this as a subproject
-#-----------------------------------------------------------------------------
-if(NOT TARGET ${PN}::pybind11)
- include("${CMAKE_CURRENT_LIST_DIR}/${PN}Targets.cmake")
+This module defines the following commands to assist with creating Python modules:
- find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED)
- set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
- set_property(TARGET ${PN}::embed APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES})
- if(WIN32 OR CYGWIN)
- set_property(TARGET ${PN}::module APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES})
- endif()
+.. code-block:: cmake
- if(CMAKE_VERSION VERSION_LESS 3.3)
- set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${PYBIND11_CPP_STANDARD}")
- else()
- set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:CXX>:${PYBIND11_CPP_STANDARD}>)
- endif()
+ pybind11_add_module(<target>
+ [STATIC|SHARED|MODULE]
+ [THIN_LTO] [OPT_SIZE] [NO_EXTRAS] [WITHOUT_SOBAI]
+ <files>...
+ )
- get_property(_iid TARGET ${PN}::pybind11 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
- get_property(_ill TARGET ${PN}::module PROPERTY INTERFACE_LINK_LIBRARIES)
- set(${PN}_INCLUDE_DIRS ${_iid})
- set(${PN}_LIBRARIES ${_ico} ${_ill})
+Add a module and setup all helpers. You can select the type of the library; the
+default is ``MODULE``. There are several options:
+
+``OPT_SIZE``
+ Optimize for size, even if the ``CMAKE_BUILD_TYPE`` is not ``RelSize``.
+``THIN_LTO``
+ Use thin TLO instead of regular if there's a choice (pybind11's selection
+ is disabled if ``CMAKE_INTERPROCEDURAL_OPTIMIZATIONS`` is set).
+``WITHOUT_SOABI``
+ Disable the SOABI component (``PYBIND11_NEWPYTHON`` mode only).
+``NO_EXTRAS``
+ Disable all extras, exit immediately after making the module.
+
+pybind11_strip
+^^^^^^^^^^^^^^
+
+.. code-block:: cmake
+
+ pybind11_strip(<target>)
+
+Strip a target after building it (linux/macOS), called by ``pybind11_add_module``.
+
+pybind11_extension
+^^^^^^^^^^^^^^^^^^
+
+.. code-block:: cmake
+
+ pybind11_extension(<target>)
+
+Sets the Python extension name correctly for Python on your platform, called by
+``pybind11_add_module``.
+
+pybind11_find_import(module)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: cmake
+
+ pybind11_find_import(<module> [VERSION <number>] [REQUIRED] [QUIET])
+
+See if a module is installed. Use the registered name (the one on PyPI). You
+can specify a ``VERSION``, and you can specify ``REQUIRED`` or ``QUIET``. Only available if
+``NOPYTHON`` mode is not active. Sets ``module_VERSION`` and ``module_FOUND``. Caches the
+result once a valid install is found.
+
+Suggested usage
+===============
+
+Using ``find_package`` with version info is not recommended except for release versions.
+
+.. code-block:: cmake
+
+ find_package(pybind11 CONFIG)
+ find_package(pybind11 2.0 EXACT CONFIG REQUIRED)
+
+#]=============================================================================]
+@PACKAGE_INIT@
+
+# Location of pybind11/pybind11.h
+set(pybind11_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
+
+set(pybind11_LIBRARY "")
+set(pybind11_DEFINITIONS USING_pybind11)
+set(pybind11_VERSION_TYPE "@pybind11_VERSION_TYPE@")
+
+check_required_components(pybind11)
+
+if(TARGET pybind11::python_link_helper)
+ # This has already been setup elsewhere, such as with a previous call or
+ # add_subdirectory
+ return()
endif()
+
+include("${CMAKE_CURRENT_LIST_DIR}/pybind11Targets.cmake")
+
+# Easier to use / remember
+add_library(pybind11::headers IMPORTED INTERFACE)
+set_target_properties(pybind11::headers PROPERTIES INTERFACE_LINK_LIBRARIES
+ pybind11::pybind11_headers)
+
+include("${CMAKE_CURRENT_LIST_DIR}/pybind11Common.cmake")
+
+if(NOT pybind11_FIND_QUIETLY)
+ message(
+ STATUS
+ "Found pybind11: ${pybind11_INCLUDE_DIR} (found version \"${pybind11_VERSION}\" ${pybind11_VERSION_TYPE})"
+ )
endif()
diff --git a/3rdparty/pybind11/tools/pybind11NewTools.cmake b/3rdparty/pybind11/tools/pybind11NewTools.cmake
new file mode 100644
index 00000000..357cc61c
--- /dev/null
+++ b/3rdparty/pybind11/tools/pybind11NewTools.cmake
@@ -0,0 +1,246 @@
+# tools/pybind11NewTools.cmake -- Build system for the pybind11 modules
+#
+# Copyright (c) 2020 Wenzel Jakob <wenzel@inf.ethz.ch> and Henry Schreiner
+#
+# All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+
+get_property(
+ is_config
+ TARGET pybind11::headers
+ PROPERTY IMPORTED)
+
+if(pybind11_FIND_QUIETLY)
+ set(_pybind11_quiet QUIET)
+endif()
+
+if(CMAKE_VERSION VERSION_LESS 3.12)
+ message(FATAL_ERROR "You cannot use the new FindPython module with CMake < 3.12")
+endif()
+
+if(NOT Python_FOUND
+ AND NOT Python3_FOUND
+ AND NOT Python2_FOUND)
+ if(NOT DEFINED Python_FIND_IMPLEMENTATIONS)
+ set(Python_FIND_IMPLEMENTATIONS CPython PyPy)
+ endif()
+
+ # GitHub Actions like activation
+ if(NOT DEFINED Python_ROOT_DIR AND DEFINED ENV{pythonLocation})
+ set(Python_ROOT_DIR "$ENV{pythonLocation}")
+ endif()
+
+ find_package(Python REQUIRED COMPONENTS Interpreter Development ${_pybind11_quiet})
+
+ # If we are in submodule mode, export the Python targets to global targets.
+ # If this behavior is not desired, FindPython _before_ pybind11.
+ if(NOT is_config)
+ set_property(TARGET Python::Python PROPERTY IMPORTED_GLOBAL TRUE)
+ set_property(TARGET Python::Interpreter PROPERTY IMPORTED_GLOBAL TRUE)
+ if(TARGET Python::Module)
+ set_property(TARGET Python::Module PROPERTY IMPORTED_GLOBAL TRUE)
+ endif()
+ endif()
+endif()
+
+if(Python_FOUND)
+ set(_Python
+ Python
+ CACHE INTERNAL "" FORCE)
+elseif(Python3_FOUND AND NOT Python2_FOUND)
+ set(_Python
+ Python3
+ CACHE INTERNAL "" FORCE)
+elseif(Python2_FOUND AND NOT Python3_FOUND)
+ set(_Python
+ Python2
+ CACHE INTERNAL "" FORCE)
+else()
+ message(AUTHOR_WARNING "Python2 and Python3 both present, pybind11 in "
+ "PYBIND11_NOPYTHON mode (manually activate to silence warning)")
+ set(_pybind11_nopython ON)
+ return()
+endif()
+
+if(PYBIND11_MASTER_PROJECT)
+ if(${_Python}_INTERPRETER_ID MATCHES "PyPy")
+ message(STATUS "PyPy ${${_Python}_PyPy_VERSION} (Py ${${_Python}_VERSION})")
+ else()
+ message(STATUS "${_Python} ${${_Python}_VERSION}")
+ endif()
+endif()
+
+# If a user finds Python, they may forget to include the Interpreter component
+# and the following two steps require it. It is highly recommended by CMake
+# when finding development libraries anyway, so we will require it.
+if(NOT DEFINED ${_Python}_EXECUTABLE)
+ message(
+ FATAL_ERROR
+ "${_Python} was found without the Interpreter component. Pybind11 requires this component.")
+
+endif()
+
+if(NOT DEFINED PYTHON_IS_DEBUG)
+ # Debug check - see https://stackoverflow.com/questions/646518/python-how-to-detect-debug-Interpreter
+ execute_process(
+ COMMAND "${${_Python}_EXECUTABLE}" "-c"
+ "import sys; sys.exit(hasattr(sys, 'gettotalrefcount'))"
+ RESULT_VARIABLE _PYTHON_IS_DEBUG)
+ set(PYTHON_IS_DEBUG
+ "${_PYTHON_IS_DEBUG}"
+ CACHE INTERNAL "Python debug status")
+endif()
+
+# Get the suffix - SO is deprecated, should use EXT_SUFFIX, but this is
+# required for PyPy3 (as of 7.3.1)
+if(NOT DEFINED PYTHON_MODULE_EXTENSION)
+ execute_process(
+ COMMAND
+ "${${_Python}_EXECUTABLE}" "-c"
+ "from distutils import sysconfig as s;print(s.get_config_var('EXT_SUFFIX') or s.get_config_var('SO'))"
+ OUTPUT_VARIABLE _PYTHON_MODULE_EXTENSION
+ ERROR_VARIABLE _PYTHON_MODULE_EXTENSION_ERR
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if(_PYTHON_MODULE_EXTENSION STREQUAL "")
+ message(
+ FATAL_ERROR "pybind11 could not query the module file extension, likely the 'distutils'"
+ "package is not installed. Full error message:\n${_PYTHON_MODULE_EXTENSION_ERR}")
+ endif()
+
+ # This needs to be available for the pybind11_extension function
+ set(PYTHON_MODULE_EXTENSION
+ "${_PYTHON_MODULE_EXTENSION}"
+ CACHE INTERNAL "")
+endif()
+
+# Python debug libraries expose slightly different objects before 3.8
+# https://docs.python.org/3.6/c-api/intro.html#debugging-builds
+# https://stackoverflow.com/questions/39161202/how-to-work-around-missing-pymodule-create2-in-amd64-win-python35-d-lib
+if(PYTHON_IS_DEBUG)
+ set_property(
+ TARGET pybind11::pybind11
+ APPEND
+ PROPERTY INTERFACE_COMPILE_DEFINITIONS Py_DEBUG)
+endif()
+
+# Check on every access - since Python2 and Python3 could have been used - do nothing in that case.
+
+if(DEFINED ${_Python}_INCLUDE_DIRS)
+ set_property(
+ TARGET pybind11::pybind11
+ APPEND
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${${_Python}_INCLUDE_DIRS}>)
+ set(pybind11_INCLUDE_DIRS
+ "${pybind11_INCLUDE_DIR}" "${${_Python}_INCLUDE_DIRS}"
+ CACHE INTERNAL "Directories where pybind11 and possibly Python headers are located")
+endif()
+
+if(DEFINED ${_Python}_VERSION AND ${_Python}_VERSION VERSION_LESS 3)
+ set_property(
+ TARGET pybind11::pybind11
+ APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES pybind11::python2_no_register)
+endif()
+
+# In CMake 3.18+, you can find these separately, so include an if
+if(TARGET ${_Python}::${_Python})
+ set_property(
+ TARGET pybind11::embed
+ APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES ${_Python}::${_Python})
+endif()
+
+# CMake 3.15+ has this
+if(TARGET ${_Python}::Module)
+ set_property(
+ TARGET pybind11::module
+ APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES ${_Python}::Module)
+else()
+ set_property(
+ TARGET pybind11::module
+ APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES pybind11::python_link_helper)
+endif()
+
+# WITHOUT_SOABI and WITH_SOABI will disable the custom extension handling used by pybind11.
+# WITH_SOABI is passed on to python_add_library.
+function(pybind11_add_module target_name)
+ cmake_parse_arguments(PARSE_ARGV 1 ARG
+ "STATIC;SHARED;MODULE;THIN_LTO;OPT_SIZE;NO_EXTRAS;WITHOUT_SOABI" "" "")
+
+ if(ARG_ADD_LIBRARY_STATIC)
+ set(type STATIC)
+ elseif(ARG_ADD_LIBRARY_SHARED)
+ set(type SHARED)
+ else()
+ set(type MODULE)
+ endif()
+
+ if("${_Python}" STREQUAL "Python")
+ python_add_library(${target_name} ${type} ${ARG_UNPARSED_ARGUMENTS})
+ elseif("${_Python}" STREQUAL "Python3")
+ python3_add_library(${target_name} ${type} ${ARG_UNPARSED_ARGUMENTS})
+ elseif("${_Python}" STREQUAL "Python2")
+ python2_add_library(${target_name} ${type} ${ARG_UNPARSED_ARGUMENTS})
+ else()
+ message(FATAL_ERROR "Cannot detect FindPython version: ${_Python}")
+ endif()
+
+ target_link_libraries(${target_name} PRIVATE pybind11::headers)
+
+ if(type STREQUAL "MODULE")
+ target_link_libraries(${target_name} PRIVATE pybind11::module)
+ else()
+ target_link_libraries(${target_name} PRIVATE pybind11::embed)
+ endif()
+
+ if(MSVC)
+ target_link_libraries(${target_name} PRIVATE pybind11::windows_extras)
+ endif()
+
+ if(DEFINED ${_Python}_VERSION AND ${_Python}_VERSION VERSION_LESS 3)
+ target_link_libraries(${target_name} PRIVATE pybind11::python2_no_register)
+ endif()
+
+ set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden"
+ CUDA_VISIBILITY_PRESET "hidden")
+
+ # If we don't pass a WITH_SOABI or WITHOUT_SOABI, use our own default handling of extensions
+ if("${type}" STREQUAL "MODULE" AND (NOT ARG_WITHOUT_SOABI OR NOT "WITH_SOABI" IN_LIST
+ ARG_UNPARSED_ARGUMENTS))
+ pybind11_extension(${target_name})
+ endif()
+
+ if(ARG_NO_EXTRAS)
+ return()
+ endif()
+
+ if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
+ if(ARG_THIN_LTO)
+ target_link_libraries(${target_name} PRIVATE pybind11::thin_lto)
+ else()
+ target_link_libraries(${target_name} PRIVATE pybind11::lto)
+ endif()
+ endif()
+
+ if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo)
+ # Strip unnecessary sections of the binary on Linux/macOS
+ pybind11_strip(${target_name})
+ endif()
+
+ if(MSVC)
+ target_link_libraries(${target_name} PRIVATE pybind11::windows_extras)
+ endif()
+
+ if(ARG_OPT_SIZE)
+ target_link_libraries(${target_name} PRIVATE pybind11::opt_size)
+ endif()
+endfunction()
+
+function(pybind11_extension name)
+ # The extension is precomputed
+ set_target_properties(${name} PROPERTIES PREFIX "" SUFFIX "${PYTHON_MODULE_EXTENSION}")
+
+endfunction()
diff --git a/3rdparty/pybind11/tools/pybind11Tools.cmake b/3rdparty/pybind11/tools/pybind11Tools.cmake
index 508e4742..23cff98e 100644
--- a/3rdparty/pybind11/tools/pybind11Tools.cmake
+++ b/3rdparty/pybind11/tools/pybind11Tools.cmake
@@ -1,119 +1,137 @@
# tools/pybind11Tools.cmake -- Build system for the pybind11 modules
#
-# Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch>
+# Copyright (c) 2020 Wenzel Jakob <wenzel.jakob@epfl.ch>
#
# All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
-cmake_minimum_required(VERSION 2.8.12)
+# Built-in in CMake 3.5+
+include(CMakeParseArguments)
-# Add a CMake parameter for choosing a desired Python version
-if(NOT PYBIND11_PYTHON_VERSION)
- set(PYBIND11_PYTHON_VERSION "" CACHE STRING "Python version to use for compiling modules")
+if(pybind11_FIND_QUIETLY)
+ set(_pybind11_quiet QUIET)
endif()
-set(Python_ADDITIONAL_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4)
-find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} REQUIRED)
-
-include(CheckCXXCompilerFlag)
-include(CMakeParseArguments)
-
-if(NOT PYBIND11_CPP_STANDARD AND NOT CMAKE_CXX_STANDARD)
- if(NOT MSVC)
- check_cxx_compiler_flag("-std=c++14" HAS_CPP14_FLAG)
+# If this is the first run, PYTHON_VERSION can stand in for PYBIND11_PYTHON_VERSION
+if(NOT DEFINED PYBIND11_PYTHON_VERSION AND DEFINED PYTHON_VERSION)
+ message(WARNING "Set PYBIND11_PYTHON_VERSION to search for a specific version, not "
+ "PYTHON_VERSION (which is an output). Assuming that is what you "
+ "meant to do and continuing anyway.")
+ set(PYBIND11_PYTHON_VERSION
+ "${PYTHON_VERSION}"
+ CACHE STRING "Python version to use for compiling modules")
+ unset(PYTHON_VERSION)
+ unset(PYTHON_VERSION CACHE)
+else()
+ # If this is set as a normal variable, promote it, otherwise, make an empty cache variable.
+ set(PYBIND11_PYTHON_VERSION
+ "${PYBIND11_PYTHON_VERSION}"
+ CACHE STRING "Python version to use for compiling modules")
+endif()
- if (HAS_CPP14_FLAG)
- set(PYBIND11_CPP_STANDARD -std=c++14)
- else()
- check_cxx_compiler_flag("-std=c++11" HAS_CPP11_FLAG)
- if (HAS_CPP11_FLAG)
- set(PYBIND11_CPP_STANDARD -std=c++11)
- else()
- message(FATAL_ERROR "Unsupported compiler -- pybind11 requires C++11 support!")
- endif()
+# A user can set versions manually too
+set(Python_ADDITIONAL_VERSIONS
+ "3.9;3.8;3.7;3.6;3.5;3.4"
+ CACHE INTERNAL "")
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
+find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED ${_pybind11_quiet})
+list(REMOVE_AT CMAKE_MODULE_PATH -1)
+
+# Cache variables so pybind11_add_module can be used in parent projects
+set(PYTHON_INCLUDE_DIRS
+ ${PYTHON_INCLUDE_DIRS}
+ CACHE INTERNAL "")
+set(PYTHON_LIBRARIES
+ ${PYTHON_LIBRARIES}
+ CACHE INTERNAL "")
+set(PYTHON_MODULE_PREFIX
+ ${PYTHON_MODULE_PREFIX}
+ CACHE INTERNAL "")
+set(PYTHON_MODULE_EXTENSION
+ ${PYTHON_MODULE_EXTENSION}
+ CACHE INTERNAL "")
+set(PYTHON_VERSION_MAJOR
+ ${PYTHON_VERSION_MAJOR}
+ CACHE INTERNAL "")
+set(PYTHON_VERSION_MINOR
+ ${PYTHON_VERSION_MINOR}
+ CACHE INTERNAL "")
+set(PYTHON_VERSION
+ ${PYTHON_VERSION}
+ CACHE INTERNAL "")
+set(PYTHON_IS_DEBUG
+ "${PYTHON_IS_DEBUG}"
+ CACHE INTERNAL "")
+
+if(PYBIND11_MASTER_PROJECT)
+ if(PYTHON_MODULE_EXTENSION MATCHES "pypy")
+ if(NOT DEFINED PYPY_VERSION)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} -c
+ [=[import sys; sys.stdout.write(".".join(map(str, sys.pypy_version_info[:3])))]=]
+ OUTPUT_VARIABLE pypy_version)
+ set(PYPY_VERSION
+ ${pypy_version}
+ CACHE INTERNAL "")
endif()
- elseif(MSVC)
- set(PYBIND11_CPP_STANDARD /std:c++14)
+ message(STATUS "PYPY ${PYPY_VERSION} (Py ${PYTHON_VERSION})")
+ else()
+ message(STATUS "PYTHON ${PYTHON_VERSION}")
endif()
-
- set(PYBIND11_CPP_STANDARD ${PYBIND11_CPP_STANDARD} CACHE STRING
- "C++ standard flag, e.g. -std=c++11, -std=c++14, /std:c++14. Defaults to C++14 mode." FORCE)
endif()
-# Checks whether the given CXX/linker flags can compile and link a cxx file. cxxflags and
-# linkerflags are lists of flags to use. The result variable is a unique variable name for each set
-# of flags: the compilation result will be cached base on the result variable. If the flags work,
-# sets them in cxxflags_out/linkerflags_out internal cache variables (in addition to ${result}).
-function(_pybind11_return_if_cxx_and_linker_flags_work result cxxflags linkerflags cxxflags_out linkerflags_out)
- set(CMAKE_REQUIRED_LIBRARIES ${linkerflags})
- check_cxx_compiler_flag("${cxxflags}" ${result})
- if (${result})
- set(${cxxflags_out} "${cxxflags}" CACHE INTERNAL "" FORCE)
- set(${linkerflags_out} "${linkerflags}" CACHE INTERNAL "" FORCE)
- endif()
-endfunction()
+# Only add Python for build - must be added during the import for config since it has to be re-discovered.
+set_property(
+ TARGET pybind11::pybind11
+ APPEND
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${PYTHON_INCLUDE_DIRS}>)
+
+set(pybind11_INCLUDE_DIRS
+ "${pybind11_INCLUDE_DIR}" "${PYTHON_INCLUDE_DIRS}"
+ CACHE INTERNAL "Directories where pybind11 and possibly Python headers are located")
+
+# Python debug libraries expose slightly different objects before 3.8
+# https://docs.python.org/3.6/c-api/intro.html#debugging-builds
+# https://stackoverflow.com/questions/39161202/how-to-work-around-missing-pymodule-create2-in-amd64-win-python35-d-lib
+if(PYTHON_IS_DEBUG)
+ set_property(
+ TARGET pybind11::pybind11
+ APPEND
+ PROPERTY INTERFACE_COMPILE_DEFINITIONS Py_DEBUG)
+endif()
-# Internal: find the appropriate link time optimization flags for this compiler
-function(_pybind11_add_lto_flags target_name prefer_thin_lto)
- if (NOT DEFINED PYBIND11_LTO_CXX_FLAGS)
- set(PYBIND11_LTO_CXX_FLAGS "" CACHE INTERNAL "")
- set(PYBIND11_LTO_LINKER_FLAGS "" CACHE INTERNAL "")
-
- if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
- set(cxx_append "")
- set(linker_append "")
- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT APPLE)
- # Clang Gold plugin does not support -Os; append -O3 to MinSizeRel builds to override it
- set(linker_append ";$<$<CONFIG:MinSizeRel>:-O3>")
- elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
- set(cxx_append ";-fno-fat-lto-objects")
- endif()
-
- if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND prefer_thin_lto)
- _pybind11_return_if_cxx_and_linker_flags_work(HAS_FLTO_THIN
- "-flto=thin${cxx_append}" "-flto=thin${linker_append}"
- PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
- endif()
-
- if (NOT HAS_FLTO_THIN)
- _pybind11_return_if_cxx_and_linker_flags_work(HAS_FLTO
- "-flto${cxx_append}" "-flto${linker_append}"
- PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
- endif()
- elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
- # Intel equivalent to LTO is called IPO
- _pybind11_return_if_cxx_and_linker_flags_work(HAS_INTEL_IPO
- "-ipo" "-ipo" PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
- elseif(MSVC)
- # cmake only interprets libraries as linker flags when they start with a - (otherwise it
- # converts /LTCG to \LTCG as if it was a Windows path). Luckily MSVC supports passing flags
- # with - instead of /, even if it is a bit non-standard:
- _pybind11_return_if_cxx_and_linker_flags_work(HAS_MSVC_GL_LTCG
- "/GL" "-LTCG" PYBIND11_LTO_CXX_FLAGS PYBIND11_LTO_LINKER_FLAGS)
- endif()
+set_property(
+ TARGET pybind11::module
+ APPEND
+ PROPERTY
+ INTERFACE_LINK_LIBRARIES pybind11::python_link_helper
+ "$<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Cygwin>>:$<BUILD_INTERFACE:${PYTHON_LIBRARIES}>>")
+
+if(PYTHON_VERSION VERSION_LESS 3)
+ set_property(
+ TARGET pybind11::pybind11
+ APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES pybind11::python2_no_register)
+endif()
- if (PYBIND11_LTO_CXX_FLAGS)
- message(STATUS "LTO enabled")
- else()
- message(STATUS "LTO disabled (not supported by the compiler and/or linker)")
- endif()
- endif()
+set_property(
+ TARGET pybind11::embed
+ APPEND
+ PROPERTY INTERFACE_LINK_LIBRARIES pybind11::pybind11 $<BUILD_INTERFACE:${PYTHON_LIBRARIES}>)
- # Enable LTO flags if found, except for Debug builds
- if (PYBIND11_LTO_CXX_FLAGS)
- target_compile_options(${target_name} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:${PYBIND11_LTO_CXX_FLAGS}>")
- endif()
- if (PYBIND11_LTO_LINKER_FLAGS)
- target_link_libraries(${target_name} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:${PYBIND11_LTO_LINKER_FLAGS}>")
- endif()
+function(pybind11_extension name)
+ # The prefix and extension are provided by FindPythonLibsNew.cmake
+ set_target_properties(${name} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
+ SUFFIX "${PYTHON_MODULE_EXTENSION}")
endfunction()
# Build a Python extension module:
# pybind11_add_module(<name> [MODULE | SHARED] [EXCLUDE_FROM_ALL]
-# [NO_EXTRAS] [SYSTEM] [THIN_LTO] source1 [source2 ...])
+# [NO_EXTRAS] [THIN_LTO] [OPT_SIZE] source1 [source2 ...])
#
function(pybind11_add_module target_name)
- set(options MODULE SHARED EXCLUDE_FROM_ALL NO_EXTRAS SYSTEM THIN_LTO)
+ set(options "MODULE;SHARED;EXCLUDE_FROM_ALL;NO_EXTRAS;SYSTEM;THIN_LTO;OPT_SIZE")
cmake_parse_arguments(ARG "${options}" "" "" ${ARGN})
if(ARG_MODULE AND ARG_SHARED)
@@ -126,102 +144,57 @@ function(pybind11_add_module target_name)
if(ARG_EXCLUDE_FROM_ALL)
set(exclude_from_all EXCLUDE_FROM_ALL)
+ else()
+ set(exclude_from_all "")
endif()
add_library(${target_name} ${lib_type} ${exclude_from_all} ${ARG_UNPARSED_ARGUMENTS})
- if(ARG_SYSTEM)
- set(inc_isystem SYSTEM)
- endif()
+ target_link_libraries(${target_name} PRIVATE pybind11::module)
- target_include_directories(${target_name} ${inc_isystem}
- PRIVATE ${PYBIND11_INCLUDE_DIR} # from project CMakeLists.txt
- PRIVATE ${pybind11_INCLUDE_DIR} # from pybind11Config
- PRIVATE ${PYTHON_INCLUDE_DIRS})
-
- # Python debug libraries expose slightly different objects
- # https://docs.python.org/3.6/c-api/intro.html#debugging-builds
- # https://stackoverflow.com/questions/39161202/how-to-work-around-missing-pymodule-create2-in-amd64-win-python35-d-lib
- if(PYTHON_IS_DEBUG)
- target_compile_definitions(${target_name} PRIVATE Py_DEBUG)
+ if(ARG_SYSTEM)
+ message(
+ STATUS
+ "Warning: this does not have an effect - use NO_SYSTEM_FROM_IMPORTED if using imported targets"
+ )
endif()
- # The prefix and extension are provided by FindPythonLibsNew.cmake
- set_target_properties(${target_name} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}")
- set_target_properties(${target_name} PROPERTIES SUFFIX "${PYTHON_MODULE_EXTENSION}")
+ pybind11_extension(${target_name})
# -fvisibility=hidden is required to allow multiple modules compiled against
# different pybind versions to work properly, and for some features (e.g.
# py::module_local). We force it on everything inside the `pybind11`
# namespace; also turning it on for a pybind module compilation here avoids
# potential warnings or issues from having mixed hidden/non-hidden types.
- set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden")
- set_target_properties(${target_name} PROPERTIES CUDA_VISIBILITY_PRESET "hidden")
-
- if(WIN32 OR CYGWIN)
- # Link against the Python shared library on Windows
- target_link_libraries(${target_name} PRIVATE ${PYTHON_LIBRARIES})
- elseif(APPLE)
- # It's quite common to have multiple copies of the same Python version
- # installed on one's system. E.g.: one copy from the OS and another copy
- # that's statically linked into an application like Blender or Maya.
- # If we link our plugin library against the OS Python here and import it
- # into Blender or Maya later on, this will cause segfaults when multiple
- # conflicting Python instances are active at the same time (even when they
- # are of the same version).
-
- # Windows is not affected by this issue since it handles DLL imports
- # differently. The solution for Linux and Mac OS is simple: we just don't
- # link against the Python library. The resulting shared library will have
- # missing symbols, but that's perfectly fine -- they will be resolved at
- # import time.
-
- target_link_libraries(${target_name} PRIVATE "-undefined dynamic_lookup")
-
- if(ARG_SHARED)
- # Suppress CMake >= 3.0 warning for shared libraries
- set_target_properties(${target_name} PROPERTIES MACOSX_RPATH ON)
- endif()
- endif()
-
- # Make sure C++11/14 are enabled
- if(CMAKE_VERSION VERSION_LESS 3.3)
- target_compile_options(${target_name} PUBLIC ${PYBIND11_CPP_STANDARD})
- else()
- target_compile_options(${target_name} PUBLIC $<$<COMPILE_LANGUAGE:CXX>:${PYBIND11_CPP_STANDARD}>)
- endif()
+ set_target_properties(${target_name} PROPERTIES CXX_VISIBILITY_PRESET "hidden"
+ CUDA_VISIBILITY_PRESET "hidden")
if(ARG_NO_EXTRAS)
return()
endif()
- _pybind11_add_lto_flags(${target_name} ${ARG_THIN_LTO})
-
- if (NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo)
- # Strip unnecessary sections of the binary on Linux/Mac OS
- if(CMAKE_STRIP)
- if(APPLE)
- add_custom_command(TARGET ${target_name} POST_BUILD
- COMMAND ${CMAKE_STRIP} -x $<TARGET_FILE:${target_name}>)
- else()
- add_custom_command(TARGET ${target_name} POST_BUILD
- COMMAND ${CMAKE_STRIP} $<TARGET_FILE:${target_name}>)
- endif()
+ if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
+ if(ARG_THIN_LTO)
+ target_link_libraries(${target_name} PRIVATE pybind11::thin_lto)
+ else()
+ target_link_libraries(${target_name} PRIVATE pybind11::lto)
endif()
endif()
+ if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo)
+ pybind11_strip(${target_name})
+ endif()
+
if(MSVC)
- # /MP enables multithreaded builds (relevant when there are many files), /bigobj is
- # needed for bigger binding projects due to the limit to 64k addressable sections
- target_compile_options(${target_name} PRIVATE /bigobj)
- if(CMAKE_VERSION VERSION_LESS 3.11)
- target_compile_options(${target_name} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/MP>)
- else()
- # Only set these options for C++ files. This is important so that, for
- # instance, projects that include other types of source files like CUDA
- # .cu files don't get these options propagated to nvcc since that would
- # cause the build to fail.
- target_compile_options(${target_name} PRIVATE $<$<NOT:$<CONFIG:Debug>>:$<$<COMPILE_LANGUAGE:CXX>:/MP>>)
- endif()
+ target_link_libraries(${target_name} PRIVATE pybind11::windows_extras)
+ endif()
+
+ if(ARG_OPT_SIZE)
+ target_link_libraries(${target_name} PRIVATE pybind11::opt_size)
endif()
endfunction()
+
+# Provide general way to call common Python commands in "common" file.
+set(_Python
+ PYTHON
+ CACHE INTERNAL "" FORCE)
diff --git a/3rdparty/pybind11/tools/pyproject.toml b/3rdparty/pybind11/tools/pyproject.toml
new file mode 100644
index 00000000..8fe2f47a
--- /dev/null
+++ b/3rdparty/pybind11/tools/pyproject.toml
@@ -0,0 +1,3 @@
+[build-system]
+requires = ["setuptools>=42", "wheel"]
+build-backend = "setuptools.build_meta"
diff --git a/3rdparty/pybind11/tools/setup_global.py.in b/3rdparty/pybind11/tools/setup_global.py.in
new file mode 100644
index 00000000..4cf040b2
--- /dev/null
+++ b/3rdparty/pybind11/tools/setup_global.py.in
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Setup script for pybind11-global (in the sdist or in tools/setup_global.py in the repository)
+# This package is targeted for easy use from CMake.
+
+import contextlib
+import glob
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+
+# Setuptools has to be before distutils
+from setuptools import setup
+
+from distutils.command.install_headers import install_headers
+
+class InstallHeadersNested(install_headers):
+ def run(self):
+ headers = self.distribution.headers or []
+ for header in headers:
+ # Remove pybind11/include/
+ short_header = header.split("/", 2)[-1]
+
+ dst = os.path.join(self.install_dir, os.path.dirname(short_header))
+ self.mkpath(dst)
+ (out, _) = self.copy_file(header, dst)
+ self.outfiles.append(out)
+
+
+main_headers = glob.glob("pybind11/include/pybind11/*.h")
+detail_headers = glob.glob("pybind11/include/pybind11/detail/*.h")
+cmake_files = glob.glob("pybind11/share/cmake/pybind11/*.cmake")
+headers = main_headers + detail_headers
+
+cmdclass = {"install_headers": InstallHeadersNested}
+$extra_cmd
+
+# This will _not_ affect installing from wheels,
+# only building wheels or installing from SDist.
+# Primarily intended on Windows, where this is sometimes
+# customized (for example, conda-forge uses Library/)
+base = os.environ.get("PYBIND11_GLOBAL_PREFIX", "")
+
+# Must have a separator
+if base and not base.endswith("/"):
+ base += "/"
+
+setup(
+ name="pybind11_global",
+ version="$version",
+ packages=[],
+ headers=headers,
+ data_files=[
+ (base + "share/cmake/pybind11", cmake_files),
+ (base + "include/pybind11", main_headers),
+ (base + "include/pybind11/detail", detail_headers),
+ ],
+ cmdclass=cmdclass,
+)
diff --git a/3rdparty/pybind11/tools/setup_main.py.in b/3rdparty/pybind11/tools/setup_main.py.in
new file mode 100644
index 00000000..2231a08f
--- /dev/null
+++ b/3rdparty/pybind11/tools/setup_main.py.in
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Setup script (in the sdist or in tools/setup_main.py in the repository)
+
+from setuptools import setup
+
+cmdclass = {}
+$extra_cmd
+
+setup(
+ name="pybind11",
+ version="$version",
+ download_url='https://github.com/pybind/pybind11/tarball/v$version',
+ packages=[
+ "pybind11",
+ "pybind11.include.pybind11",
+ "pybind11.include.pybind11.detail",
+ "pybind11.share.cmake.pybind11",
+ ],
+ package_data={
+ "pybind11": ["py.typed", "*.pyi"],
+ "pybind11.include.pybind11": ["*.h"],
+ "pybind11.include.pybind11.detail": ["*.h"],
+ "pybind11.share.cmake.pybind11": ["*.cmake"],
+ },
+ extras_require={
+ "global": ["pybind11_global==$version"]
+ },
+ entry_points={
+ "console_scripts": [
+ "pybind11-config = pybind11.__main__:main",
+ ]
+ },
+ cmdclass=cmdclass
+)