Skip to content

Commit a07d8a8

Browse files
committed
cmake: disallow in-source builds
1 parent 10787c6 commit a07d8a8

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
#
77
# ----------------------------------------------------------------------------
88

9+
# Disable in-source builds to prevent source tree corruption.
10+
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
11+
message(FATAL_ERROR "
12+
FATAL: In-source builds are not allowed.
13+
You should create separate directory for build files.
14+
")
15+
endif()
916

1017

1118
include(cmake/OpenCVMinDepVersions.cmake)
@@ -1386,13 +1393,6 @@ status("")
13861393

13871394
ocv_finalize_status()
13881395

1389-
# ----------------------------------------------------------------------------
1390-
# Warn in the case of in-source build
1391-
# ----------------------------------------------------------------------------
1392-
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
1393-
message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")
1394-
endif()
1395-
13961396
# ----------------------------------------------------------------------------
13971397
# CPack stuff
13981398
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)