File: Utils.cmake

package info (click to toggle)
fastdds 3.1.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 58,132 kB
  • sloc: cpp: 779,516; xml: 15,119; python: 4,356; sh: 190; makefile: 93; ansic: 12
file content (32 lines) | stat: -rw-r--r-- 760 bytes parent folder | download | duplicates (3)
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()