From e8a9209577d4622a4dbfa3e617fbaa8ee3db9c74 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 29 Feb 2016 16:28:53 +0000 Subject: [PATCH] Add sanity check to make sure in-source CMake builds are disallowed. --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 234b6da0f..389c317a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,14 @@ set(z3_polluted_tree_msg " this with ``-n`` first to check which file(s) would be removed." ) +################################################################################ +# Sanity check - Disallow building in source +################################################################################ +if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + message(FATAL_ERROR "In source builds are not allowed. You should invoke " + "CMake from a different directory.") +endif() + ################################################################################ # Add our CMake module directory to the list of module search directories ################################################################################