blob: 4806892a86f789b7ed946f32592dd3c1eefdb969 [file] [log] [blame]
include(CMakeParseArguments)
function(precondition var)
cmake_parse_arguments(
PRECONDITION # prefix
"NEGATE" # options
"MESSAGE" # single-value args
"" # multi-value args
${ARGN})
if (PRECONDITION_NEGATE)
if (${var})
if (PRECONDITION_MESSAGE)
message(FATAL_ERROR "Error! ${PRECONDITION_MESSAGE}")
else()
message(FATAL_ERROR "Error! Variable ${var} is true or not empty. The value of ${var} is ${${var}}.")
endif()
endif()
else()
if (NOT ${var})
if (PRECONDITION_MESSAGE)
message(FATAL_ERROR "Error! ${PRECONDITION_MESSAGE}")
else()
message(FATAL_ERROR "Error! Variable ${var} is false, empty or not set.")
endif()
endif()
endif()
endfunction()