@@ -16,6 +16,29 @@ else()
1616 cmake_policy (VERSION 3.18)
1717endif ()
1818
19+ # Only needed for CMake < 3.5 support
20+ include (CMakeParseArguments)
21+
22+ # Filter out items; print an optional message if any items filtered
23+ #
24+ # Usage:
25+ # pybind11_filter_tests(LISTNAME file1.cpp file2.cpp ... MESSAGE "")
26+ #
27+ function (PYBIND11_FILTER_TESTS LISTNAME)
28+ cmake_parse_arguments (ARG "" "MESSAGE" "" ${ARGN} )
29+ set (PYBIND11_FILTER_TESTS_FOUND OFF )
30+ foreach (filename IN LISTS ARG_UNPARSED_ARGUMENTS)
31+ list (FIND ${LISTNAME} ${filename} FILE_FOUND)
32+ if (FILE_FOUND GREATER -1)
33+ list (REMOVE_AT PYBIND11_TEST_FILES ${FILE_FOUND} )
34+ set (PYBIND11_FILTER_TESTS_FOUND ON )
35+ endif ()
36+ endforeach ()
37+ if (PYBIND11_FILTER_TESTS_FOUND AND ARG_MESSAGE)
38+ message (STATUS "${ARG_MESSAGE} " )
39+ endif ()
40+ endfunction ()
41+
1942# New Python support
2043if (DEFINED Python_EXECUTABLE)
2144 set (PYTHON_EXECUTABLE "${Python_EXECUTABLE} " )
@@ -65,7 +88,7 @@ set(PYBIND11_TEST_FILES
6588 test_eigen.cpp
6689 test_enum.cpp
6790 test_eval.cpp
68- #AV this fails with PGI test_exceptions.cpp
91+ test_exceptions.cpp
6992 test_factory_constructors.cpp
7093 test_gil_scoped.cpp
7194 test_iostream.cpp
@@ -82,13 +105,12 @@ set(PYBIND11_TEST_FILES
82105 test_pickling.cpp
83106 test_pytypes.cpp
84107 test_sequences_and_iterators.cpp
85- #AV this fails with PGI test_smart_ptr.cpp
108+ test_smart_ptr.cpp
86109 test_stl.cpp
87110 test_stl_binders.cpp
88111 test_tagbased_polymorphic.cpp
89112 test_union.cpp
90- #AV this fails with PGI test_virtual_functions.cpp
91- )
113+ test_virtual_functions.cpp)
92114
93115# Invoking cmake with something like:
94116# cmake -DPYBIND11_TEST_OVERRIDE="test_callbacks.cpp;test_pickling.cpp" ..
@@ -98,11 +120,15 @@ if(PYBIND11_TEST_OVERRIDE)
98120 set (PYBIND11_TEST_FILES ${PYBIND11_TEST_OVERRIDE} )
99121endif ()
100122
101- # Skip test_async for Python < 3.5
102- list (FIND PYBIND11_TEST_FILES test_async.cpp PYBIND11_TEST_FILES_ASYNC_I)
103- if ((PYBIND11_TEST_FILES_ASYNC_I GREATER -1) AND (PYTHON_VERSION VERSION_LESS 3.5))
104- message (STATUS "Skipping test_async because Python version ${PYTHON_VERSION} < 3.5" )
105- list (REMOVE_AT PYBIND11_TEST_FILES ${PYBIND11_TEST_FILES_ASYNC_I} )
123+ if (PYTHON_VERSION VERSION_LESS 3.5)
124+ pybind11_filter_tests(PYBIND11_TEST_FILES test_async.cpp MESSAGE
125+ "Skipping test_async on Python 2" )
126+ endif ()
127+
128+ if (CMAKE_CXX_COMPILER_ID MATCHES "PGI" )
129+ pybind11_filter_tests(
130+ PYBIND11_TEST_FILES test_exceptions.cpp test_smart_ptr.cpp test_virtual_functions.cpp MESSAGE
131+ "Skipping tests that do not support PGI compilers" )
106132endif ()
107133
108134string (REPLACE ".cpp" ".py" PYBIND11_PYTEST_FILES "${PYBIND11_TEST_FILES} " )
0 commit comments