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()