tdlight/CMake/PreventInSourceBuild.cmake
levlam 357ed48e0e Add PreventInSourceBuild.cmake.
GitOrigin-RevId: a774b5aa7adbeb3ba974ff55a3de52f7d6371a49
2020-10-29 12:57:30 +03:00

15 lines
607 B
CMake

function(prevent_in_source_build)
get_filename_component(REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
get_filename_component(REAL_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" REALPATH)
if (REAL_BINARY_DIR STREQUAL REAL_SOURCE_DIR)
message(" Out-of-source build must be used. Remove the files already")
message(" created by CMake and rerun CMake from a new directory:")
message(" rm -rf CMakeFiles CMakeCache.txt")
message(" mkdir build")
message(" cd build")
message(" cmake ..")
message(FATAL_ERROR "In-source build failed.")
endif()
endfunction()