diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b85f4c9b0c..f389f2b343d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,17 @@ cmake_minimum_required(VERSION 3.14) +# +# Prevent in-source builds +# +if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR) + message(FATAL_ERROR + "\nin-source builds are not allowed: " + "build directory cannot be in the source directory path!\n" + "You MUST remove the file ${CMAKE_BINARY_DIR}/CMakeCache.txt and " + " the directory ${CMAKE_BINARY_DIR}/CMakeFiles/ to be able to build again.") +endif () + + ######################################################################## # # Set variables for AMReX versioning