summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-04-23 13:21:11 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-04-23 13:21:11 +0200
commit2f9489fbf4b6c4fa9814fb4e402293dbb957f869 (patch)
tree236fe63df264a8b91504a788432df466e7be904a
parent5f9fd9633b4efcd0b45012d5f1fa6529bfde9d65 (diff)
cmake: explicitly disallow source directory being equal to build directory
Causes frequent user confusion on Linux.
-rwxr-xr-x[-rw-r--r--]CMakeLists.txt1
-rwxr-xr-xcmake/opentrack-check-build-directory.cmake7
2 files changed, 8 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fef1baed..1d8d5aef 100644..100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 2.8.11)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/)
include(CMakeParseArguments)
+include(opentrack-check-build-directory)
include(opentrack-policy)
include(opentrack-qt)
include(opentrack-platform)
diff --git a/cmake/opentrack-check-build-directory.cmake b/cmake/opentrack-check-build-directory.cmake
new file mode 100755
index 00000000..a9351b6a
--- /dev/null
+++ b/cmake/opentrack-check-build-directory.cmake
@@ -0,0 +1,7 @@
+get_filename_component(_abs_src_path ${CMAKE_SOURCE_DIR} REALPATH)
+string(TOLOWER ${_abs_src_path} _abs_src_path)
+get_filename_component(_abs_build_path ${CMAKE_BINARY_DIR} REALPATH)
+string(TOLOWER ${_abs_build_path} _abs_build_path)
+if(_abs_src_path STREQUAL _abs_build_path)
+ message(FATAL_ERROR "source directory has to be different than build directory")
+endif()