File: PreventInSourceBuilds.cmake

package info (click to toggle)
therion 6.3.4-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,544 kB
  • sloc: cpp: 195,273; tcl: 19,779; ansic: 8,434; perl: 1,895; makefile: 1,281; python: 255; asm: 219; sh: 104
file content (18 lines) | stat: -rw-r--r-- 712 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#
# This function will prevent in-source builds
function(AssureOutOfSourceBuilds)
  # 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("######################################################")
    message("Warning: in-source builds are disabled")
    message("Please create a separate build directory and run cmake from there")
    message("######################################################")
    message(FATAL_ERROR "Quitting configuration")
  endif()
endfunction()

assureoutofsourcebuilds()