1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
# returns true if only a single one of its arguments is true
function(xor result)
set(true_args_count 0)
foreach(foo ${ARGN})
if(foo)
math(EXPR true_args_count "${true_args_count}+1")
endif()
endforeach()
if(NOT (${true_args_count} EQUAL 1))
set(${result} FALSE PARENT_SCOPE)
else()
set(${result} TRUE PARENT_SCOPE)
endif()
endfunction()
function(at_most_one result)
set(true_args_count 0)
foreach(foo ${ARGN})
if(foo)
math(EXPR true_args_count "${true_args_count}+1")
endif()
endforeach()
if(${true_args_count} GREATER 1)
set(${result} FALSE PARENT_SCOPE)
else()
set(${result} TRUE PARENT_SCOPE)
endif()
endfunction()
|