chore: cleanup
diff --git a/tools/FindPythonLibsNew.cmake b/tools/FindPythonLibsNew.cmake
index cf2a13f..cc56351 100644
--- a/tools/FindPythonLibsNew.cmake
+++ b/tools/FindPythonLibsNew.cmake
@@ -140,6 +140,7 @@
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}")
diff --git a/tools/pybind11Config.cmake.in b/tools/pybind11Config.cmake.in
index bcc74d6..a8b3cb1 100644
--- a/tools/pybind11Config.cmake.in
+++ b/tools/pybind11Config.cmake.in
@@ -1,62 +1,65 @@
-# 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 CMAKE_CXX_STANDARD (11 or 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
+
+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.
+
+
+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.
+Classic mode::
+
+Set PythonLibsNew variables to influence python detection and
+CMAKE_CXX_STANDARD to influence standard setting. ::
+
+ find_package(pybind11 CONFIG REQUIRED)
+ message(STATUS "Found pybind11 v${pybind11_VERSION} ${pybind11_VERSION_TYPE}: ${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
+#]=============================================================================]
@PACKAGE_INIT@
@@ -65,32 +68,35 @@
set(pybind11_LIBRARY "")
set(pybind11_DEFINITIONS USING_pybind11)
+set(pybind11_VERSION_TYPE "@pybind11_VERSION_TYPE@")
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
# project which has already built this as a subproject
#-----------------------------------------------------------------------------
if(NOT TARGET pybind11::pybind11)
- include("${CMAKE_CURRENT_LIST_DIR}/pybind11Targets.cmake")
+ include("${CMAKE_CURRENT_LIST_DIR}/pybind11Targets.cmake")
- find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE 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)
- 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_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
+ set_property(TARGET pybind11::pybind11 APPEND PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
- set_property(TARGET pybind11::embed APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES})
- set_property(TARGET pybind11::module APPEND PROPERTY INTERFACE_LINK_LIBRARIES
- "$<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Cygwin>>:$<BUILD_INTERFACE:${PYTHON_LIBRARIES}>>")
+ set_property(TARGET pybind11::embed APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES})
+ set_property(TARGET pybind11::module APPEND PROPERTY INTERFACE_LINK_LIBRARIES
+ "$<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:Cygwin>>:$<BUILD_INTERFACE:${PYTHON_LIBRARIES}>>")
- get_property(_iid TARGET pybind11::pybind11 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
- get_property(_ill TARGET pybind11::module PROPERTY INTERFACE_LINK_LIBRARIES)
- set(pybind11_INCLUDE_DIRS ${_iid})
- set(pybind11_LIBRARIES ${_ico} ${_ill})
+ get_property(_iid TARGET pybind11::pybind11 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+ get_property(_ill TARGET pybind11::module PROPERTY INTERFACE_LINK_LIBRARIES)
+ set(pybind11_INCLUDE_DIRS ${_iid})
+ set(pybind11_LIBRARIES ${_ico} ${_ill})
+
+ include("${CMAKE_CURRENT_LIST_DIR}/pybind11Tools.cmake")
endif()
diff --git a/tools/pybind11Tools.cmake b/tools/pybind11Tools.cmake
index 49876eb..258aaac 100644
--- a/tools/pybind11Tools.cmake
+++ b/tools/pybind11Tools.cmake
@@ -5,16 +5,6 @@
# 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 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
if(NOT PYBIND11_PYTHON_VERSION)
set(PYBIND11_PYTHON_VERSION
@@ -26,10 +16,12 @@
set(Python_ADDITIONAL_VERSIONS
"3.9;3.8;3.7;3.6;3.5;3.4"
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(CMakeParseArguments)
# Warn or error if old variable name used
if(PYBIND11_CPP_STANDARD)
@@ -131,7 +123,7 @@
#
function(pybind11_add_module target_name)
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)
message(FATAL_ERROR "Can't be both MODULE and SHARED")
@@ -185,9 +177,14 @@
_pybind11_add_lto_flags(${target_name} ${ARG_THIN_LTO})
else()
include(CheckIPOSupported)
- check_ipo_supported(RESULT supported OUTPUT error)
+ check_ipo_supported(
+ RESULT supported
+ OUTPUT error
+ LANGUAGES CXX)
if(supported)
set_property(TARGET ${target_name} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
+ else()
+ message(WARNING "IPO is not supported: ${output}")
endif()
endif()