Deprecating functions, macros, and variables can be done as follows:
- First, we define a function that we will use to deprecate a variable:
function(deprecate_variable _variable _access) if(_access STREQUAL "READ_ACCESS") message(DEPRECATION "variable ${_variable} is deprecated") endif()endfunction()
- Then, if the version of CMake is greater than 3.9, we redefine custom_include_guard and attach variable_watch to included_modules:
if (CMAKE_VERSION VERSION_GREATER "3.9") # deprecate custom_include_guard macro(custom_include_guard) message(DEPRECATION "custom_include_guard is deprecated - use built-in include_guard instead") _custom_include_guard(${ARGV}) endmacro() # deprecate variable included_modules variable_watch(included_modules ...