1# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md 2# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE 3 4#.rst: 5# 6# Provides safeguards against in-source builds and bad build types. 7# 8# Variables used:: 9# 10# PROJECT_SOURCE_DIR 11# PROJECT_BINARY_DIR 12# CMAKE_BUILD_TYPE 13 14if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR}) 15 message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.") 16endif() 17 18string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower) 19string(TOUPPER "${CMAKE_BUILD_TYPE}" cmake_build_type_toupper) 20 21if(NOT cmake_build_type_tolower STREQUAL "debug" AND 22 NOT cmake_build_type_tolower STREQUAL "release" AND 23 NOT cmake_build_type_tolower STREQUAL "minsizerel" AND 24 NOT cmake_build_type_tolower STREQUAL "relwithdebinfo") 25 message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Release, RelWithDebInfo, and MinSizeRel (case-insensitive).") 26endif() 27