https://github.com/Kitware/CMake
Raw File
Tip revision: f3e9a6ff62f6f58cd661dd447c22a01c50f6f4ad authored by Brad King on 31 May 2019, 13:18:58 UTC
CMake 3.14.5
Tip revision: f3e9a6f
VariableWatchTest.cmake.in
message("Start")

variable_watch(TESTVAR MESSAGE)
variable_watch(TESTVAR1)

macro(testwatch var access file stack)
  message("There was a ${access} access done on the variable: ${var} in file ${file}")
  message("List file stack is: ${stack}")
  set(${var}_watched 1)
endmacro()

variable_watch(somevar testwatch)

set(TESTVAR1 "1")
set(TESTVAR "1")
set(TESTVAR1 "0")
set(TESTVAR "0")


message("Variable: ${somevar}")
if(NOT somevar_watched)
  message(SEND_ERROR "'somevar' watch failed!")
endif()
set(somevar_watched)

set(somevar "1")
message("Variable: ${somevar}")
if(NOT somevar_watched)
  message(SEND_ERROR "'somevar' watch failed!")
endif()
remove(somevar)
back to top