Browse Source

cmake: Forbid in-source builds

Xenofon Karamanos 7 months ago
parent
commit
0afea1fd17
1 changed files with 11 additions and 0 deletions
  1. 11 0
      CMakeLists.txt

+ 11 - 0
CMakeLists.txt

@@ -10,6 +10,17 @@ project(
   HOMEPAGE_URL "https://www.kamailio.org"
 )
 
+# ---- Include guards ----
+
+if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
+  message(
+    FATAL_ERROR
+      "In-source builds not allowed. Please make a new directory (called a build directory) \
+and run CMake again accordingly.")
+endif()
+
+# ---- Project settings ----
+
 # Set the version number
 set(EXTRAVERSION "-dev1")
 set(RELEASE "${PROJECT_VERSION}${EXTRAVERSION}")