mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-29 00:22:00 +00:00
chore: cleanup
This commit is contained in:
parent
3e448c0b5e
commit
df115977df
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
@ -286,7 +286,10 @@ jobs:
|
|||||||
apt-get install -y git make cmake g++ libeigen3-dev python3-dev python3-pip python3-pytest
|
apt-get install -y git make cmake g++ libeigen3-dev python3-dev python3-pip python3-pytest
|
||||||
|
|
||||||
- name: Configure for install
|
- name: Configure for install
|
||||||
run: cmake -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0 .
|
run: >
|
||||||
|
cmake .
|
||||||
|
-DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0
|
||||||
|
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
|
||||||
|
|
||||||
- name: Make and install
|
- name: Make and install
|
||||||
run: make install
|
run: make install
|
||||||
@ -298,7 +301,11 @@ jobs:
|
|||||||
run: mkdir /build-tests
|
run: mkdir /build-tests
|
||||||
|
|
||||||
- name: Configure tests
|
- name: Configure tests
|
||||||
run: cmake -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") ../pybind11-tests -DPYBIND11_WERROR=ON
|
run: >
|
||||||
|
cmake ../pybind11-tests
|
||||||
|
-DDOWNLOAD_CATCH=ON
|
||||||
|
-DPYBIND11_WERROR=ON
|
||||||
|
-DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)")
|
||||||
working-directory: /build-tests
|
working-directory: /build-tests
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
# VERSION 3.7...3.18, but some versions of MCVS have a patched CMake 3.11
|
# The `cmake_minimum_required(VERSION 3.7...3.18)` syntax does not work with
|
||||||
# that do not work properly with this syntax, so using the following workaround:
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
|
# the behavior using the following workaround:
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
else()
|
else()
|
||||||
@ -26,7 +27,7 @@ foreach(ver ${pybind11_version_defines})
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(PYBIND11_VERSION_PATCH MATCHES [[([a-zA-Z]+)]])
|
if(PYBIND11_VERSION_PATCH MATCHES [[([a-zA-Z]+)]])
|
||||||
set(PYBIND11_VERSION_TYPE "${CMAKE_MATCH_1}")
|
set(pybind11_VERSION_TYPE "${CMAKE_MATCH_1}")
|
||||||
endif()
|
endif()
|
||||||
string(REGEX MATCH "[0-9]+" PYBIND11_VERSION_PATCH "${PYBIND11_VERSION_PATCH}")
|
string(REGEX MATCH "[0-9]+" PYBIND11_VERSION_PATCH "${PYBIND11_VERSION_PATCH}")
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ include(GNUInstallDirs)
|
|||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
|
|
||||||
message(STATUS "pybind11 v${pybind11_VERSION} ${PYBIND11_VERSION_TYPE}")
|
message(STATUS "pybind11 v${pybind11_VERSION} ${pybind11_VERSION_TYPE}")
|
||||||
|
|
||||||
# Check if pybind11 is being used directly or via add_subdirectory
|
# Check if pybind11 is being used directly or via add_subdirectory
|
||||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
@ -56,9 +57,11 @@ else()
|
|||||||
set(pybind11_system SYSTEM)
|
set(pybind11_system SYSTEM)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Options
|
||||||
option(PYBIND11_INSTALL "Install pybind11 header files?" ${PYBIND11_MASTER_PROJECT})
|
option(PYBIND11_INSTALL "Install pybind11 header files?" ${PYBIND11_MASTER_PROJECT})
|
||||||
option(PYBIND11_TEST "Build pybind11 test suite?" ${PYBIND11_MASTER_PROJECT})
|
option(PYBIND11_TEST "Build pybind11 test suite?" ${PYBIND11_MASTER_PROJECT})
|
||||||
option(PYBIND11_CLASSIC_LTO "Use the classic LTO flag algorithm, even on CMake 3.9+" OFF)
|
option(PYBIND11_CLASSIC_LTO "Use the classic LTO flag algorithm, even on CMake 3.9+" OFF)
|
||||||
|
|
||||||
cmake_dependent_option(
|
cmake_dependent_option(
|
||||||
USE_PYTHON_INCLUDE_DIR
|
USE_PYTHON_INCLUDE_DIR
|
||||||
"Install pybind11 headers in Python include directory instead of default installation prefix"
|
"Install pybind11 headers in Python include directory instead of default installation prefix"
|
||||||
@ -117,8 +120,7 @@ string(REPLACE "include/" "${CMAKE_CURRENT_SOURCE_DIR}/include/" PYBIND11_HEADER
|
|||||||
|
|
||||||
# Classic mode
|
# Classic mode
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/tools")
|
include("${CMAKE_CURRENT_LIST_DIR}/tools/pybind11Tools.cmake")
|
||||||
include(pybind11Tools)
|
|
||||||
|
|
||||||
# Cache variables so pybind11_add_module can be used in parent projects
|
# Cache variables so pybind11_add_module can be used in parent projects
|
||||||
set(PYBIND11_INCLUDE_DIR
|
set(PYBIND11_INCLUDE_DIR
|
||||||
@ -146,10 +148,6 @@ set(PYTHON_IS_DEBUG
|
|||||||
"${PYTHON_IS_DEBUG}"
|
"${PYTHON_IS_DEBUG}"
|
||||||
CACHE INTERNAL "")
|
CACHE INTERNAL "")
|
||||||
|
|
||||||
if(PYBIND11_TEST OR (BUILD_TESTING AND PYBIND11_MASTER_PROJECT))
|
|
||||||
add_subdirectory(tests)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(USE_PYTHON_INCLUDE_DIR)
|
if(USE_PYTHON_INCLUDE_DIR)
|
||||||
file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_INCLUDE_DIRS})
|
file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
@ -273,3 +271,7 @@ if(PYBIND11_INSTALL)
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(PYBIND11_TEST OR (BUILD_TESTING AND PYBIND11_MASTER_PROJECT))
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
# VERSION 3.7...3.18, but some versions of VS have a patched CMake 3.11
|
# The `cmake_minimum_required(VERSION 3.7...3.18)` syntax does not work with
|
||||||
# that do not work properly with this syntax, so using the following workaround:
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
|
# the behavior using the following workaround:
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
else()
|
else()
|
||||||
@ -18,6 +19,9 @@ endif()
|
|||||||
# There's no harm in including a project in a project
|
# There's no harm in including a project in a project
|
||||||
project(pybind11_tests CXX)
|
project(pybind11_tests CXX)
|
||||||
|
|
||||||
|
# Access FindCatch and more
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../tools")
|
||||||
|
|
||||||
option(PYBIND11_WERROR "Report all warnings as errors" OFF)
|
option(PYBIND11_WERROR "Report all warnings as errors" OFF)
|
||||||
option(DOWNLOAD_EIGEN "Download EIGEN (requires CMake 3.11+)" OFF)
|
option(DOWNLOAD_EIGEN "Download EIGEN (requires CMake 3.11+)" OFF)
|
||||||
set(PYBIND11_TEST_OVERRIDE
|
set(PYBIND11_TEST_OVERRIDE
|
||||||
@ -89,12 +93,8 @@ endif()
|
|||||||
|
|
||||||
# Skip test_async for Python < 3.5
|
# Skip test_async for Python < 3.5
|
||||||
list(FIND PYBIND11_TEST_FILES test_async.cpp PYBIND11_TEST_FILES_ASYNC_I)
|
list(FIND PYBIND11_TEST_FILES test_async.cpp PYBIND11_TEST_FILES_ASYNC_I)
|
||||||
if((PYBIND11_TEST_FILES_ASYNC_I GREATER -1) AND ("${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
|
if((PYBIND11_TEST_FILES_ASYNC_I GREATER -1) AND (PYTHON_VERSION VERSION_LESS 3.5))
|
||||||
VERSION_LESS 3.5))
|
message(STATUS "Skipping test_async because Python version ${PYTHON_VERSION} < 3.5")
|
||||||
message(
|
|
||||||
STATUS
|
|
||||||
"Skipping test_async because Python version ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} < 3.5"
|
|
||||||
)
|
|
||||||
list(REMOVE_AT PYBIND11_TEST_FILES ${PYBIND11_TEST_FILES_ASYNC_I})
|
list(REMOVE_AT PYBIND11_TEST_FILES ${PYBIND11_TEST_FILES_ASYNC_I})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ function(pybind11_add_build_test name)
|
|||||||
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
|
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
|
||||||
"-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}")
|
"-DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE}")
|
||||||
|
|
||||||
if(CMAKE_CXX_STANDARD)
|
if(DEFINED CMAKE_CXX_STANDARD)
|
||||||
list(APPEND build_options "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
|
list(APPEND build_options "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,4 +1,14 @@
|
|||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
|
# The `cmake_minimum_required(VERSION 3.7...3.18)` syntax does not work with
|
||||||
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
|
# the behavior using the following workaround:
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
||||||
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
|
else()
|
||||||
|
cmake_policy(VERSION 3.18)
|
||||||
|
endif()
|
||||||
|
|
||||||
project(test_installed_embed CXX)
|
project(test_installed_embed CXX)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "")
|
set(CMAKE_MODULE_PATH "")
|
||||||
|
@ -1,10 +1,21 @@
|
|||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
|
# The `cmake_minimum_required(VERSION 3.7...3.18)` syntax does not work with
|
||||||
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
|
# the behavior using the following workaround:
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
||||||
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
|
else()
|
||||||
|
cmake_policy(VERSION 3.18)
|
||||||
|
endif()
|
||||||
|
|
||||||
project(test_installed_module CXX)
|
project(test_installed_module CXX)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "")
|
set(CMAKE_MODULE_PATH "")
|
||||||
|
|
||||||
find_package(pybind11 CONFIG REQUIRED)
|
find_package(pybind11 CONFIG REQUIRED)
|
||||||
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
|
message(
|
||||||
|
STATUS "Found pybind11 v${pybind11_VERSION} ${pybind11_VERSION_TYPE}: ${pybind11_INCLUDE_DIRS}")
|
||||||
|
|
||||||
pybind11_add_module(test_cmake_build SHARED NO_EXTRAS ../main.cpp)
|
pybind11_add_module(test_cmake_build SHARED NO_EXTRAS ../main.cpp)
|
||||||
|
|
||||||
|
@ -1,4 +1,14 @@
|
|||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
|
# The `cmake_minimum_required(VERSION 3.7...3.18)` syntax does not work with
|
||||||
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
|
# the behavior using the following workaround:
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
||||||
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
|
else()
|
||||||
|
cmake_policy(VERSION 3.18)
|
||||||
|
endif()
|
||||||
|
|
||||||
project(test_installed_target CXX)
|
project(test_installed_target CXX)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "")
|
set(CMAKE_MODULE_PATH "")
|
||||||
|
@ -1,4 +1,14 @@
|
|||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
|
# The `cmake_minimum_required(VERSION 3.7...3.18)` syntax does not work with
|
||||||
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
|
# the behavior using the following workaround:
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
||||||
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
|
else()
|
||||||
|
cmake_policy(VERSION 3.18)
|
||||||
|
endif()
|
||||||
|
|
||||||
project(test_subdirectory_embed CXX)
|
project(test_subdirectory_embed CXX)
|
||||||
|
|
||||||
set(PYBIND11_INSTALL
|
set(PYBIND11_INSTALL
|
||||||
|
@ -1,4 +1,14 @@
|
|||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
|
# The `cmake_minimum_required(VERSION 3.7...3.18)` syntax does not work with
|
||||||
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
|
# the behavior using the following workaround:
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
||||||
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
|
else()
|
||||||
|
cmake_policy(VERSION 3.18)
|
||||||
|
endif()
|
||||||
|
|
||||||
project(test_subdirectory_module CXX)
|
project(test_subdirectory_module CXX)
|
||||||
|
|
||||||
add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11)
|
add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11)
|
||||||
|
@ -1,4 +1,14 @@
|
|||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
|
|
||||||
|
# The `cmake_minimum_required(VERSION 3.7...3.18)` syntax does not work with
|
||||||
|
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
|
||||||
|
# the behavior using the following workaround:
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
||||||
|
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
||||||
|
else()
|
||||||
|
cmake_policy(VERSION 3.18)
|
||||||
|
endif()
|
||||||
|
|
||||||
project(test_subdirectory_target CXX)
|
project(test_subdirectory_target CXX)
|
||||||
|
|
||||||
add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11)
|
add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11)
|
||||||
|
@ -140,6 +140,7 @@ string(REGEX REPLACE "\\." ";" _PYTHON_VERSION_LIST ${_PYTHON_VERSION_LIST})
|
|||||||
list(GET _PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
|
list(GET _PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
|
||||||
list(GET _PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR)
|
list(GET _PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR)
|
||||||
list(GET _PYTHON_VERSION_LIST 2 PYTHON_VERSION_PATCH)
|
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 '/'
|
# Make sure all directory separators are '/'
|
||||||
string(REGEX REPLACE "\\\\" "/" PYTHON_PREFIX "${PYTHON_PREFIX}")
|
string(REGEX REPLACE "\\\\" "/" PYTHON_PREFIX "${PYTHON_PREFIX}")
|
||||||
|
@ -1,62 +1,65 @@
|
|||||||
# pybind11Config.cmake
|
#[=============================================================================[.rst
|
||||||
# --------------------
|
|
||||||
#
|
pybind11Config.cmake
|
||||||
# PYBIND11 cmake module.
|
--------------------
|
||||||
# This module sets the following variables in your project::
|
|
||||||
#
|
PYBIND11 cmake module.
|
||||||
# pybind11_FOUND - true if pybind11 and all required components found on the system
|
This module sets the following variables in your project::
|
||||||
# pybind11_VERSION - pybind11 version in format Major.Minor.Release
|
|
||||||
# pybind11_INCLUDE_DIRS - Directories where pybind11 and python headers are located.
|
pybind11_FOUND - true if pybind11 and all required components found on the system
|
||||||
# pybind11_INCLUDE_DIR - Directory where pybind11 headers are located.
|
pybind11_VERSION - pybind11 version in format Major.Minor.Release
|
||||||
# pybind11_DEFINITIONS - Definitions necessary to use pybind11, namely USING_pybind11.
|
pybind11_INCLUDE_DIRS - Directories where pybind11 and python headers are located.
|
||||||
# pybind11_LIBRARIES - compile flags and python libraries (as needed) to link against.
|
pybind11_INCLUDE_DIR - Directory where pybind11 headers are located.
|
||||||
# pybind11_LIBRARY - empty.
|
pybind11_DEFINITIONS - Definitions necessary to use pybind11, namely USING_pybind11.
|
||||||
# CMAKE_MODULE_PATH - appends location of accompanying FindPythonLibsNew.cmake and
|
pybind11_LIBRARIES - compile flags and python libraries (as needed) to link against.
|
||||||
# pybind11Tools.cmake modules.
|
pybind11_LIBRARY - empty.
|
||||||
#
|
|
||||||
#
|
|
||||||
# Available components: None
|
Available components: None
|
||||||
#
|
|
||||||
#
|
|
||||||
# Exported targets::
|
Exported targets::
|
||||||
#
|
|
||||||
# If pybind11 is found, this module defines the following :prop_tgt:`IMPORTED`
|
If pybind11 is found, this module defines the following :prop_tgt:`IMPORTED`
|
||||||
# interface library targets::
|
interface library targets::
|
||||||
#
|
|
||||||
# pybind11::module - for extension modules
|
pybind11::module - for extension modules
|
||||||
# pybind11::embed - for embedding the Python interpreter
|
pybind11::embed - for embedding the Python interpreter
|
||||||
#
|
|
||||||
# Python headers, libraries (as needed by platform), and the C++ standard
|
Python headers, libraries (as needed by platform), and the C++ standard
|
||||||
# are attached to the target. Set PythonLibsNew variables to influence
|
are attached to the target.
|
||||||
# python detection and CMAKE_CXX_STANDARD (11 or 14) to influence standard
|
Classic mode::
|
||||||
# setting. ::
|
|
||||||
#
|
Set PythonLibsNew variables to influence python detection and
|
||||||
# find_package(pybind11 CONFIG REQUIRED)
|
CMAKE_CXX_STANDARD to influence standard setting. ::
|
||||||
# message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
|
|
||||||
#
|
find_package(pybind11 CONFIG REQUIRED)
|
||||||
# # Create an extension module
|
message(STATUS "Found pybind11 v${pybind11_VERSION} ${pybind11_VERSION_TYPE}: ${pybind11_INCLUDE_DIRS}")
|
||||||
# add_library(mylib MODULE main.cpp)
|
|
||||||
# target_link_libraries(mylib pybind11::module)
|
# Create an extension module
|
||||||
#
|
add_library(mylib MODULE main.cpp)
|
||||||
# # Or embed the Python interpreter into an executable
|
target_link_libraries(mylib pybind11::module)
|
||||||
# add_executable(myexe main.cpp)
|
|
||||||
# target_link_libraries(myexe pybind11::embed)
|
# Or embed the Python interpreter into an executable
|
||||||
#
|
add_executable(myexe main.cpp)
|
||||||
# Suggested usage::
|
target_link_libraries(myexe pybind11::embed)
|
||||||
#
|
|
||||||
# find_package with version info is not recommended except for release versions. ::
|
Suggested usage::
|
||||||
#
|
|
||||||
# find_package(pybind11 CONFIG)
|
find_package with version info is not recommended except for release versions. ::
|
||||||
# find_package(pybind11 2.0 EXACT CONFIG REQUIRED)
|
|
||||||
#
|
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
|
The following variables can be set to guide the search for this package::
|
||||||
# CMAKE_PREFIX_PATH - CMake variable, set to root directory of this package
|
|
||||||
# PATH - environment variable, set to bin directory of this package
|
pybind11_DIR - CMake variable, set to directory containing this Config file
|
||||||
# CMAKE_DISABLE_FIND_PACKAGE_pybind11 - CMake variable, disables
|
CMAKE_PREFIX_PATH - CMake variable, set to root directory of this package
|
||||||
# find_package(pybind11) when not REQUIRED, perhaps to force internal build
|
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
|
||||||
|
#]=============================================================================]
|
||||||
|
|
||||||
@PACKAGE_INIT@
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
@ -65,13 +68,12 @@ set(pybind11_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
|
|||||||
|
|
||||||
set(pybind11_LIBRARY "")
|
set(pybind11_LIBRARY "")
|
||||||
set(pybind11_DEFINITIONS USING_pybind11)
|
set(pybind11_DEFINITIONS USING_pybind11)
|
||||||
|
set(pybind11_VERSION_TYPE "@pybind11_VERSION_TYPE@")
|
||||||
|
|
||||||
check_required_components(pybind11)
|
check_required_components(pybind11)
|
||||||
|
|
||||||
# Make the FindPythonLibsNew.cmake module available
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
|
|
||||||
|
|
||||||
include(pybind11Tools)
|
include("${CMAKE_CURRENT_LIST_DIR}/pybind11Tools.cmake")
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# Don't include targets if this file is being picked up by another
|
# Don't include targets if this file is being picked up by another
|
||||||
@ -80,7 +82,9 @@ include(pybind11Tools)
|
|||||||
if(NOT TARGET pybind11::pybind11)
|
if(NOT TARGET pybind11::pybind11)
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/pybind11Targets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/pybind11Targets.cmake")
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED)
|
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED)
|
||||||
|
list(REMOVE_AT CMAKE_MODULE_PATH -1)
|
||||||
|
|
||||||
set_property(TARGET pybind11::pybind11 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
|
set_property(TARGET pybind11::pybind11 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
|
||||||
set_property(TARGET pybind11::pybind11 APPEND PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
|
set_property(TARGET pybind11::pybind11 APPEND PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
|
||||||
@ -93,4 +97,6 @@ if(NOT TARGET pybind11::pybind11)
|
|||||||
get_property(_ill TARGET pybind11::module PROPERTY INTERFACE_LINK_LIBRARIES)
|
get_property(_ill TARGET pybind11::module PROPERTY INTERFACE_LINK_LIBRARIES)
|
||||||
set(pybind11_INCLUDE_DIRS ${_iid})
|
set(pybind11_INCLUDE_DIRS ${_iid})
|
||||||
set(pybind11_LIBRARIES ${_ico} ${_ill})
|
set(pybind11_LIBRARIES ${_ico} ${_ill})
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/pybind11Tools.cmake")
|
||||||
endif()
|
endif()
|
||||||
|
@ -5,16 +5,6 @@
|
|||||||
# All rights reserved. Use of this source code is governed by a
|
# All rights reserved. Use of this source code is governed by a
|
||||||
# BSD-style license that can be found in the LICENSE file.
|
# BSD-style license that can be found in the LICENSE file.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.7)
|
|
||||||
|
|
||||||
# VERSION 3.7...3.18, but some versions of VS have a patched CMake 3.11
|
|
||||||
# that do not work properly with this syntax, so using the following workaround:
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.18)
|
|
||||||
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
|
|
||||||
else()
|
|
||||||
cmake_policy(VERSION 3.18)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Add a CMake parameter for choosing a desired Python version
|
# Add a CMake parameter for choosing a desired Python version
|
||||||
if(NOT PYBIND11_PYTHON_VERSION)
|
if(NOT PYBIND11_PYTHON_VERSION)
|
||||||
set(PYBIND11_PYTHON_VERSION
|
set(PYBIND11_PYTHON_VERSION
|
||||||
@ -26,10 +16,12 @@ endif()
|
|||||||
set(Python_ADDITIONAL_VERSIONS
|
set(Python_ADDITIONAL_VERSIONS
|
||||||
"3.9;3.8;3.7;3.6;3.5;3.4"
|
"3.9;3.8;3.7;3.6;3.5;3.4"
|
||||||
CACHE INTERNAL "")
|
CACHE INTERNAL "")
|
||||||
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} REQUIRED)
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
|
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED)
|
||||||
|
list(REMOVE_AT CMAKE_MODULE_PATH -1)
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
include(CMakeParseArguments)
|
|
||||||
|
|
||||||
# Warn or error if old variable name used
|
# Warn or error if old variable name used
|
||||||
if(PYBIND11_CPP_STANDARD)
|
if(PYBIND11_CPP_STANDARD)
|
||||||
@ -131,7 +123,7 @@ endfunction()
|
|||||||
#
|
#
|
||||||
function(pybind11_add_module target_name)
|
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)
|
||||||
cmake_parse_arguments(ARG "${options}" "" "" ${ARGN})
|
cmake_parse_arguments(PARSE_ARGV 2 ARG "${options}" "" "")
|
||||||
|
|
||||||
if(ARG_MODULE AND ARG_SHARED)
|
if(ARG_MODULE AND ARG_SHARED)
|
||||||
message(FATAL_ERROR "Can't be both MODULE and SHARED")
|
message(FATAL_ERROR "Can't be both MODULE and SHARED")
|
||||||
@ -185,9 +177,14 @@ function(pybind11_add_module target_name)
|
|||||||
_pybind11_add_lto_flags(${target_name} ${ARG_THIN_LTO})
|
_pybind11_add_lto_flags(${target_name} ${ARG_THIN_LTO})
|
||||||
else()
|
else()
|
||||||
include(CheckIPOSupported)
|
include(CheckIPOSupported)
|
||||||
check_ipo_supported(RESULT supported OUTPUT error)
|
check_ipo_supported(
|
||||||
|
RESULT supported
|
||||||
|
OUTPUT error
|
||||||
|
LANGUAGES CXX)
|
||||||
if(supported)
|
if(supported)
|
||||||
set_property(TARGET ${target_name} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
set_property(TARGET ${target_name} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||||
|
else()
|
||||||
|
message(WARNING "IPO is not supported: ${output}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user