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 ################################################################################