SOURCE_EXISTS¶
This generator expression belongs to the Source-Dependent Expressions family. See that section for related generator expressions.
Syntax¶
$<SOURCE_EXISTS:src[,(DIRECTORY:dir|TARGET_DIRECTORY:tgt)]>
Added in version 4.3.
1 if src exists as a CMake source file, else 0. By default, the
source file is searched in the scope of the current source directory or the
directory of the consuming target.
Directory scope can be overridden with one of the following sub-options:
DIRECTORY:dirThe source file will be searched in the
dirdirectory's scope. CMake must know about the directory, either by having added it through a call toadd_subdirectory()ordirbeing the top level directory. Relative paths are treated as relative to the current source directory.TARGET_DIRECTORY:targetThe source file will be searched in the directory scope in which
targetwas created (targetmust therefore exist).