PreventInSourceBuilds.cmake 438 Bytes
Newer Older
Mateusz Ozga's avatar
Mateusz Ozga committed
1
2
3
4
5
6
7
8
9
10
11
12
function(AssureOutOfSourceBuilds)
  get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
  get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH)

  if("${srcdir}" STREQUAL "${bindir}")
    message("Warning: in-source builds are disabled")
    message("Please create a separate build directory and run cmake from there")
    message(FATAL_ERROR "Quitting configuration")
  endif()
endfunction()

assureOutOfSourceBuilds()