From 94dd3da2aa42680345594812e3d03442d5f7f3f9 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 9 May 2025 20:24:19 +0200 Subject: [PATCH] Prevent mixing in-tree and out-of-tree builds This is an easy pitfall to encounter when running an Android build. --- src/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 75d64d3449..1231f49baf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -375,6 +375,9 @@ endif() check_include_files(endian.h HAVE_ENDIAN_H) +if((NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) AND EXISTS "${PROJECT_SOURCE_DIR}/cmake_config.h") + message(FATAL_ERROR "You are doing an out-of-tree build, but build artifacts are left in-tree. This will break the build!") +endif() configure_file( "${PROJECT_SOURCE_DIR}/cmake_config.h.in" "${PROJECT_BINARY_DIR}/cmake_config.h"