diff options
Diffstat (limited to 'cmake/SanitizeBool.cmake')
-rw-r--r-- | cmake/SanitizeBool.cmake | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cmake/SanitizeBool.cmake b/cmake/SanitizeBool.cmake new file mode 100644 index 0000000..586c17d --- /dev/null +++ b/cmake/SanitizeBool.cmake @@ -0,0 +1,20 @@ +function(SanitizeBool VAR) + string(TOLOWER "${${VAR}}" VALUE) + if(VALUE STREQUAL "on") + set(${VAR} "ON" PARENT_SCOPE) + elseif(VALUE STREQUAL "yes") + set(${VAR} "ON" PARENT_SCOPE) + elseif(VALUE STREQUAL "true") + set(${VAR} "ON" PARENT_SCOPE) + elseif(VALUE STREQUAL "1") + set(${VAR} "ON" PARENT_SCOPE) + elseif(VALUE STREQUAL "off") + set(${VAR} "OFF" PARENT_SCOPE) + elseif(VALUE STREQUAL "no") + set(${VAR} "OFF" PARENT_SCOPE) + elseif(VALUE STREQUAL "false") + set(${VAR} "OFF" PARENT_SCOPE) + elseif(VALUE STREQUAL "0") + set(${VAR} "OFF" PARENT_SCOPE) + endif() +endfunction() |