2 # This function will prevent in-source builds
3 function(AssureOutOfSourceBuilds)
4 # make sure the user doesn't play dirty with symlinks
5 get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
6 get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)
8 # disallow in-source builds
9 if("${srcdir}" STREQUAL "${bindir}")
10 message("######################################################")
11 message("# lapack should not be configured & built in the lapack source directory")
12 message("# You must run cmake in a build directory.")
13 message("# For example:")
14 message("# mkdir lapack-Sandbox ; cd lapack-sandbox")
15 message("# git clone https://github.com/Reference-LAPACK/lapack.git # or download & unpack the source tarball")
16 message("# mkdir lapack-build")
17 message("# this will create the following directory structure")
19 message("# lapack-Sandbox")
20 message("# +--lapack")
21 message("# +--lapack-build")
23 message("# Then you can proceed to configure and build")
24 message("# by using the following commands")
26 message("# cd lapack-build")
27 message("# cmake ../lapack # or ccmake, or cmake-gui ")
30 message("# NOTE: Given that you already tried to make an in-source build")
31 message("# CMake have already created several files & directories")
32 message("# in your source tree. run 'git status' to find them and")
33 message("# remove them by doing:")
35 message("# cd lapack-Sandbox/lapack")
36 message("# git clean -n -d")
37 message("# git clean -f -d")
38 message("# git checkout --")
40 message("######################################################")
41 message(FATAL_ERROR "Quitting configuration")
45 AssureOutOfSourceBuilds()