# CMakeLists.txt -- Build system for the pybind11 test suite
#
# Copyright (c) 2015 Wenzel Jakob <[email protected]>
#
# All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
cmake_minimum_required(VERSION 3.4)
# The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
# the behavior using the following workaround:
if(${CMAKE_VERSION} VERSION_LESS 3.21)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.21)
endif()
# Only needed for CMake < 3.5 support
include(CMakeParseArguments)
# Filter out items; print an optional message if any items filtered. This ignores extensions.
#
# Usage:
# pybind11_filter_tests(LISTNAME file1.cpp file2.cpp ... MESSAGE "")
#
macro(pybind11_filter_tests LISTNAME)
cmake_parse_arguments(ARG "" "MESSAGE" "" ${ARGN})
set(PYBIND11_FILTER_TESTS_FOUND OFF)
# Make a list of the test without any extensions, for easier filtering.
set(_TMP_ACTUAL_LIST "${${LISTNAME}};") # enforce ';' at the end to allow matching last item.
string(REGEX REPLACE "\\.[^.;]*;" ";" LIST_WITHOUT_EXTENSIONS "${_TMP_ACTUAL_LIST}")
foreach(filename IN LISTS ARG_UNPARSED_ARGUMENTS)
string(REGEX REPLACE "\\.[^.]*$" "" filename_no_ext ${filename})
# Search in the list without extensions.
list(FIND LIST_WITHOUT_EXTENSIONS ${filename_no_ext} _FILE_FOUND)
if(_FILE_FOUND GREATER -1)
list(REMOVE_AT ${LISTNAME} ${_FILE_FOUND}) # And remove from the list with extensions.
list(REMOVE_AT LIST_WITHOUT_EXTENSIONS ${_FILE_FOUND}
)# And our search list, to ensure it is in sync.
set(PYBIND11_FILTER_TESTS_FOUND ON)
endif()
endforeach()
if(PYBIND11_FILTER_TESTS_FOUND AND ARG_MESSAGE)
message(STATUS "${ARG_MESSAGE}")
endif()
endmacro()
macro(possibly_uninitialized)
foreach(VARNAME ${ARGN})
if(NOT DEFINED "${VARNAME}")
set("${VARNAME}" "")
endif()
endforeach()
endmacro()
# Function to add additional targets if any of the provided tests are found.
# Needles; Specifies the test names to look for.
# Additions; Specifies the additional test targets to add when any of the needles are found.
macro(tests_extra_targets needles additions)
# Add the index for this relation to the index extra targets map.
list(LENGTH PYBIND11_TEST_EXTRA_TARGETS PYBIND11_TEST_EXTRA_TARGETS_LEN)
list(APPEND PYBIND11_TEST_EXTRA_TARGETS ${PYBIND11_TEST_EXTRA_TARGETS_LEN})
# Add the test names to look for, and the associated test target additions.
set(PYBIND11_TEST_EXTRA_TARGETS_NEEDLES_${PYBIND11_TEST_EXTRA_TARGETS_LEN} ${needles})
set(PYBIND11_TEST_EXTRA_TARGETS_ADDITION_${PYBIND11_TEST_EXTRA_TARGETS_LEN} ${additions})
endmacro()
# New Python support
if(DEFINED Python_EXECUTABLE)
set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
set(PYTHON_VERSION "${Python_VERSION}")
endif()
# There's no harm in including a project in a project
project(pybind11_tests CXX)
# Access FindCatch and more
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../tools")
option(PYBIND11_WERROR "Report all warnings as errors" OFF)
option(DOWNLOAD_EIGEN "Download EIGEN (requires CMake 3.11+)" OFF)
option(PYBIND11_CUDA_TESTS "Enable building CUDA tests (requires CMake 3.12+)" OFF)
set(PYBIND11_TEST_OVERRIDE
""
CACHE STRING "Tests from ;-separated list of *.cpp files will be built instead of all tests")
set(PYBIND11_TEST_FILTER
""
CACHE STRING "Tests from ;-separated list of *.cpp files will be removed from all tests")
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
# We're being loaded directly, i.e. not via add_subdirectory, so make this
# work as its own project and load the pybind11Config to get the tools we need
find_package(pybind11 REQUIRED CONFIG)
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting tests build type to MinSizeRel as none was specified")
set(CMAKE_BUILD_TYPE
MinSizeRel
CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel"
"RelWithDebInfo")
endif()
if(PYBIND11_CUDA_TESTS)
enable_language(CUDA)
if(DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CUDA_STANDARD ${CMAKE_CXX_STANDARD})
endif()
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()
# Full set of test files (you can override these; see below, overrides ignore extension)
# Any test that has no extension is both .py and .cpp, so 'foo' will add 'foo.cpp' and 'foo.py'.
# Any test that has an extension is exclusively that and handled as such.
set(PYBIND11_TEST_FILES
test_async
test_buffers
test_builtin_casters
test_call_policies
test_callbacks
test_chrono
test_class
test_const_name
test_constants_and_functions
test_copy_move
test_custom_type_casters
test_custom_type_setup
test_docstring_options
test_eigen
test_enum
test_eval
test_exceptions
test_factory_constructors
test_gil_scoped
test_iostream
test_kwargs_and_defaults
test_local_bindings
test_methods_and_attributes
test_modules
test_multiple_inheritance
test_numpy_array
test_numpy_dtypes
test_numpy_vectorize
test_opaque_types
test_operator_overloading
test_pickling
test_pytypes
test_sequences_and_iterators
test_smart_ptr
test_stl
test_stl_binders
test_tagbased_polymorphic
test_thread
test_union
test_virtual_functions)
# Invoking cmake with something like:
# cmake -DPYBIND11_TEST_OVERRIDE="test_callbacks.cpp;test_pickling.cpp" ..
# lets you override the tests that get compiled and run. You can restore to all tests with:
# cmake -DPYBIND11_TEST_OVERRIDE= ..
if(PYBIND11_TEST_OVERRIDE)
# Instead of doing a direct override here, we iterate over the overrides without extension and
# match them against entries from the PYBIND11_TEST_FILES, anything that not matches goes into the filter list.
string(REGEX REPLACE "\\.[^.;]*;" ";" TEST_OVERRIDE_NO_EXT "${PYBIND11_TEST_OVERRIDE};")
string(REGEX REPLACE "\\.[^.;]*;" ";" TEST_FILES_NO_EXT "${PYBIND11_TEST_FILES};")
# This allows the override to be done with extensions, preserving backwards compatibility.
foreach(test_name ${TEST_FILES_NO_EXT})
if(NOT ${test_name} IN_LIST TEST_OVERRIDE_NO_EXT
)# If not in the whitelist, add to be filtered out.
list(APPEND PYBIND11_TEST_FILTER ${test_name})
endif()
endforeach()
endif()
# You can also filter tests:
if(PYBIND11_TEST_FILTER)
pybind11_filter_tests(PYBIND11_TEST_FILES ${PYBIND11_TEST_FILTER})
endif()
if(PYTHON_VERSION VERSION_LESS 3.5)
pybind11_filter_tests(PYBIND11_TEST_FILES test_async.cpp MESSAGE
"Skipping test_async on Python 2")
endif()
# Skip tests for CUDA check:
# /pybind11/tests/test_constants_and_functions.cpp(125):
# error: incompatible exception specifications
if(PYBIND11_CUDA_TESTS)
pybind11_filter_tests(
PYBIND11_TEST_FILES test_constants_and_functions.cpp MESSAGE
"Skipping test_constants_and_functions due to incompatible exception specifications")
endif()
# Now that the test filtering is complete, we need to split the list into the test for PYTEST
# and the list for the cpp targets.
set(PYBIND11_CPPTEST_FILES "")
set(PYBIND11_PYTEST_FILES "")
foreach(test_name ${PYBIND11_TEST_FILES})
if(test_name MATCHES "\\.py$") # Ends in .py, purely python test.
list(APPEND PYBIND11_PYTEST_FILES ${test_name})
elseif(test_name MATCHES "\\.cpp$") # Ends in .cpp, purely cpp test.
list(APPEND PYBIND11_CPPTEST_FILES ${test_name})
elseif(NOT test_name MATCHES "\\.") # No extension specified, assume both, add extension.
list(APPEND PYBIND11_PYTEST_FILES ${test_name}.py)
list(APPEND PYBIND11_CPPTEST_FILES ${test_name}.cpp)
else()
me
没有合适的资源?快使用搜索试试~ 我知道了~
Openpose编译时的pybind11
共236个文件
py:59个
cpp:48个
h:32个
需积分: 0 1 下载量 119 浏览量
2023-06-26
18:45:57
上传
评论
收藏 788KB ZIP 举报
温馨提示
Openpose编译时的pybind11
资源推荐
资源详情
资源评论
收起资源包目录
Openpose编译时的pybind11 (236个子文件)
setup.cfg 2KB
.clang-format 453B
.clang-tidy 2KB
pybind11Common.cmake 14KB
FindPythonLibsNew.cmake 10KB
pybind11NewTools.cmake 9KB
pybind11Tools.cmake 7KB
FindEigen3.cmake 3KB
FindCatch.cmake 2KB
CODEOWNERS 182B
test_class.cpp 22KB
test_virtual_functions.cpp 21KB
test_methods_and_attributes.cpp 20KB
test_pytypes.cpp 20KB
test_stl.cpp 20KB
test_sequences_and_iterators.cpp 19KB
test_numpy_array.cpp 19KB
test_numpy_dtypes.cpp 18KB
test_smart_ptr.cpp 18KB
test_eigen.cpp 17KB
test_factory_constructors.cpp 17KB
test_builtin_casters.cpp 15KB
test_interpreter.cpp 13KB
test_multiple_inheritance.cpp 12KB
test_copy_move.cpp 10KB
test_exceptions.cpp 10KB
test_operator_overloading.cpp 9KB
test_callbacks.cpp 9KB
test_kwargs_and_defaults.cpp 8KB
test_buffers.cpp 8KB
test_pickling.cpp 6KB
pybind11_cross_module_tests.cpp 6KB
test_custom_type_casters.cpp 6KB
test_constants_and_functions.cpp 6KB
test_enum.cpp 6KB
test_tagbased_polymorphic.cpp 4KB
test_stl_binders.cpp 4KB
test_numpy_vectorize.cpp 4KB
test_local_bindings.cpp 4KB
test_const_name.cpp 4KB
test_iostream.cpp 4KB
test_call_policies.cpp 4KB
test_modules.cpp 4KB
pybind11_tests.cpp 4KB
test_chrono.cpp 3KB
test_eval.cpp 3KB
test_opaque_types.cpp 3KB
test_docstring_options.cpp 2KB
test_thread.cpp 2KB
cross_module_gil_utils.cpp 2KB
test_gil_scoped.cpp 2KB
test_custom_type_setup.cpp 1KB
test_async.cpp 864B
embed.cpp 656B
catch.cpp 637B
test_union.cpp 603B
external_module.cpp 563B
main.cpp 152B
theme_overrides.css 254B
Doxyfile 653B
.gitignore 487B
pybind11.h 116KB
pytypes.h 75KB
numpy.h 70KB
cast.h 59KB
common.h 48KB
type_caster_base.h 41KB
eigen.h 29KB
class.h 27KB
stl_bind.h 26KB
internals.h 23KB
attr.h 23KB
init.h 17KB
stl.h 13KB
embed.h 11KB
constructor_stats.h 11KB
iostream.h 9KB
operators.h 9KB
chrono.h 8KB
gil.h 6KB
buffer_info.h 6KB
object.h 5KB
eval.h 5KB
descr.h 5KB
functional.h 4KB
filesystem.h 3KB
pybind11_tests.h 3KB
local_bindings.h 3KB
options.h 2KB
complex.h 2KB
typeid.h 1KB
test_exceptions.h 398B
common.h 120B
pybind11Config.cmake.in 7KB
setup_global.py.in 2KB
setup_main.py.in 1KB
cmake_uninstall.cmake.in 952B
MANIFEST.in 256B
pytest.ini 693B
pytest.ini 0B
共 236 条
- 1
- 2
- 3
资源评论
Python初级写手、阿胜
- 粉丝: 2
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功