|
| 1 | +# Adapated from ITKv4/CMake/PreventInSourceBuilds.cmake |
| 2 | +# |
| 3 | +# This function will prevent in-source builds |
| 4 | +function(AssureOutOfSourceBuilds) |
| 5 | + # make sure the user doesn't play dirty with symlinks |
| 6 | + get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH) |
| 7 | + get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH) |
| 8 | + |
| 9 | + # disallow in-source builds |
| 10 | + if("${srcdir}" STREQUAL "${bindir}") |
| 11 | + message("######################################################") |
| 12 | + message("# Cocos2d-x should not be configured & built in the Cocos2d-x source directory") |
| 13 | + message("# You must run cmake in a build directory.") |
| 14 | + message("# For example:") |
| 15 | + message("# mkdir Cocos ; cd Cocos") |
| 16 | + message("# download & unpack the Cocos2d-x tarball") |
| 17 | + message("# mkdir Cocos2d-x-Build") |
| 18 | + message("# this will create the following directory structure") |
| 19 | + message("#") |
| 20 | + message("# Cocos") |
| 21 | + message("# +--Cocos2d-x") |
| 22 | + message("# +--Cocos2d-x-Build") |
| 23 | + message("#") |
| 24 | + message("# Then you can proceed to configure and build") |
| 25 | + message("# by using the following commands") |
| 26 | + message("#") |
| 27 | + message("# cd Cocos2d-x-Build") |
| 28 | + message("# cmake ../Cocos2d-x # or ccmake, or cmake-gui ") |
| 29 | + message("# make") |
| 30 | + message("#") |
| 31 | + message("# NOTE: Given that you already tried to make an in-source build") |
| 32 | + message("# CMake have already created several files & directories") |
| 33 | + message("# in your source tree. run 'git status' to find them and") |
| 34 | + message("# remove them by doing:") |
| 35 | + message("#") |
| 36 | + message("# cd Cocos/Cocos2d-x") |
| 37 | + message("# git clean -n -d") |
| 38 | + message("# git clean -f -d") |
| 39 | + message("# git checkout --") |
| 40 | + message("#") |
| 41 | + message("######################################################") |
| 42 | + message(FATAL_ERROR "Quitting configuration") |
| 43 | + endif() |
| 44 | +endfunction() |
| 45 | + |
| 46 | +AssureOutOfSourceBuilds() |
| 47 | + |
0 commit comments