mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 22:52:01 +00:00
fix: duplicate target names removed
This commit is contained in:
parent
df115977df
commit
da803eb0a5
@ -1,7 +1,7 @@
|
|||||||
add_custom_target(test_cmake_build)
|
add_custom_target(test_cmake_build)
|
||||||
|
|
||||||
function(pybind11_add_build_test name)
|
function(pybind11_add_build_test name)
|
||||||
cmake_parse_arguments(ARG "INSTALL" "" "" ${ARGN})
|
cmake_parse_arguments(PARSE_ARGV 1 ARG "INSTALL" "" "")
|
||||||
|
|
||||||
set(build_options
|
set(build_options
|
||||||
"-DCMAKE_PREFIX_PATH=${pybind11_BINARY_DIR}/mock_install"
|
"-DCMAKE_PREFIX_PATH=${pybind11_BINARY_DIR}/mock_install"
|
||||||
@ -14,10 +14,12 @@ function(pybind11_add_build_test name)
|
|||||||
|
|
||||||
if(NOT ARG_INSTALL)
|
if(NOT ARG_INSTALL)
|
||||||
list(APPEND build_options "-DPYBIND11_PROJECT_DIR=${pybind11_SOURCE_DIR}")
|
list(APPEND build_options "-DPYBIND11_PROJECT_DIR=${pybind11_SOURCE_DIR}")
|
||||||
|
else()
|
||||||
|
list(APPEND build_options "-DCMAKE_PREFIX_PATH=${pybind11_BINARY_DIR}/mock_install")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
test_${name}
|
test_build_${name}
|
||||||
${CMAKE_CTEST_COMMAND}
|
${CMAKE_CTEST_COMMAND}
|
||||||
--build-and-test
|
--build-and-test
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/${name}"
|
"${CMAKE_CURRENT_SOURCE_DIR}/${name}"
|
||||||
@ -32,13 +34,13 @@ function(pybind11_add_build_test name)
|
|||||||
--build-makeprogram
|
--build-makeprogram
|
||||||
${CMAKE_MAKE_PROGRAM}
|
${CMAKE_MAKE_PROGRAM}
|
||||||
--build-target
|
--build-target
|
||||||
check
|
check_${name}
|
||||||
--build-options
|
--build-options
|
||||||
${build_options})
|
${build_options})
|
||||||
if(ARG_INSTALL)
|
if(ARG_INSTALL)
|
||||||
add_dependencies(test_${name} mock_install)
|
add_dependencies(test_build_${name} mock_install)
|
||||||
endif()
|
endif()
|
||||||
add_dependencies(test_cmake_build test_${name})
|
add_dependencies(test_cmake_build test_build_${name})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
pybind11_add_build_test(subdirectory_function)
|
pybind11_add_build_test(subdirectory_function)
|
||||||
|
@ -11,15 +11,16 @@ endif()
|
|||||||
|
|
||||||
project(test_installed_embed CXX)
|
project(test_installed_embed CXX)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "")
|
|
||||||
find_package(pybind11 CONFIG REQUIRED)
|
find_package(pybind11 CONFIG REQUIRED)
|
||||||
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
|
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
|
||||||
|
|
||||||
add_executable(test_cmake_build ../embed.cpp)
|
add_executable(test_installed_embed ../embed.cpp)
|
||||||
target_link_libraries(test_cmake_build PRIVATE pybind11::embed)
|
target_link_libraries(test_installed_embed PRIVATE pybind11::embed)
|
||||||
|
set_target_properties(test_installed_embed PROPERTIES OUTPUT_NAME test_cmake_build)
|
||||||
|
|
||||||
# Do not treat includes from IMPORTED target as SYSTEM (Python headers in pybind11::embed).
|
# Do not treat includes from IMPORTED target as SYSTEM (Python headers in pybind11::embed).
|
||||||
# This may be needed to resolve header conflicts, e.g. between Python release and debug headers.
|
# This may be needed to resolve header conflicts, e.g. between Python release and debug headers.
|
||||||
set_target_properties(test_cmake_build PROPERTIES NO_SYSTEM_FROM_IMPORTED ON)
|
set_target_properties(test_installed_embed PROPERTIES NO_SYSTEM_FROM_IMPORTED ON)
|
||||||
|
|
||||||
add_custom_target(check $<TARGET_FILE:test_cmake_build> ${PROJECT_SOURCE_DIR}/../test.py)
|
add_custom_target(check_installed_embed $<TARGET_FILE:test_installed_embed>
|
||||||
|
${PROJECT_SOURCE_DIR}/../test.py)
|
||||||
|
@ -9,22 +9,21 @@ else()
|
|||||||
cmake_policy(VERSION 3.18)
|
cmake_policy(VERSION 3.18)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(test_installed_module CXX)
|
project(test_installed_function CXX)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "")
|
|
||||||
|
|
||||||
find_package(pybind11 CONFIG REQUIRED)
|
find_package(pybind11 CONFIG REQUIRED)
|
||||||
message(
|
message(
|
||||||
STATUS "Found pybind11 v${pybind11_VERSION} ${pybind11_VERSION_TYPE}: ${pybind11_INCLUDE_DIRS}")
|
STATUS "Found pybind11 v${pybind11_VERSION} ${pybind11_VERSION_TYPE}: ${pybind11_INCLUDE_DIRS}")
|
||||||
|
|
||||||
pybind11_add_module(test_cmake_build SHARED NO_EXTRAS ../main.cpp)
|
pybind11_add_module(test_installed_function SHARED NO_EXTRAS ../main.cpp)
|
||||||
|
set_target_properties(test_installed_function PROPERTIES OUTPUT_NAME test_cmake_build)
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
check
|
check_installed_function
|
||||||
${CMAKE_COMMAND}
|
${CMAKE_COMMAND}
|
||||||
-E
|
-E
|
||||||
env
|
env
|
||||||
PYTHONPATH=$<TARGET_FILE_DIR:test_cmake_build>
|
PYTHONPATH=$<TARGET_FILE_DIR:test_installed_function>
|
||||||
${PYTHON_EXECUTABLE}
|
${PYTHON_EXECUTABLE}
|
||||||
${PROJECT_SOURCE_DIR}/../test.py
|
${PROJECT_SOURCE_DIR}/../test.py
|
||||||
${PROJECT_NAME})
|
${PROJECT_NAME})
|
||||||
|
@ -11,29 +11,28 @@ endif()
|
|||||||
|
|
||||||
project(test_installed_target CXX)
|
project(test_installed_target CXX)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "")
|
|
||||||
|
|
||||||
find_package(pybind11 CONFIG REQUIRED)
|
find_package(pybind11 CONFIG REQUIRED)
|
||||||
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
|
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}")
|
||||||
|
|
||||||
add_library(test_cmake_build MODULE ../main.cpp)
|
add_library(test_installed_target MODULE ../main.cpp)
|
||||||
|
|
||||||
target_link_libraries(test_cmake_build PRIVATE pybind11::module)
|
target_link_libraries(test_installed_target PRIVATE pybind11::module)
|
||||||
|
set_target_properties(test_installed_target PROPERTIES OUTPUT_NAME test_cmake_build)
|
||||||
|
|
||||||
# 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_installed_target PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
|
||||||
SUFFIX "${PYTHON_MODULE_EXTENSION}")
|
SUFFIX "${PYTHON_MODULE_EXTENSION}")
|
||||||
|
|
||||||
# Do not treat includes from IMPORTED target as SYSTEM (Python headers in pybind11::module).
|
# Do not treat includes from IMPORTED target as SYSTEM (Python headers in pybind11::module).
|
||||||
# This may be needed to resolve header conflicts, e.g. between Python release and debug headers.
|
# This may be needed to resolve header conflicts, e.g. between Python release and debug headers.
|
||||||
set_target_properties(test_cmake_build PROPERTIES NO_SYSTEM_FROM_IMPORTED ON)
|
set_target_properties(test_installed_target PROPERTIES NO_SYSTEM_FROM_IMPORTED ON)
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
check
|
check_installed_target
|
||||||
${CMAKE_COMMAND}
|
${CMAKE_COMMAND}
|
||||||
-E
|
-E
|
||||||
env
|
env
|
||||||
PYTHONPATH=$<TARGET_FILE_DIR:test_cmake_build>
|
PYTHONPATH=$<TARGET_FILE_DIR:test_installed_target>
|
||||||
${PYTHON_EXECUTABLE}
|
${PYTHON_EXECUTABLE}
|
||||||
${PROJECT_SOURCE_DIR}/../test.py
|
${PROJECT_SOURCE_DIR}/../test.py
|
||||||
${PROJECT_NAME})
|
${PROJECT_NAME})
|
||||||
|
@ -19,10 +19,12 @@ set(PYBIND11_EXPORT_NAME test_export)
|
|||||||
add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11)
|
add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11)
|
||||||
|
|
||||||
# Test basic target functionality
|
# Test basic target functionality
|
||||||
add_executable(test_cmake_build ../embed.cpp)
|
add_executable(test_subdirectory_embed ../embed.cpp)
|
||||||
target_link_libraries(test_cmake_build PRIVATE pybind11::embed)
|
target_link_libraries(test_subdirectory_embed PRIVATE pybind11::embed)
|
||||||
|
set_target_properties(test_subdirectory_embed PROPERTIES OUTPUT_NAME test_cmake_build)
|
||||||
|
|
||||||
add_custom_target(check $<TARGET_FILE:test_cmake_build> ${PROJECT_SOURCE_DIR}/../test.py)
|
add_custom_target(check_subdirectory_embed $<TARGET_FILE:test_subdirectory_embed>
|
||||||
|
${PROJECT_SOURCE_DIR}/../test.py)
|
||||||
|
|
||||||
# Test custom export group -- PYBIND11_EXPORT_NAME
|
# Test custom export group -- PYBIND11_EXPORT_NAME
|
||||||
add_library(test_embed_lib ../embed.cpp)
|
add_library(test_embed_lib ../embed.cpp)
|
||||||
|
@ -9,17 +9,18 @@ else()
|
|||||||
cmake_policy(VERSION 3.18)
|
cmake_policy(VERSION 3.18)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(test_subdirectory_module CXX)
|
project(test_subdirectory_function CXX)
|
||||||
|
|
||||||
add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11)
|
add_subdirectory("${PYBIND11_PROJECT_DIR}" pybind11)
|
||||||
pybind11_add_module(test_cmake_build THIN_LTO ../main.cpp)
|
pybind11_add_module(test_subdirectory_function THIN_LTO ../main.cpp)
|
||||||
|
set_target_properties(test_subdirectory_function PROPERTIES OUTPUT_NAME test_cmake_build)
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
check
|
check_subdirectory_function
|
||||||
${CMAKE_COMMAND}
|
${CMAKE_COMMAND}
|
||||||
-E
|
-E
|
||||||
env
|
env
|
||||||
PYTHONPATH=$<TARGET_FILE_DIR:test_cmake_build>
|
PYTHONPATH=$<TARGET_FILE_DIR:test_subdirectory_function>
|
||||||
${PYTHON_EXECUTABLE}
|
${PYTHON_EXECUTABLE}
|
||||||
${PROJECT_SOURCE_DIR}/../test.py
|
${PROJECT_SOURCE_DIR}/../test.py
|
||||||
${PROJECT_NAME})
|
${PROJECT_NAME})
|
||||||
|
@ -13,20 +13,21 @@ project(test_subdirectory_target CXX)
|
|||||||
|
|
||||||
add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11)
|
add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11)
|
||||||
|
|
||||||
add_library(test_cmake_build MODULE ../main.cpp)
|
add_library(test_subdirectory_target MODULE ../main.cpp)
|
||||||
|
set_target_properties(test_subdirectory_target PROPERTIES OUTPUT_NAME test_cmake_build)
|
||||||
|
|
||||||
target_link_libraries(test_cmake_build PRIVATE pybind11::module)
|
target_link_libraries(test_subdirectory_target 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_subdirectory_target PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
|
||||||
SUFFIX "${PYTHON_MODULE_EXTENSION}")
|
SUFFIX "${PYTHON_MODULE_EXTENSION}")
|
||||||
|
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
check
|
check_subdirectory_target
|
||||||
${CMAKE_COMMAND}
|
${CMAKE_COMMAND}
|
||||||
-E
|
-E
|
||||||
env
|
env
|
||||||
PYTHONPATH=$<TARGET_FILE_DIR:test_cmake_build>
|
PYTHONPATH=$<TARGET_FILE_DIR:test_subdirectory_target>
|
||||||
${PYTHON_EXECUTABLE}
|
${PYTHON_EXECUTABLE}
|
||||||
${PROJECT_SOURCE_DIR}/../test.py
|
${PROJECT_SOURCE_DIR}/../test.py
|
||||||
${PROJECT_NAME})
|
${PROJECT_NAME})
|
||||||
|
Loading…
Reference in New Issue
Block a user