From 568c6a3d85dca3add895652439d64432dfcaf1f3 Mon Sep 17 00:00:00 2001 From: Daniel McInnes Date: Wed, 24 Jul 2024 09:35:19 +1000 Subject: [PATCH] Don't allow in-source builds --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index aff1fcdd4..7c237d963 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,11 @@ # Copyright (C) 2023 Victron Energy B.V. # See LICENSE.txt for license information. # + +if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + message(FATAL_ERROR "In-source builds are not allowed. Build artifacts such as CMakeCache.txt created in ${CMAKE_SOURCE_DIR} will cause problems for future builds. Run 'git clean -fd' in ${CMAKE_SOURCE_DIR} to continue.") +endif() + cmake_minimum_required(VERSION 3.24) # earlier versions of cmake don't handle 'qt_add_qml_module' properly, you get errors at runtime like: "qrc:/main.qml:164 ApplicationContent is not a type\n" # CMAKE HINTS