File: CMakeUtilityFunctions.cmake

package info (click to toggle)
insighttoolkit4 4.13.3withdata-dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 489,260 kB
  • sloc: cpp: 557,342; ansic: 146,850; fortran: 34,788; python: 16,572; sh: 2,187; lisp: 2,070; tcl: 993; java: 362; perl: 200; makefile: 129; csh: 81; pascal: 69; xml: 19; ruby: 10
file content (46 lines) | stat: -rw-r--r-- 1,613 bytes parent folder | download | duplicates (7)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
################################################################################
# Macro definitions for some simple CMake utility functions.
################################################################################

################################################################################
# Functions for list operations.
################################################################################

macro(UNIQUE var_name list)
  # Make the given list have only one instance of each unique element and
  # store it in var_name.
  set(${var_name} ${list})
  list(REMOVE_DUPLICATES ${var_name})
endmacro()

macro(INTERSECTION var_name list1 list2)
  # Store the intersection between the two given lists in var_name.
  set(intersect_tmp "")
  foreach(l ${list1})
    if("${list2}" MATCHES "(^|;)${l}(;|$)")
      list(APPEND intersect_tmp ${l})
    endif()
  endforeach()
  set(${var_name} ${intersect_tmp})
endmacro()

macro(REMOVE var_name list1 list2)
  # Remove elements in list2 from list1 and store the result in var_name.
  set(${var_name} ${list1})
  list(REMOVE_ITEM ${var_name} ${list2})
endmacro()


################################################################################
# Simple arithmetic.
################################################################################

macro(INCREMENT var_name input)
  # Increment the input variable and store the result in var_name.
  math(EXPR ${var_name} "${input} + 1")
endmacro()

macro(DECREMENT var_name input)
  # Decrement the input variable and store the result in var_name.
  math(EXPR ${var_name} "${input} - 1")
endmacro()