summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/CMake/PreventInSourceBuild.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Telegram/tdlib/td/CMake/PreventInSourceBuild.cmake')
-rw-r--r--protocols/Telegram/tdlib/td/CMake/PreventInSourceBuild.cmake14
1 files changed, 14 insertions, 0 deletions
diff --git a/protocols/Telegram/tdlib/td/CMake/PreventInSourceBuild.cmake b/protocols/Telegram/tdlib/td/CMake/PreventInSourceBuild.cmake
new file mode 100644
index 0000000000..1815e82a25
--- /dev/null
+++ b/protocols/Telegram/tdlib/td/CMake/PreventInSourceBuild.cmake
@@ -0,0 +1,14 @@
+function(prevent_in_source_build)
+ get_filename_component(REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
+ get_filename_component(REAL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" REALPATH)
+
+ if (REAL_BINARY_DIR STREQUAL REAL_SOURCE_DIR)
+ message(" Out-of-source build must be used. Remove the files already")
+ message(" created by CMake and rerun CMake from a new directory:")
+ message(" rm -rf CMakeFiles CMakeCache.txt")
+ message(" mkdir build")
+ message(" cd build")
+ message(" cmake ..")
+ message(FATAL_ERROR "In-source build failed.")
+ endif()
+endfunction()