"vscode:/vscode.git/clone" did not exist on "93528f57f33c35c6ae81d2889037611c99445946"
pybind11Config.cmake.in 3.95 KB
Newer Older
Henry Schreiner's avatar
Henry Schreiner committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#[=============================================================================[.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
#]=============================================================================]
63
64
65

@PACKAGE_INIT@

66
67
# Location of pybind11/pybind11.h
set(pybind11_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
68

69
70
set(pybind11_LIBRARY "")
set(pybind11_DEFINITIONS USING_pybind11)
Henry Schreiner's avatar
Henry Schreiner committed
71
set(pybind11_VERSION_TYPE "@pybind11_VERSION_TYPE@")
72

73
check_required_components(pybind11)
74
75


Henry Schreiner's avatar
Henry Schreiner committed
76
include("${CMAKE_CURRENT_LIST_DIR}/pybind11Tools.cmake")
77
78
79
80
81

#-----------------------------------------------------------------------------
# Don't include targets if this file is being picked up by another
# project which has already built this as a subproject
#-----------------------------------------------------------------------------
82
if(NOT TARGET pybind11::pybind11)
Henry Schreiner's avatar
Henry Schreiner committed
83
84
85
86
87
  include("${CMAKE_CURRENT_LIST_DIR}/pybind11Targets.cmake")

  list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
  find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED)
  list(REMOVE_AT CMAKE_MODULE_PATH -1)
88

Henry Schreiner's avatar
Henry Schreiner committed
89
90
  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})
91

Henry Schreiner's avatar
Henry Schreiner committed
92
93
94
  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}>>")
95

Henry Schreiner's avatar
Henry Schreiner committed
96
97
98
99
  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})
100

Henry Schreiner's avatar
Henry Schreiner committed
101
  include("${CMAKE_CURRENT_LIST_DIR}/pybind11Tools.cmake")
102
endif()