diff options
author | Aiden Grossman <agrossman154@yahoo.com> | 2023-11-16 10:32:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-16 10:32:14 -0800 |
commit | f49bca9b5a4a5a3d9d8135b4c17e7f1e7dcecdde (patch) | |
tree | 731befe44bb123da65f205e23e02c0597c3c5f9f /llvm/CMakeLists.txt | |
parent | 0718c1a8405ac130d72cd3525befed2911618cc7 (diff) | |
download | llvm-f49bca9b5a4a5a3d9d8135b4c17e7f1e7dcecdde.zip llvm-f49bca9b5a4a5a3d9d8135b4c17e7f1e7dcecdde.tar.gz llvm-f49bca9b5a4a5a3d9d8135b4c17e7f1e7dcecdde.tar.bz2 |
[CMake] Make specifying invalid build type a fatal error (#72021)
This patch makes it so that specifying an invalid value for
CMAKE_BUILD_TYPE is a fatal error. Having this simply as a warning has
caused me (and probably others) a decent amount of headache. The check
was present before, but was proposed to be modified to a warning in
https://github.com/llvm/llvm-project/issues/60975 and changed to a
warning in c75dbeda15c10424910ddc83a9ff7669776c19ac. This patch
reenables that behavior to hopefully reduce frustration for people
building LLVM in the common case while still allowing for alternative
build types to be setup without needing to perform source modification
through the addition of a CMake flag.
Diffstat (limited to 'llvm/CMakeLists.txt')
-rw-r--r-- | llvm/CMakeLists.txt | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 7ff3acd..1c983165 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -392,9 +392,15 @@ endif() string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) +option(LLVM_ADDITIONAL_BUILD_TYPES "Additional build types that are allowed to be passed into CMAKE_BUILD_TYPE" "") + +set(ALLOWED_BUILD_TYPES DEBUG RELEASE RELWITHDEBINFO MINSIZEREL ${LLVM_ADDITIONAL_BUILD_TYPES}) +string (REPLACE ";" "|" ALLOWED_BUILD_TYPES_STRING "${ALLOWED_BUILD_TYPES}") +string (TOUPPER "${ALLOWED_BUILD_TYPES_STRING}" uppercase_ALLOWED_BUILD_TYPES) + if (CMAKE_BUILD_TYPE AND - NOT uppercase_CMAKE_BUILD_TYPE MATCHES "^(DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL)$") - message(WARNING "Unknown value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") + NOT uppercase_CMAKE_BUILD_TYPE MATCHES "^(${uppercase_ALLOWED_BUILD_TYPES})$") + message(FATAL_ERROR "Unknown value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") endif() # LLVM_INSTALL_PACKAGE_DIR needs to be declared prior to adding the tools |