PreventInSourceBuilds.cmake 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. # disallow in-source builds
  9. if("${srcdir}" STREQUAL "${bindir}")
  10. message("######################################################")
  11. message("# Cocos2d-x should not be configured & built in the Cocos2d-x source directory")
  12. message("# You must run cmake in a build directory.")
  13. message("# For example:")
  14. message("# mkdir Cocos ; cd Cocos")
  15. message("# download & unpack the Cocos2d-x tarball")
  16. message("# mkdir Cocos2d-x-Build")
  17. message("# this will create the following directory structure")
  18. message("#")
  19. message("# Cocos")
  20. message("# +--Cocos2d-x")
  21. message("# +--Cocos2d-x-Build")
  22. message("#")
  23. message("# Then you can proceed to configure and build")
  24. message("# by using the following commands")
  25. message("#")
  26. message("# cd Cocos2d-x-Build")
  27. message("# cmake ../Cocos2d-x # or ccmake, or cmake-gui ")
  28. message("# make")
  29. message("#")
  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:")
  34. message("#")
  35. message("# cd Cocos/Cocos2d-x")
  36. message("# git clean -n -d")
  37. message("# git clean -f -d")
  38. message("# git checkout --")
  39. message("#")
  40. message("######################################################")
  41. message(FATAL_ERROR "Quitting configuration")
  42. endif()
  43. endfunction()
  44. AssureOutOfSourceBuilds()