Skip to content

Commit

Permalink
fix(cmake): use explicit variable for is config
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Aug 12, 2024
1 parent 6a3ca2d commit 3a3ab40
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ else()
set(PYBIND11_INSTALL OFF)
endif()

set(_pybind11_is_config OFF)
include("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11Common.cmake")
# https://github.com/jtojnar/cmake-snips/#concatenating-paths-when-building-pkg-config-files
# TODO: cmake 3.20 adds the cmake_path() function, which obsoletes this snippet
Expand Down
6 changes: 1 addition & 5 deletions tools/pybind11Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ endif()
# are in CONFIG mode, they should be "normal" targets instead.
# In CMake 3.11+ you can promote a target to global after you create it,
# which might be simpler than this check.
get_property(
is_config
TARGET pybind11::pybind11_headers
PROPERTY IMPORTED)
if(NOT is_config)
if(NOT _pybind11_is_config)
set(optional_global GLOBAL)
endif()

Expand Down
4 changes: 2 additions & 2 deletions tools/pybind11Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ you can either use the basic targets, or use the FindPython tools:
# Python method:
Python_add_library(MyModule2 src2.cpp)
target_link_libraries(MyModule2 pybind11::headers)
target_link_libraries(MyModule2 PUBLIC pybind11::headers)
set_target_properties(MyModule2 PROPERTIES
INTERPROCEDURAL_OPTIMIZATION ON
CXX_VISIBILITY_PRESET ON
Expand Down Expand Up @@ -222,7 +222,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/pybind11Targets.cmake")
add_library(pybind11::headers IMPORTED INTERFACE)
set_target_properties(pybind11::headers PROPERTIES INTERFACE_LINK_LIBRARIES
pybind11::pybind11_headers)

set(_pybind11_is_config ON)
include("${CMAKE_CURRENT_LIST_DIR}/pybind11Common.cmake")

if(NOT pybind11_FIND_QUIETLY)
Expand Down

0 comments on commit 3a3ab40

Please sign in to comment.