| 1 |
# @HEADER |
| 2 |
# ***************************************************************************** |
| 3 |
# TriBITS: Tribal Build, Integrate, and Test System |
| 4 |
# |
| 5 |
# Copyright 2013-2016 NTESS and the TriBITS contributors. |
| 6 |
# SPDX-License-Identifier: BSD-3-Clause |
| 7 |
# ***************************************************************************** |
| 8 |
# @HEADER |
| 9 |
|
| 10 |
|
| 11 |
# @FUNCTION: set_cache_on_off_empty() |
| 12 |
# |
| 13 |
# Usage:: |
| 14 |
# |
| 15 |
# set_cache_on_off_empty(<varName> <initialVal> "<docString>" [FORCE]) |
| 16 |
# |
| 17 |
# Sets a special string cache variable with possible values "", "ON", or |
| 18 |
# "OFF". This results in a nice drop-down box in the CMake cache manipulation |
| 19 |
# GUIs. |
| 20 |
# |
| 21 |
function(set_cache_on_off_empty VAR INITIAL_VALUE DOCSTR) |
| 22 |
set(FORCE_ARG) |
| 23 |
foreach(ARG ${ARGN}) |
| 24 |
if (ARG STREQUAL FORCE) |
| 25 |
set(FORCE_ARG FORCE) |
| 26 |
else() |
| 27 |
message(FATAL_ERROR "set_cache_on_off_empty(...): Error, last arg '${ARG}' is" |
| 28 |
"invalid! Must be 'FORCE' or nothing." ) |
| 29 |
endif() |
| 30 |
endforeach() |
| 31 |
set( ${VAR} "${INITIAL_VALUE}" CACHE STRING "${DOCSTR}" ${FORCE_ARG}) |
| 32 |
set_property(CACHE ${VAR} PROPERTY STRINGS "" "ON" "OFF") |
| 33 |
endfunction() |