Skip to content

Commit 777a008

Browse files
committed
cmake: disallow in-source builds
1 parent 572c861 commit 777a008

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

CMakeLists.txt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
# From the off-tree build directory, invoke:
55
# $ cmake <PATH_TO_OPENCV_ROOT>
66
#
7-
#
8-
# - OCT-2008: Initial version <joseluisblancoc@gmail.com>
9-
#
107
# ----------------------------------------------------------------------------
118

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()
16+
1217
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
1318

1419
# Following block can broke build in case of cross-compilng
@@ -1094,13 +1099,6 @@ status("")
10941099

10951100
ocv_finalize_status()
10961101

1097-
# ----------------------------------------------------------------------------
1098-
# Warn in the case of in-source build
1099-
# ----------------------------------------------------------------------------
1100-
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
1101-
message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")
1102-
endif()
1103-
11041102
# ----------------------------------------------------------------------------
11051103
# CPack stuff
11061104
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)