| 1 |
# - MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>) |
| 2 |
# MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>) |
| 3 |
# Call this macro in your project if you want to enforce out-of-source builds. |
| 4 |
# If an in-source build is detected, it will abort with the given error message. |
| 5 |
# This macro works in any of the CMakeLists.txt of your project, but the recommended |
| 6 |
# location to call this is close to the beginning of the top level CMakeLists.txt |
| 7 |
|
| 8 |
# SPDX-FileCopyrightText: 2006 Alexander Neundorf <[email protected]> |
| 9 |
# |
| 10 |
# SPDX-License-Identifier: BSD-3-Clause |
| 11 |
# |
| 12 |
|
| 13 |
MACRO (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage) |
| 14 |
|
| 15 |
STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource) |
| 16 |
IF(insource) |
| 17 |
MESSAGE(FATAL_ERROR "${_errorMessage}") |
| 18 |
ENDIF(insource) |
| 19 |
|
| 20 |
ENDMACRO (MACRO_ENSURE_OUT_OF_SOURCE_BUILD) |