summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/include_guard/VariableScope.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-06-28 12:53:21 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-06-28 12:53:30 (GMT)
commit0552747b58799afd6cb23db1cc5296a605cfde18 (patch)
tree4d8765b3cbc64a3e0ad40d5dcfecf836ec2bb99d /Tests/RunCMake/include_guard/VariableScope.cmake
parent45ca0403ac11a78550997a38d9d55a06439220c9 (diff)
parentc96f43b7dd1d41379fe63b4e8b508b2b034520b6 (diff)
downloadCMake-0552747b58799afd6cb23db1cc5296a605cfde18.zip
CMake-0552747b58799afd6cb23db1cc5296a605cfde18.tar.gz
CMake-0552747b58799afd6cb23db1cc5296a605cfde18.tar.bz2
Merge topic 'feature/include_guard'
c96f43b7 include_guard: add tests for the feature 80f1221f include_guard: add doc pages and a release note 85b52a04 include_guard: add vim syntax highlighting rules d44bd1c2 include_guard: implement new command Acked-by: Kitware Robot <kwrobot@kitware.com> Reviewed-by: Craig Scott <craig.scott@crascit.com> Merge-request: !928
Diffstat (limited to 'Tests/RunCMake/include_guard/VariableScope.cmake')
-rw-r--r--Tests/RunCMake/include_guard/VariableScope.cmake24
1 files changed, 24 insertions, 0 deletions
diff --git a/Tests/RunCMake/include_guard/VariableScope.cmake b/Tests/RunCMake/include_guard/VariableScope.cmake
new file mode 100644
index 0000000..7f8477d
--- /dev/null
+++ b/Tests/RunCMake/include_guard/VariableScope.cmake
@@ -0,0 +1,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()