Warning, /frameworks/extra-cmake-modules/tests/test_helpers.cmake is written in an unsupported language. File is not indexed.

0001 macro(assert_var_defined varname)
0002     if(NOT DEFINED ${varname})
0003         message(SEND_ERROR "${varname} is not defined.")
0004     endif()
0005 endmacro()
0006 
0007 macro(assert_vars_strequal varname exp_varname)
0008     if(ARGC LESS 3 OR NOT "${ARGV2}" STREQUAL "ALLOW_UNDEFINED")
0009         assert_var_defined(${varname})
0010     endif()
0011     if(NOT ${varname} STREQUAL ${exp_varname})
0012         message(SEND_ERROR "${varname} is '${${varname}}', expecting '${${exp_varname}}'.")
0013     endif()
0014 endmacro()
0015 
0016 macro(assert_var_str_value varname value)
0017     if(ARGC LESS 3 OR NOT "${ARGV2}" STREQUAL "ALLOW_UNDEFINED")
0018         assert_var_defined(${varname})
0019     endif()
0020     set(_value_var "${value}")
0021     if(NOT ${varname} STREQUAL _value_var)
0022         message(SEND_ERROR "${varname} is '${${varname}}', expecting '${value}'.")
0023     endif()
0024 endmacro()
0025 
0026 macro(assert_var_num_value varname value)
0027     if(ARGC LESS 3 OR NOT "${ARGV2}" STREQUAL "ALLOW_UNDEFINED")
0028         assert_var_defined(${varname})
0029     endif()
0030     set(_value_var "${value}")
0031     if(NOT ${varname} EQUAL _value_var)
0032         message(SEND_ERROR "${varname} is '${${varname}}', expecting '${value}'.")
0033     endif()
0034 endmacro()
0035 
0036 macro(assert_var_bool_value varname value)
0037     if(ARGC LESS 3 OR NOT "${ARGV2}" STREQUAL "ALLOW_UNDEFINED")
0038         assert_var_defined(${varname})
0039     endif()
0040     if(${value} AND NOT ${varname})
0041         message(FATAL_ERROR "${varname} was FALSE")
0042     elseif(${varname} AND NOT ${value})
0043         message(FATAL_ERROR "${varname} was TRUE")
0044     endif()
0045 endmacro()
0046 
0047 macro(assert_var_relative_path varname)
0048     if(ARGC LESS 2 OR NOT "${ARGV1}" STREQUAL "ALLOW_UNDEFINED")
0049         assert_var_defined(${varname})
0050     endif()
0051     if(DEFINED ${varname} AND IS_ABSOLUTE "${${varname}}")
0052         message(SEND_ERROR "${varname} (${${varname}}) should be a relative path, but is absolute.")
0053     endif()
0054 endmacro()
0055 
0056 macro(assert_var_absolute_path varname)
0057     if(ARGC LESS 2 OR NOT "${ARGV1}" STREQUAL "ALLOW_UNDEFINED")
0058         assert_var_defined(${varname})
0059     endif()
0060     if(DEFINED ${varname} AND NOT IS_ABSOLUTE "${${varname}}")
0061         message(SEND_ERROR "${varname} (${${varname}}) should be an absolute path, but is relative.")
0062     endif()
0063 endmacro()
0064 
0065 function(assert_vars_setequal varname exp_varname)
0066     if(ARGC LESS 3 OR NOT "${ARGV2}" STREQUAL "ALLOW_UNDEFINED")
0067         assert_var_defined(${varname})
0068     endif()
0069     # need real variables
0070     set(list1 "${${varname}}")
0071     set(list2 "${${exp_varname}}")
0072     list(LENGTH list1 list1_len)
0073     list(LENGTH list2 list2_len)
0074     set(same_els FALSE)
0075     if(list1_len EQUAL list2_len)
0076         set(same_els TRUE)
0077         foreach(item ${list1})
0078             list(FIND list2 "${item}" pos)
0079             if(pos EQUAL "-1")
0080                 set(same_els FALSE)
0081                 break()
0082             else()
0083                 # deal nicely with duplicates
0084                 list(REMOVE_AT list2 "${pos}")
0085             endif()
0086         endforeach()
0087     endif()
0088     if(NOT same_els)
0089         message(SEND_ERROR "${varname} is '${${varname}}', expecting '${${exp_varname}}'.")
0090     endif()
0091 endfunction()
0092