2016-12-13 15:55:38 +00:00
|
|
|
# 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`
|
2017-03-23 12:32:54 +00:00
|
|
|
# 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
|
2016-12-13 15:55:38 +00:00
|
|
|
# are attached to the target. Set PythonLibsNew variables to influence
|
2020-04-26 01:10:53 +00:00
|
|
|
# python detection and CMAKE_CXX_STANDARD (11 or 14) to influence standard
|
|
|
|
# setting. ::
|
2016-12-13 15:55:38 +00:00
|
|
|
#
|
|
|
|
# find_package(pybind11 CONFIG REQUIRED)
|
2017-03-23 12:32:54 +00:00
|
|
|
# message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
|
|
|
|
#
|
|
|
|
# # Create an extension module
|
2016-12-13 15:55:38 +00:00
|
|
|
# add_library(mylib MODULE main.cpp)
|
2016-12-17 20:38:57 +00:00
|
|
|
# target_link_libraries(mylib pybind11::module)
|
2016-12-13 15:55:38 +00:00
|
|
|
#
|
2017-03-23 12:32:54 +00:00
|
|
|
# # Or embed the Python interpreter into an executable
|
|
|
|
# add_executable(myexe main.cpp)
|
|
|
|
# target_link_libraries(myexe pybind11::embed)
|
|
|
|
#
|
2016-12-13 15:55:38 +00:00
|
|
|
# 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@
|
|
|
|
|
2020-07-29 19:02:53 +00:00
|
|
|
# Location of pybind11/pybind11.h
|
|
|
|
set(pybind11_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
|
2016-12-13 15:55:38 +00:00
|
|
|
|
2020-07-29 19:02:53 +00:00
|
|
|
set(pybind11_LIBRARY "")
|
|
|
|
set(pybind11_DEFINITIONS USING_pybind11)
|
2016-12-13 15:55:38 +00:00
|
|
|
|
2020-07-29 19:02:53 +00:00
|
|
|
check_required_components(pybind11)
|
2016-12-13 15:55:38 +00:00
|
|
|
|
2020-07-29 19:02:53 +00:00
|
|
|
# Make the FindPythonLibsNew.cmake module available
|
2016-12-13 15:55:38 +00:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
|
|
|
|
|
|
|
|
include(pybind11Tools)
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Don't include targets if this file is being picked up by another
|
|
|
|
# project which has already built this as a subproject
|
|
|
|
#-----------------------------------------------------------------------------
|
2020-07-29 19:02:53 +00:00
|
|
|
if(NOT TARGET pybind11::pybind11)
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/pybind11Targets.cmake")
|
2016-12-13 15:55:38 +00:00
|
|
|
|
|
|
|
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED)
|
|
|
|
|
2020-07-29 19:02:53 +00:00
|
|
|
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}>>")
|
|
|
|
|
|
|
|
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})
|
2016-12-13 15:55:38 +00:00
|
|
|
endif()
|