Skip to content

Commit 3e2d0b7

Browse files
committed
fix: warn if source directory is dirty
1 parent 5e14480 commit 3e2d0b7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ foreach(target ${test_targets})
227227
pybind11_add_module(${target} THIN_LTO ${target}.cpp ${test_files} ${PYBIND11_HEADERS})
228228
pybind11_enable_warnings(${target})
229229

230+
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
231+
get_property(
232+
suffix
233+
TARGET ${target}
234+
PROPERTY SUFFIX)
235+
set(source_output "${CMAKE_CURRENT_SOURCE_DIR}/${target}${suffix}")
236+
if(suffix AND EXISTS "${source_output}")
237+
message(WARNING "Output file also in source directory; "
238+
"please remove to avoid confusion: ${source_output}")
239+
endif()
240+
endif()
241+
230242
if(MSVC)
231243
target_compile_options(${target} PRIVATE /utf-8)
232244
endif()

0 commit comments

Comments
 (0)