Skip to content

Commit

Permalink
cmake: disallow in-source builds
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Jul 21, 2017
1 parent 572c861 commit 777a008
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions CMakeLists.txt
Expand Up @@ -4,11 +4,16 @@
# From the off-tree build directory, invoke:
# $ cmake <PATH_TO_OPENCV_ROOT>
#
#
# - OCT-2008: Initial version <joseluisblancoc@gmail.com>
#
# ----------------------------------------------------------------------------

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

set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)

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

ocv_finalize_status()

# ----------------------------------------------------------------------------
# Warn in the case of in-source build
# ----------------------------------------------------------------------------
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")
endif()

# ----------------------------------------------------------------------------
# CPack stuff
# ----------------------------------------------------------------------------
Expand Down

0 comments on commit 777a008

Please sign in to comment.