Skip to content

Commit 1caf1d0

Browse files
authored
fix: check list validity and add missing file (pybind#2352)
Added a check on CMake 3.12+ to make sure the file listing is up to date. And caught a missing file with it!
1 parent 4d90f1a commit 1caf1d0

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

CMakeLists.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ set(PYBIND11_HEADERS
8282
include/pybind11/eigen.h
8383
include/pybind11/embed.h
8484
include/pybind11/eval.h
85+
include/pybind11/iostream.h
8586
include/pybind11/functional.h
8687
include/pybind11/numpy.h
8788
include/pybind11/operators.h
@@ -90,9 +91,26 @@ set(PYBIND11_HEADERS
9091
include/pybind11/stl.h
9192
include/pybind11/stl_bind.h)
9293

93-
# TODO: compare with grep and warn if missmatched
94+
# Compare with grep and warn if mismatched
95+
if(PYBIND11_MASTER_PROJECT AND NOT CMAKE_VERSION VERSION_LESS 3.12)
96+
file(
97+
GLOB_RECURSE _pybind11_header_check
98+
LIST_DIRECTORIES false
99+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
100+
CONFIGURE_DEPENDS "include/pybind11/*.h")
101+
set(_pybind11_here_only ${PYBIND11_HEADERS})
102+
set(_pybind11_disk_only ${_pybind11_header_check})
103+
list(REMOVE_ITEM _pybind11_here_only ${_pybind11_header_check})
104+
list(REMOVE_ITEM _pybind11_disk_only ${PYBIND11_HEADERS})
105+
if(_pybind11_here_only)
106+
message(AUTHOR_WARNING "PYBIND11_HEADERS has extra files:" ${_pybind11_here_only})
107+
endif()
108+
if(_pybind11_disk_only)
109+
message(AUTHOR_WARNING "PYBIND11_HEADERS is missing files:" ${_pybind11_disk_only})
110+
endif()
111+
endif()
94112

95-
# cmake 3.12 added list(TRANSFORM <list> PREPEND
113+
# CMake 3.12 added list(TRANSFORM <list> PREPEND
96114
# But we can't use it yet
97115
string(REPLACE "include/" "${CMAKE_CURRENT_SOURCE_DIR}/include/" PYBIND11_HEADERS
98116
"${PYBIND11_HEADERS}")

0 commit comments

Comments
 (0)