diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2010-04-17 20:12:02 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2010-04-17 20:12:02 +0000 |
commit | 63e9c0ddf1d9cea90439896c007ca3b50a230d6d (patch) | |
tree | c89ca060499d812d14a426fc32ee6749f4e3c3c8 /CMakeLists.txt | |
parent | afd5eda46e8e98e13e6cb0c937e39835eef5a296 (diff) |
Prevent accidental in-source builds with CMake, and detect when there are
generated files from a previous in-source builds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101665 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2001c7125d..e91fb43f34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,26 @@ configure_file( set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) + message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite " +"the makefiles distributed with LLVM. Please create a directory and run cmake " +"from there, passing the path to this source directory as the last argument. " +"This process created the file `CMakeCache.txt' and the directory " +"`CMakeFiles'. Please delete them.") +endif() + +if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) + file(GLOB_RECURSE + tablegenned_files_on_include_dir + "${CLANG_SOURCE_DIR}/include/clang/*.inc") + if( tablegenned_files_on_include_dir ) + message(FATAL_ERROR "Apparently there is a previous in-source build, " +"probably as the result of running `configure' and `make' on " +"${CLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n" +"${tablegenned_files_on_include_dir}\nPlease clean the source directory.") + endif() +endif() + # Compute the Clang version from the contents of VER file(READ ${CMAKE_CURRENT_SOURCE_DIR}/VER CLANG_VERSION_DATA) string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION |