mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
fix: reduce target collision in add_submodule mode (#2423)
* fix: reduce target collision in add_submodule mode Closes #2420 * fix: update CMakeLists.txt
This commit is contained in:
parent
56df3c4649
commit
c58f7b745b
@ -154,8 +154,10 @@ set(PYBIND11_INCLUDE_DIR
|
|||||||
# This section builds targets, but does *not* touch Python
|
# This section builds targets, but does *not* touch Python
|
||||||
|
|
||||||
# Build the headers-only target (no Python included):
|
# Build the headers-only target (no Python included):
|
||||||
add_library(headers INTERFACE)
|
# (long name used here to keep this from clashing in subdirectory mode)
|
||||||
add_library(pybind11::headers ALIAS headers) # to match exported target
|
add_library(pybind11_headers INTERFACE)
|
||||||
|
add_library(pybind11::pybind11_headers ALIAS pybind11_headers) # to match exported target
|
||||||
|
add_library(pybind11::headers ALIAS pybind11_headers) # easier to use/remember
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11Common.cmake")
|
include("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11Common.cmake")
|
||||||
|
|
||||||
@ -172,10 +174,10 @@ endif()
|
|||||||
|
|
||||||
# Fill in headers target
|
# Fill in headers target
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
headers ${pybind11_system} INTERFACE $<BUILD_INTERFACE:${PYBIND11_INCLUDE_DIR}>
|
pybind11_headers ${pybind11_system} INTERFACE $<BUILD_INTERFACE:${PYBIND11_INCLUDE_DIR}>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||||
|
|
||||||
target_compile_features(headers INTERFACE cxx_inheriting_constructors cxx_user_literals
|
target_compile_features(pybind11_headers INTERFACE cxx_inheriting_constructors cxx_user_literals
|
||||||
cxx_right_angle_brackets)
|
cxx_right_angle_brackets)
|
||||||
|
|
||||||
if(PYBIND11_INSTALL)
|
if(PYBIND11_INSTALL)
|
||||||
@ -222,7 +224,7 @@ if(PYBIND11_INSTALL)
|
|||||||
set(PYBIND11_EXPORT_NAME "${PROJECT_NAME}Targets")
|
set(PYBIND11_EXPORT_NAME "${PROJECT_NAME}Targets")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS headers EXPORT "${PYBIND11_EXPORT_NAME}")
|
install(TARGETS pybind11_headers EXPORT "${PYBIND11_EXPORT_NAME}")
|
||||||
|
|
||||||
install(
|
install(
|
||||||
EXPORT "${PYBIND11_EXPORT_NAME}"
|
EXPORT "${PYBIND11_EXPORT_NAME}"
|
||||||
|
@ -130,6 +130,11 @@ endif()
|
|||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/pybind11Targets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/pybind11Targets.cmake")
|
||||||
|
|
||||||
|
# Easier to use / remember
|
||||||
|
add_library(pybind11::headers IMPORTED INTERFACE)
|
||||||
|
set_target_properties(pybind11::headers PROPERTIES INTERFACE_LINK_LIBRARIES
|
||||||
|
pybind11::pybind11_headers)
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/pybind11Common.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/pybind11Common.cmake")
|
||||||
|
|
||||||
if(NOT pybind11_FIND_QUIETLY)
|
if(NOT pybind11_FIND_QUIETLY)
|
||||||
|
Loading…
Reference in New Issue
Block a user