<filename>
and store it in a<variable>
. Optionally start from the given <offset>
andread at most <max-in>
bytes. The HEX
option causes data tobe converted to a hexadecimal representation (useful for binary data). If theHEX
option is specified, letters in the output (a
through f
) are inlowercase.<filename>
and store it in<variable>
. Binary data in the file are ignored. Carriage return(r
, CR) characters are ignored. The options are:LENGTH_MAXIMUM<max-len>
LENGTH_MINIMUM<min-len>
LIMIT_COUNT<max-num>
LIMIT_INPUT<max-in>
LIMIT_OUTPUT<max-out>
<variable>
.NEWLINE_CONSUME
n
, LF) as part of string contentinstead of terminating at them.NO_HEX_CONVERSION
REGEX<regex>
ENCODING<encoding-type>
myfile
in which each item is a linefrom the input file.<filename>
andstore it in a <variable>
. The supported <HASH>
algorithm namesare those listed by the string(<HASH>)command.<filename>
and store it in <variable>
. Should the command be unable to obtain atimestamp variable will be set to the empty string (“”).string(TIMESTAMP)
command for documentation ofthe <format>
and UTC
options.install(CODE)
or install(SCRIPT)
block. For example:RESOLVED_DEPENDENCIES_VAR<deps_var>
UNRESOLVED_DEPENDENCIES_VAR<unresolved_deps_var>
CONFLICTING_DEPENDENCIES_PREFIX<conflicting_deps_prefix>
<conflicting_deps_prefix>_FILENAMES
. For each filename, the list of pathsthat were found for that filename are stored in<conflicting_deps_prefix>_<filename>
.EXECUTABLES<executable_files>
add_executable()
, but they do not have tobe created by CMake. On Apple platforms, the paths to these files determinethe value of @executable_path
when recursively resolving the libraries.Specifying any kind of library (STATIC
, MODULE
, or SHARED
) herewill result in undefined behavior.LIBRARIES<library_files>
add_library(SHARED)
, but they do not haveto be created by CMake. Specifying STATIC
libraries, MODULE
libraries, or executables here will result in undefined behavior.MODULES<module_files>
add_library(MODULE)
, but they donot have to be created by CMake. They are typically used by callingdlopen()
at runtime rather than linked at link time with ld-l
.Specifying STATIC
libraries, SHARED
libraries, or executables herewill result in undefined behavior.DIRECTORIES<directories>
BUNDLE_EXECUTABLE<bundle_executable_file>
@executable_path
when recursively resolving libraries for LIBRARIES
and MODULES
files.It has no effect on EXECUTABLES
files. On other platforms, it has noeffect. This is typically (but not always) one of the executables in theEXECUTABLES
argument which designates the “main” executable of thepackage.PRE_INCLUDE_REGEXES<regexes>
PRE_EXCLUDE_REGEXES<regexes>
POST_INCLUDE_REGEXES<regexes>
POST_EXCLUDE_REGEXES<regexes>
PRE_INCLUDE_REGEXES
, steps 2 and 3 are skipped, and the dependencyresolution proceeds to step 4.PRE_EXCLUDE_REGEXES
, dependency resolution stops for that dependency.file(GET_RUNTIME_DEPENDENCIES)
searches for the dependency according tothe linking rules of the platform (see below).POST_INCLUDE_REGEXES
, the full path is added to the resolveddependencies, and file(GET_RUNTIME_DEPENDENCIES)
recursively resolvesthat library’s own dependencies. Otherwise, resolution proceeds to step 6.POST_EXCLUDE_REGEXES
, it is not added to the resolved dependencies, anddependency resolution stops for that dependency.POST_INCLUDE_REGEXES
or POST_EXCLUDE_REGEXES
, the full path is addedto the resolved dependencies, and file(GET_RUNTIME_DEPENDENCIES)
recursively resolves that library’s own dependencies.RUNPATH
entries, and the libraryexists in one of the depending file’s RPATH
entries, or its parents’, inthat order, the dependency is resolved to that file.RUNPATH
entries, and thelibrary exists in one of those entries, the dependency is resolved to thatfile.ldconfig
, the dependency is resolved to that file.DIRECTORIES
entries, thedependency is resolved to that file. In this case, a warning is issued,because finding a file in one of the DIRECTORIES
means that thedepending file is not complete (it does not list all the directories fromwhich it pulls dependencies).PRE_INCLUDE_REGEXES
,PRE_EXCLUDE_REGEXES
, POST_INCLUDE_REGEXES
, andPOST_EXCLUDE_REGEXES
to properly filter DLL names - every regex wouldhave to check for both uppercase and lowercase letters. For example:mylibrary.dll
regardless of how it is cased,either on disk or in the depending file. (For example, it will matchmylibrary.dll
, MyLibrary.dll
, and MYLIBRARY.DLL
.)system32
directory or the Windows
directory, in that order, thedependency is resolved to that file.DIRECTORIES
, in the order they are listed, the dependency is resolved tothat file. In this case, a warning is not issued, because searching otherdirectories is a normal part of Windows library resolution.@executable_path/
, and an EXECUTABLES
argument is in the process of being resolved, and replacing@executable_path/
with the directory of the executable yields anexisting file, the dependency is resolved to that file.@executable_path/
, and there isa BUNDLE_EXECUTABLE
argument, and replacing @executable_path/
withthe directory of the bundle executable yields an existing file, thedependency is resolved to that file.@loader_path/
, and replacing@loader_path/
with the directory of the depending file yields anexisting file, the dependency is resolved to that file.@rpath/
, and replacing@rpath/
with one of the RPATH
entries of the depending file yieldsan existing file, the dependency is resolved to that file. Note thatRPATH
entries that start with @executable_path/
or @loader_path/
also have these items replaced with the appropriate path.CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM
¶linux+elf
windows+pe
macos+macho
CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL
¶CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM
:CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM | CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL |
---|---|
linux+elf | objdump |
windows+pe | dumpbin |
windows+pe | objdump |
macos+macho | otool |
CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND
¶objdump
, dumpbin
, or otool
.CMAKE_OBJDUMP
if set, else by system introspection.<content>
into a file called <filename>
. If the file doesnot exist, it will be created. If the file already exists, WRITE
mode will overwrite it and APPEND
mode will append to the end.Any directories in the path specified by <filename>
that do notexist will be created.configure_file()
commandto update the file only when its content changes.CMakeGenerator
. Evaluategeneratorexpressions
from the input content to produce the output content. The options are:CONDITION<condition>
0
or 1
after evaluating generator expressions.CONTENT<content>
INPUT<input-file>
CMAKE_CURRENT_SOURCE_DIR
. See policy CMP0070
.OUTPUT<output-file>
$<CONFIG>
to specify a configuration-specific output filename. Multiple configurations may generate the same output file onlyif the generated content is identical. Otherwise, the <output-file>
must evaluate to an unique name for each configuration.A relative path (after evaluating generator expressions) is treatedwith respect to the value of CMAKE_CURRENT_BINARY_DIR
.See policy CMP0070
.CONTENT
or INPUT
option must be given. A specificOUTPUT
file may be named by at most one invocation of file(GENERATE)
.Generated files are modified and their timestamp updated on subsequent cmakeruns only if their content is changed.file(GENERATE)
does not create the output file until thegeneration phase. The output file will not yet have been written when thefile(GENERATE)
command returns, it is written only after processing allof a project’s CMakeLists.txt
files.CONTENT
and substitutevariable values referenced as @VAR@
or ${VAR}
contained therein. Thesubstitution rules behave the same as the configure_file()
command.In order to match configure_file()
’s behavior, generator expressionsare not supported for both OUTPUT
and CONTENT
.OUTPUT<output-file>
CMAKE_CURRENT_BINARY_DIR
.<output-file>
does not support generator expressions.CONTENT<content>
<content>
does not support generator expressions.ESCAPE_QUOTES
@ONLY
@VAR@
.This is useful for configuring scripts that use ${VAR}
syntax.NEWLINE_STYLE<style>
UNIX
or LF
for n
newlines, or specifyDOS
, WIN32
, or CRLF
for rn
newlines.<globbing-expressions>
andstore it into the <variable>
. Globbing expressions are similar toregular expressions, but much simpler. If RELATIVE
flag isspecified, the results will be returned as relative paths to the givenpath. The results will be ordered lexicographically.CONFIGURE_DEPENDS
flag is specified, CMake will add logicto the main build system check target to rerun the flagged GLOB
commandsat build time. If any of the outputs change, CMake will regenerate the buildsystem.GLOB
lists directories - directories are omitted in result ifLIST_DIRECTORIES
is set to false.CONFIGURE_DEPENDS
flag may not work reliably on all generators, or ifa new generator is added in the future that cannot support it, projects usingit will be stuck. Even if CONFIGURE_DEPENDS
works reliably, there isstill a cost to perform the check on every rebuild.GLOB_RECURSE
mode will traverse all the subdirectories of thematched directory and match the files. Subdirectories that are symlinksare only traversed if FOLLOW_SYMLINKS
is given or policyCMP0009
is not set to NEW
.GLOB_RECURSE
omits directories from result list - settingLIST_DIRECTORIES
to true adds directories to result list.If FOLLOW_SYMLINKS
is given or policy CMP0009
is not set toNEW
then LIST_DIRECTORIES
treats symlinks as directories.<oldname>
to<newname>
, replacing the destination atomically.REMOVE_RECURSE
mode will remove the givenfiles and directories, also non-empty directories. No error is emitted if agiven file does not exist. Relative input paths are evaluated with respectto the current source directory. Empty input paths are ignored with a warning.COPY
signature copies files, directories, and symlinks to adestination folder. Relative input paths are evaluated with respectto the current source directory, and a relative destination isevaluated with respect to the current build directory. Copyingpreserves input file timestamps, and optimizes out a file if it existsat the destination with the same timestamp. Copying preserves inputpermissions unless explicit permissions or NO_SOURCE_PERMISSIONS
are given (default is USE_SOURCE_PERMISSIONS
).FOLLOW_SYMLINK_CHAIN
is specified, COPY
will recursively resolvethe symlinks at the paths given until a real file is found, and installa corresponding symlink in the destination for each symlink encountered. Foreach symlink that is installed, the resolution is stripped of the directory,leaving only the filename, meaning that the new symlink points to a file inthe same directory as the symlink. This feature is useful on some Unix systems,where libraries are installed as a chain of symlinks with version numbers, withless specific versions pointing to more specific versions.FOLLOW_SYMLINK_CHAIN
will install all of these symlinks and the libraryitself into the destination directory. For example, if you have the followingdirectory structure:/opt/foo/lib/libfoo.so.1.2.3
/opt/foo/lib/libfoo.so.1.2->libfoo.so.1.2.3
/opt/foo/lib/libfoo.so.1->libfoo.so.1.2
/opt/foo/lib/libfoo.so->libfoo.so.1
libfoo.so.1.2.3
itself intolib
.install(DIRECTORY)
command for documentation ofpermissions, FILES_MATCHING
, PATTERN
, REGEX
, andEXCLUDE
options. Copying directories preserves the structureof their content even if options are used to select a subset offiles.INSTALL
signature differs slightly from COPY
: it printsstatus messages (subject to the CMAKE_INSTALL_MESSAGE
variable),and NO_SOURCE_PERMISSIONS
is default.Installation scripts generated by the install()
commanduse this signature (with some undocumented options for internal use).<filename>
and put the result in<variable>
variable. Requires that <filename>
is a valid pathpointing to a file and is readable.<linkname>
and stores the path itpoints to in the result <variable>
. If <linkname>
does not exist oris not a symlink, CMake issues a fatal error.<linkname>
that points to <original>
.It will be a hard link by default, but providing the SYMBOLIC
optionresults in a symbolic link instead. Hard links require that original
exists and is a file, not a directory. If <linkname>
already exists,it will be overwritten.<result>
variable, if specified, receives the status of the operation.It is set to 0
upon success or an error message otherwise. If RESULT
is not specified and the operation fails, a fatal error is emitted.COPY_ON_ERROR
enables copying the file as a fallback ifcreating the link fails. It can be useful for handling situations such as<original>
and <linkname>
being on different drives or mount points,which would make them unable to support a hard link.<directory>
to a <file>
andstore it in the <variable>
.TO_CMAKE_PATH
mode converts a native <path>
into a cmake-stylepath with forward-slashes (/
). The input can be a single path or asystem search path like $ENV{PATH}
. A search path will be convertedto a cmake-style list separated by ;
characters.TO_NATIVE_PATH
mode converts a cmake-style <path>
into a nativepath with platform-specific slashes (
on Windows and /
elsewhere).<path>
to be sure it is treatedas a single argument to this command.DOWNLOAD
mode downloads the given <url>
to a local <file>
.The UPLOAD
mode uploads a local <file>
to a given <url>
.DOWNLOAD
and UPLOAD
are:INACTIVITY_TIMEOUT<seconds>
LOG<variable>
SHOW_PROGRESS
STATUS<variable>
;
separated list of length 2.The first element is the numeric return value for the operation,and the second element is a string value for the error.A 0
numeric error means no error in the operation.TIMEOUT<seconds>
USERPWD<username>:<password>
HTTPHEADER<HTTP-header>
NETRC<level>
CMAKE_NETRC
variablewill be used instead.Valid levels are:IGNORED
OPTIONAL
REQUIRED
NETRC_FILE<file>
NETRC
level is OPTIONAL
or REQUIRED
. If this optionis not specified, the value of the CMAKE_NETRC_FILE
variable willbe used instead.NETRC
option is given CMake will check variablesCMAKE_NETRC
and CMAKE_NETRC_FILE
, respectively.TLS_VERIFY<ON|OFF>
https://
URLs.The default is to not verify.TLS_CAINFO<file>
https://
URLs.https://
URLs CMake must be built with OpenSSL support. TLS/SSL
certificates are not checked by default. Set TLS_VERIFY
to ON
tocheck certificates. If neither TLS
option is given CMake will checkvariables CMAKE_TLS_VERIFY
and CMAKE_TLS_CAINFO
, respectively.DOWNLOAD
are:EXPECTED_HASHALGO=<value>
ALGO
is one of the algorithms supported by file(<HASH>)
. https://mailerkeen804.weebly.com/free-scanner-software-for-mac-yosemite.html. If it does not match, the operation fails with an error.EXPECTED_MD5<value>
EXPECTED_HASHMD5=<value>
.<path>
if no DIRECTORY
option present and file<path>/cmake.lock
otherwise. File will be locked for scope defined byGUARD
option (default value is PROCESS
). RELEASE
option can be usedto unlock file explicitly. If option TIMEOUT
is not specified CMake willwait until lock succeed or until fatal error occurs. If TIMEOUT
is set to0
lock will be tried once and result will be reported immediately. IfTIMEOUT
is not 0
CMake will try to lock file for the period specifiedby <seconds>
value. Any errors will be interpreted as fatal if there is noRESULT_VARIABLE
option. Otherwise result will be stored in <variable>
and will be 0
on success or error message on failure.DIRECTORY
option -locking parent directory doesn’t prevent other LOCK
commands to lock anychild directory or file.GUARD
and TIMEOUT
options ignored on RELEASE
operation.<archive>
file with the files and directorieslisted in <paths>
. Note that <paths>
must list actual files ordirectories, wildcards are not supported.FORMAT
option to specify the archive format. Supported valuesfor <format>
are 7zip
, gnutar
, pax
, paxr
, raw
andzip
. If FORMAT
is not given, the default format is paxr
.7zip
and zip
archive formats already imply a specific type ofcompression. The other formats use no compression by default, but can bedirected to do so with the COMPRESSION
option. Valid values for<compression>
are None
, BZip2
, GZip
, XZ
, and Zstd
.FORMAT
set to raw
only one file will be compressed with thecompression type specified by COMPRESSION
.VERBOSE
option enables verbose output for the archive operation.MTIME
option.<archive>
.DESTINATION
option. If the directory does notexist, it will be created. If DESTINATION
is not given, the currentbinary directory will be used.<patterns>
. Wildcards are supported.If the PATTERNS
option is not given, the entire archive will be listed orextracted.LIST_ONLY
will list the files in the archive rather than extract them.VERBOSE
, the command will produce verbose output.