summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/include_guard/VariableScope.cmake
blob: 7f8477db3dd5e438874d00129fe234eee7916876 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Scripts")

# Test include_guard with VARIABLE scope
function(var_include_func)
  # Include twice in the same scope
  include(VarScript)
  include(VarScript)
  get_property(var_count GLOBAL PROPERTY VAR_SCRIPT_COUNT)
  if(NOT var_count EQUAL 1)
    message(FATAL_ERROR
            "Wrong VAR_SCRIPT_COUNT value: ${var_count}, expected: 1")
  endif()
endfunction()

var_include_func()

# Check again that include_guard has been reset
include(VarScript)

get_property(var_count GLOBAL PROPERTY VAR_SCRIPT_COUNT)
if(NOT var_count EQUAL 2)
  message(FATAL_ERROR
          "Wrong VAR_SCRIPT_COUNT value: ${var_count}, expected: 2")
endif()