Provides an include guard for the file currently being processed by CMake.
Sets up an include guard for the current CMake file (see the
CMAKE_CURRENT_LIST_FILE variable documentation).
CMake will end its processing of the current file at the location of the
include_guard() command if the current file has already been processed for the applicable scope (see below). This provides functionality similar to the include guards commonly used in source headers or to the
#pragma once directive. If the current file has been processed previously for the applicable scope, the effect is as though
return() had been called. Do not call this command from inside a function being defined within the current file.
An optional argument specifying the scope of the guard may be provided. Possible values for the option are:
include()from the current file or its children).
If no arguments given,
include_guard has the same scope as a variable, meaning that the include guard effect is isolated by the most recent function scope or current directory if no inner function scopes exist. In this case the command behavior is the same as:
if(__CURRENT_FILE_VAR__) return() endif() set(__CURRENT_FILE_VAR__ TRUE)
© 2000–2019 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.