mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
Rename target from pybind11::pybind11 to pybind11::module
Makes room for an eventual pybind11::embedded target.
This commit is contained in:
parent
0cbec5c96e
commit
71e8a7962c
@ -89,18 +89,18 @@ message(STATUS "pybind11 v${${PROJECT_NAME}_VERSION}")
|
|||||||
|
|
||||||
if(NOT (CMAKE_VERSION VERSION_LESS 3.0)) # CMake >= 3.0
|
if(NOT (CMAKE_VERSION VERSION_LESS 3.0)) # CMake >= 3.0
|
||||||
# Build an interface library target:
|
# Build an interface library target:
|
||||||
add_library(pybind11 INTERFACE)
|
add_library(module INTERFACE)
|
||||||
target_include_directories(pybind11 INTERFACE $<BUILD_INTERFACE:${PYBIND11_INCLUDE_DIR}>
|
target_include_directories(module INTERFACE $<BUILD_INTERFACE:${PYBIND11_INCLUDE_DIR}>
|
||||||
$<BUILD_INTERFACE:${PYTHON_INCLUDE_DIRS}>
|
$<BUILD_INTERFACE:${PYTHON_INCLUDE_DIRS}>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||||
if(WIN32 OR CYGWIN)
|
if(WIN32 OR CYGWIN)
|
||||||
target_link_libraries(pybind11 INTERFACE $<BUILD_INTERFACE:${PYTHON_LIBRARIES}>)
|
target_link_libraries(module INTERFACE $<BUILD_INTERFACE:${PYTHON_LIBRARIES}>)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
target_link_libraries(pybind11 INTERFACE "-undefined dynamic_lookup")
|
target_link_libraries(module INTERFACE "-undefined dynamic_lookup")
|
||||||
endif()
|
endif()
|
||||||
target_compile_options(pybind11 INTERFACE $<BUILD_INTERFACE:${PYBIND11_CPP_STANDARD}>)
|
target_compile_options(module INTERFACE $<BUILD_INTERFACE:${PYBIND11_CPP_STANDARD}>)
|
||||||
|
|
||||||
add_library(pybind11::pybind11 ALIAS pybind11) # to match exported target
|
add_library(pybind11::module ALIAS module) # to match exported target
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (PYBIND11_INSTALL)
|
if (PYBIND11_INSTALL)
|
||||||
@ -122,7 +122,7 @@ if (PYBIND11_INSTALL)
|
|||||||
DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
|
DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
|
||||||
|
|
||||||
if(NOT (CMAKE_VERSION VERSION_LESS 3.0))
|
if(NOT (CMAKE_VERSION VERSION_LESS 3.0))
|
||||||
install(TARGETS pybind11
|
install(TARGETS module
|
||||||
EXPORT "${PROJECT_NAME}Targets")
|
EXPORT "${PROJECT_NAME}Targets")
|
||||||
install(EXPORT "${PROJECT_NAME}Targets"
|
install(EXPORT "${PROJECT_NAME}Targets"
|
||||||
NAMESPACE "${PROJECT_NAME}::"
|
NAMESPACE "${PROJECT_NAME}::"
|
||||||
|
@ -142,7 +142,7 @@ Advanced: interface library target
|
|||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
When using a version of CMake greater than 3.0, pybind11 can additionally
|
When using a version of CMake greater than 3.0, pybind11 can additionally
|
||||||
be used as a special *interface library* . The target ``pybind11::pybind11``
|
be used as a special *interface library* . The target ``pybind11::module``
|
||||||
is available with pybind11 headers, Python headers and libraries as needed,
|
is available with pybind11 headers, Python headers and libraries as needed,
|
||||||
and C++ compile definitions attached. This target is suitable for linking
|
and C++ compile definitions attached. This target is suitable for linking
|
||||||
to an independently constructed (through ``add_library``, not
|
to an independently constructed (through ``add_library``, not
|
||||||
@ -156,7 +156,7 @@ to an independently constructed (through ``add_library``, not
|
|||||||
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
|
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
|
||||||
|
|
||||||
add_library(example MODULE main.cpp)
|
add_library(example MODULE main.cpp)
|
||||||
target_link_libraries(example PRIVATE pybind11::pybind11)
|
target_link_libraries(example PRIVATE pybind11::module)
|
||||||
set_target_properties(example PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
|
set_target_properties(example PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
|
||||||
SUFFIX "${PYTHON_MODULE_EXTENSION}")
|
SUFFIX "${PYTHON_MODULE_EXTENSION}")
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
|
|||||||
|
|
||||||
add_library(test_cmake_build MODULE ../main.cpp)
|
add_library(test_cmake_build MODULE ../main.cpp)
|
||||||
|
|
||||||
target_link_libraries(test_cmake_build PRIVATE pybind11::pybind11)
|
target_link_libraries(test_cmake_build PRIVATE pybind11::module)
|
||||||
|
|
||||||
# make sure result is, for example, test_installed_target.so, not libtest_installed_target.dylib
|
# make sure result is, for example, test_installed_target.so, not libtest_installed_target.dylib
|
||||||
set_target_properties(test_cmake_build PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
|
set_target_properties(test_cmake_build PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
|
||||||
|
@ -5,7 +5,7 @@ add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11)
|
|||||||
|
|
||||||
add_library(test_cmake_build MODULE ../main.cpp)
|
add_library(test_cmake_build MODULE ../main.cpp)
|
||||||
|
|
||||||
target_link_libraries(test_cmake_build PRIVATE pybind11::pybind11)
|
target_link_libraries(test_cmake_build PRIVATE pybind11::module)
|
||||||
|
|
||||||
# make sure result is, for example, test_installed_target.so, not libtest_installed_target.dylib
|
# make sure result is, for example, test_installed_target.so, not libtest_installed_target.dylib
|
||||||
set_target_properties(test_cmake_build PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
|
set_target_properties(test_cmake_build PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
|
||||||
|
@ -26,12 +26,12 @@
|
|||||||
# python detection and PYBIND11_CPP_STANDARD (-std=c++11 or -std=c++14) to
|
# python detection and PYBIND11_CPP_STANDARD (-std=c++11 or -std=c++14) to
|
||||||
# influence standard setting. ::
|
# influence standard setting. ::
|
||||||
#
|
#
|
||||||
# pybind11::pybind11 - the main pybind11 interface library (i.e., headers)
|
# pybind11::module - the main pybind11 interface library for extension modules (i.e., headers)
|
||||||
#
|
#
|
||||||
# find_package(pybind11 CONFIG REQUIRED)
|
# find_package(pybind11 CONFIG REQUIRED)
|
||||||
# message(STATUS "Found pybind11: ${pybind11_INCLUDE_DIR} (found version ${pybind11_VERSION} & Py${PYTHON_VERSION_STRING})")
|
# message(STATUS "Found pybind11: ${pybind11_INCLUDE_DIR} (found version ${pybind11_VERSION} & Py${PYTHON_VERSION_STRING})")
|
||||||
# add_library(mylib MODULE main.cpp)
|
# add_library(mylib MODULE main.cpp)
|
||||||
# target_link_libraries(mylib pybind11::pybind11)
|
# target_link_libraries(mylib pybind11::module)
|
||||||
#
|
#
|
||||||
# Suggested usage::
|
# Suggested usage::
|
||||||
#
|
#
|
||||||
@ -75,17 +75,17 @@ if(NOT TARGET ${PN}::pybind11)
|
|||||||
include("${CMAKE_CURRENT_LIST_DIR}/${PN}Targets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/${PN}Targets.cmake")
|
||||||
|
|
||||||
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED)
|
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED)
|
||||||
set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
|
set_property(TARGET ${PN}::module APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
|
||||||
if(WIN32 OR CYGWIN)
|
if(WIN32 OR CYGWIN)
|
||||||
set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES})
|
set_property(TARGET ${PN}::module APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
select_cxx_standard()
|
select_cxx_standard()
|
||||||
set_property(TARGET ${PN}::pybind11 APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${PYBIND11_CPP_STANDARD}")
|
set_property(TARGET ${PN}::module APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "${PYBIND11_CPP_STANDARD}")
|
||||||
|
|
||||||
get_property(_iid TARGET ${PN}::pybind11 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
get_property(_iid TARGET ${PN}::module PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
get_property(_ill TARGET ${PN}::pybind11 PROPERTY INTERFACE_LINK_LIBRARIES)
|
get_property(_ill TARGET ${PN}::module PROPERTY INTERFACE_LINK_LIBRARIES)
|
||||||
get_property(_ico TARGET ${PN}::pybind11 PROPERTY INTERFACE_COMPILE_OPTIONS)
|
get_property(_ico TARGET ${PN}::module PROPERTY INTERFACE_COMPILE_OPTIONS)
|
||||||
set(${PN}_INCLUDE_DIRS ${_iid})
|
set(${PN}_INCLUDE_DIRS ${_iid})
|
||||||
set(${PN}_LIBRARIES ${_ico} ${_ill})
|
set(${PN}_LIBRARIES ${_ico} ${_ill})
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user