From 60e557a71103264dd95edf2c5d8ea5cbced3ca53 Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Sun, 27 Sep 2015 12:21:56 +1000 Subject: [PATCH] Disable CMake in-source build --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2c527a..a7796fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,18 @@ cmake_minimum_required(VERSION 2.8.5) +# Make sure the user doesn't play dirty with symlinks +get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH) +get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH) + +# Disallow in-source builds +if(${srcdir} STREQUAL ${bindir}) + message(FATAL_ERROR "In-source builds are not allowed." + " Please create a directory and run cmake from there, passing the path" + " to this source directory as the last argument. This process created" + " the file `CMakeCache.txt' and the directory `CMakeFiles' in ${srcdir}." + " Please remove them.") +endif() + project(gmt_makemap CXX) if(NOT CMAKE_BUILD_TYPE)