From fad34678f1fd4fb8b562be9d4d3072efe26eeb9c Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sun, 14 Jan 2024 16:55:06 +0100 Subject: [PATCH] NEW: disallow in-source builds --- CMakeLists.txt | 3 +++ cmake/jkqtplotter_noInsourceBuilds.cmake | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 cmake/jkqtplotter_noInsourceBuilds.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cd941c1c5..01b1f82c11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,9 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) # Find includes in the build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) +# error message when user tries to make in-source build! +include(jkqtplotter_noInsourceBuilds) + # Common Includes for JKQtPlotter include(jkqtplotter_common_include) diff --git a/cmake/jkqtplotter_noInsourceBuilds.cmake b/cmake/jkqtplotter_noInsourceBuilds.cmake new file mode 100644 index 0000000000..8cd379a8c0 --- /dev/null +++ b/cmake/jkqtplotter_noInsourceBuilds.cmake @@ -0,0 +1,11 @@ +if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) + message(FATAL_ERROR + "\n" + "In-source builds are not allowed.\n" + "Instead, provide a path to build tree like so:\n" + "cmake -B \n" + "\n" + "To remove files you accidentally created execute:\n" + "rm -rf CMakeFiles CMakeCache.txt\n" + ) +endif()