File: bs_base_utils.cmake

package info (click to toggle)
intel-gmmlib 20.4.1%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,524 kB
  • sloc: cpp: 52,910; ansic: 5,587; makefile: 6
file content (80 lines) | stat: -rwxr-xr-x 3,258 bytes parent folder | download | duplicates (2)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Copyright(c) 2017 Intel Corporation

# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files(the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and / or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.


if(NOT DEFINED _bs_include_base_utils)
  set(_bs_include_base_utils TRUE)

  # bs_set_if_undefined - If not defined, assign value from env or arg
  macro(bs_set_if_undefined VAR_NAME VAR_VALUE)
    if(DEFINED ${VAR_NAME} AND NOT ${VAR_NAME} STREQUAL "")
      # Already defined
    elseif(DEFINED ENV{VAR_NAME} AND NOT "$ENV{VAR_NAME}" STREQUAL "")
      set(${VAR_NAME} "$ENV{VAR_NAME}")
    else()
      set(${VAR_NAME} "${VAR_VALUE}")
    endif()
  endmacro()

  set(_bs_check_build_type_done 0)

  # function bs_check_build_type
  # Deal with the ambiguity of the three different variables for BUILD_TYPE:
  # Give them priority in this order:
  #   UFO_BUILD_TYPE
  #   BUILD_TYPE
  # Note: Despite the similarity of name, CMAKE_BUILD_TYPE is not analogous
  # to UFO_BUILD_TYPE and BUILD_TYPE.
  function(bs_check_build_type)
    if(NOT ${_bs_check_build_type_done})
      set(_bs_check_build_type_done 1 PARENT_SCOPE)
      set(_bs_bt_var_names UFO_BUILD_TYPE BUILD_TYPE)
      foreach(_bs_bt_var_a ${_bs_bt_var_names})
        foreach(_bs_bt_var_b ${_bs_bt_var_names})
          if(NOT _bs_bt_var_a STREQUAL _bs_bt_var_b)
            if(DEFINED ${_bs_bt_var_a} AND DEFINED ${_bs_bt_var_b} AND NOT ${_bs_bt_var_a} STREQUAL ${_bs_bt_var_b})
              message(FATAL_ERROR "Conflict: ${_bs_bt_var_a}=${${_bs_bt_var_a}} vs ${_bs_bt_var_b=${${_bs_bt_var_b}}}")
            endif()
          endif()
        endforeach()
      endforeach()
      set(_bs_bt_value "")
      foreach(_bs_bt_var_a ${_bs_bt_var_names})
        if(DEFINED ${_bs_bt_var_a})
          set(_bs_bt_value ${${_bs_bt_var_a}})
          break()
        endif()
      endforeach()

      if(_bs_bt_value STREQUAL "")
        message("*BUILD_TYPE not defined, default to: release")
        set(_bs_bt_value "release")
      endif()

      foreach(_bs_bt_var_a ${_bs_bt_var_names})
        if(NOT DEFINED ${_bs_bt_var_a})
          set(${_bs_bt_var_a} "${_bs_bt_value}" PARENT_SCOPE)
        endif()
      endforeach()
    endif()
  endfunction(bs_check_build_type)


endif(NOT DEFINED _bs_include_base_utils)