Skip to content

Commit

Permalink
fix: Python include directory was missing from DIRS
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Nov 2, 2020
1 parent 06a5401 commit f4478cf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,14 @@ endif()
string(REPLACE "include/" "${CMAKE_CURRENT_SOURCE_DIR}/include/" PYBIND11_HEADERS
"${PYBIND11_HEADERS}")

# Cache variables so pybind11_add_module can be used in parent projects
set(PYBIND11_INCLUDE_DIR
# Cache variable so this can be used in parent projects
set(pybind11_INCLUDE_DIR
"${CMAKE_CURRENT_LIST_DIR}/include"
CACHE INTERNAL "Directory where pybind11 headers are located")

# Backward compatible variable for add_subdirectory mode
set(PYBIND11_INCLUDE_DIR
"${pybind11_INCLUDE_DIR}"
CACHE INTERNAL "")

# Note: when creating targets, you cannot use if statements at configure time -
Expand Down Expand Up @@ -259,8 +264,5 @@ endif()
if(NOT PYBIND11_MASTER_PROJECT)
set(pybind11_FOUND
TRUE
CACHE INTERNAL "true if pybind11 and all required components found on the system")
set(pybind11_INCLUDE_DIR
"${PYBIND11_INCLUDE_DIR}"
CACHE INTERNAL "Directory where pybind11 headers are located")
CACHE INTERNAL "True if pybind11 and all required components found on the system")
endif()
6 changes: 6 additions & 0 deletions tools/pybind11Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ 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:
Expand Down
3 changes: 3 additions & 0 deletions tools/pybind11NewTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ if(DEFINED ${_Python}_INCLUDE_DIRS)
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)
Expand Down
4 changes: 4 additions & 0 deletions tools/pybind11Tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ set_property(
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
Expand Down

0 comments on commit f4478cf

Please sign in to comment.