From d151eb56fcaddc0b1b797d1c4df5ee433520a817 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 3 Nov 2016 07:24:12 +0000 Subject: [PATCH] CMake: reject in-tree builds. We do not support clobbering the source tree with build products, nor recommend this in any documentation, and this already leads to weird bugs with the resource system. Show an explicit error in this case to avoid confusion. --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e004fc..3b1d50a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,12 @@ # cmake configuration +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + message(FATAL_ERROR + "In-tree builds are not supported; please perform an out-of-tree build:\n" + " rm -rf CMakeCache.txt CMakeFiles/\n" + " mkdir build && cd build && cmake ..") +endif() + cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) cmake_policy(VERSION 3.1.0) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}