.
. RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .rstReportMargin post:
.. . RE indent \\n[an-margin]
old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1 new: \\n[rst2man-indent\\n[rst2man-indent-level]]
..
add_compile_options(<option> ...)NINDENT NINDENT Adds options to the compiler command line for targets in the current directory and below that are added after this command is invoked. See documentation of the directory and target COMPILE_OPTIONS properties. This command can be used to add any options, but alternative commands exist to add preprocessor definitions (target_compile_definitions() and add_definitions()) or include directories (target_include_directories() and include_directories()). Arguments to add_compile_options may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions. See the cmake-buildsystem(7) manual for more on defining buildsystem properties.
add_custom_command(OUTPUT output1 [output2 ...] COMMAND command1 [ARGS] [args1...] [COMMAND command2 [ARGS] [args2...] ...] [MAIN_DEPENDENCY depend] [DEPENDS [depends...]] [BYPRODUCTS [files...]] [IMPLICIT_DEPENDS <lang1> depend1 [<lang2> depend2] ...] [WORKING_DIRECTORY dir] [COMMENT comment] [VERBATIM] [APPEND] [USES_TERMINAL])NINDENT NINDENT This defines a command to generate specified OUTPUT file(s). A target created in the same directory (CMakeLists.txt file) that specifies any output of the custom command as a source file is given a rule to generate the file using the command at build time. Do not list the output in more than one independent target that may build in parallel or the two instances of the rule may conflict (instead use the add_custom_target() command to drive the command and make the other targets depend on that one). In makefile terms this creates a new target in the following form: NDENT 0.0 NDENT 3.5
OUTPUT: MAIN_DEPENDENCY DEPENDS COMMANDNINDENT NINDENT The options are: NDENT 0.0
APPEND Append the COMMAND and DEPENDS option values to the custom command for the first output specified. There must have already been a previous call to this command with the same output. The COMMENT, MAIN_DEPENDENCY, and WORKING_DIRECTORY options are currently ignored when APPEND is given, but may be used in the future.
BYPRODUCTS Specify the files the command is expected to produce but whose modification time may or may not be newer than the dependencies. If a byproduct name is a relative path it will be interpreted relative to the build tree directory corresponding to the current source directory. Each byproduct file will be marked with the GENERATED source file property automatically. Explicit specification of byproducts is supported by the Ninja generator to tell the ninja build tool how to regenerate byproducts when they are missing. It is also useful when other build rules (e.g. custom commands) depend on the byproducts. Ninja requires a build rule for any generated file on which another rule depends even if there are order-only dependencies to ensure the byproducts will be available before their dependents build. The BYPRODUCTS option is ignored on non-Ninja generators except to mark byproducts GENERATED.
COMMAND Specify the command-line(s) to execute at build time. If more than one COMMAND is specified they will be executed in order, but not necessarily composed into a stateful shell or batch script. (To run a full script, use the configure_file() command or the file(GENERATE) command to create it, and then specify a COMMAND to launch it.) The optional ARGS argument is for backward compatibility and will be ignored. If COMMAND specifies an executable target (created by the add_executable() command) it will automatically be replaced by the location of the executable created at build time. (Use the TARGET_FILE generator expression to reference an executable later in the command line.) Additionally a target-level dependency will be added so that the executable target will be built before any target using this custom command. However this does NOT add a file-level dependency that would cause the custom command to re-run whenever the executable is recompiled. Arguments to COMMAND may use generator expressions. References to target names in generator expressions imply target-level dependencies, but NOT file-level dependencies. List target names with the DEPENDS option to add file-level dependencies.
COMMENT Display the given message before the commands are executed at build time.
DEPENDS Specify files on which the command depends. If any dependency is an OUTPUT of another custom command in the same directory (CMakeLists.txt file) CMake automatically brings the other custom command into the target in which this command is built. If DEPENDS is not specified the command will run whenever the OUTPUT is missing; if the command does not actually create the OUTPUT then the rule will always run. If DEPENDS specifies any target (created by the add_custom_target(), add_executable(), or add_library() command) a target-level dependency is created to make sure the target is built before any target using this custom command. Additionally, if the target is an executable or library a file-level dependency is created to cause the custom command to re-run whenever the target is recompiled. Arguments to DEPENDS may use generator expressions.
IMPLICIT_DEPENDS Request scanning of implicit dependencies of an input file. The language given specifies the programming language whose corresponding dependency scanner should be used. Currently only C and CXX language scanners are supported. The language has to be specified for every file in the IMPLICIT_DEPENDS list. Dependencies discovered from the scanning are added to those of the custom command at build time. Note that the IMPLICIT_DEPENDS option is currently supported only for Makefile generators and will be ignored by other generators.
MAIN_DEPENDENCY Specify the primary input source file to the command. This is treated just like any value given to the DEPENDS option but also suggests to Visual Studio generators where to hang the custom command. At most one custom command may specify a given source file as its main dependency.
OUTPUT Specify the output files the command is expected to produce. If an output name is a relative path it will be interpreted relative to the build tree directory corresponding to the current source directory. Each output file will be marked with the GENERATED source file property automatically. If the output of the custom command is not actually created as a file on disk it should be marked with the SYMBOLIC source file property.
USES_TERMINAL The command will be given direct access to the terminal if possible. With the Ninja generator, this places the command in the console pool.
VERBATIM All arguments to the commands will be escaped properly for the build tool so that the invoked command receives each argument unchanged. Note that one level of escapes is still used by the CMake language processor before add_custom_command even sees the arguments. Use of VERBATIM is recommended as it enables correct behavior. When VERBATIM is not given the behavior is platform specific because there is no protection of tool-specific special characters.
WORKING_DIRECTORY Execute the command with the given current working directory. If it is a relative path it will be interpreted relative to the build tree directory corresponding to the current source directory. NINDENT
add_custom_command(TARGET target PRE_BUILD | PRE_LINK | POST_BUILD COMMAND command1 [ARGS] [args1...] [COMMAND command2 [ARGS] [args2...] ...] [BYPRODUCTS [files...]] [WORKING_DIRECTORY dir] [COMMENT comment] [VERBATIM] [USES_TERMINAL])NINDENT NINDENT This defines a new command that will be associated with building the specified target. When the command will happen is determined by which of the following is specified: NDENT 0.0
PRE_BUILD Run before any other rules are executed within the target. This is supported only on Visual Studio 7 or later. For all other generators PRE_BUILD will be treated as PRE_LINK.
PRE_LINK Run after sources have been compiled but before linking the binary or running the librarian or archiver tool of a static library. This is not defined for targets created by the add_custom_target() command.
POST_BUILD Run after all other rules within the target have been executed. NINDENT
add_custom_target(Name [ALL] [command1 [args1...]] [COMMAND command2 [args2...] ...] [DEPENDS depend depend depend ... ] [BYPRODUCTS [files...]] [WORKING_DIRECTORY dir] [COMMENT comment] [VERBATIM] [USES_TERMINAL] [SOURCES src1 [src2...]])NINDENT NINDENT Adds a target with the given name that executes the given commands. The target has no output file and is always considered out of date even if the commands try to create a file with the name of the target. Use the add_custom_command() command to generate a file with dependencies. By default nothing depends on the custom target. Use the add_dependencies() command to add dependencies to or from other targets. The options are: NDENT 0.0
ALL Indicate that this target should be added to the default build target so that it will be run every time (the command cannot be called ALL).
BYPRODUCTS Specify the files the command is expected to produce but whose modification time may or may not be updated on subsequent builds. If a byproduct name is a relative path it will be interpreted relative to the build tree directory corresponding to the current source directory. Each byproduct file will be marked with the GENERATED source file property automatically. Explicit specification of byproducts is supported by the Ninja generator to tell the ninja build tool how to regenerate byproducts when they are missing. It is also useful when other build rules (e.g. custom commands) depend on the byproducts. Ninja requires a build rule for any generated file on which another rule depends even if there are order-only dependencies to ensure the byproducts will be available before their dependents build. The BYPRODUCTS option is ignored on non-Ninja generators except to mark byproducts GENERATED.
COMMAND Specify the command-line(s) to execute at build time. If more than one COMMAND is specified they will be executed in order, but not necessarily composed into a stateful shell or batch script. (To run a full script, use the configure_file() command or the file(GENERATE) command to create it, and then specify a COMMAND to launch it.) If COMMAND specifies an executable target (created by the add_executable() command) it will automatically be replaced by the location of the executable created at build time. Additionally a target-level dependency will be added so that the executable target will be built before this custom target. Arguments to COMMAND may use generator expressions. References to target names in generator expressions imply target-level dependencies. The command and arguments are optional and if not specified an empty target will be created.
COMMENT Display the given message before the commands are executed at build time.
DEPENDS Reference files and outputs of custom commands created with add_custom_command() command calls in the same directory (CMakeLists.txt file). They will be brought up to date when the target is built. Use the add_dependencies() command to add dependencies on other targets.
SOURCES Specify additional source files to be included in the custom target. Specified source files will be added to IDE project files for convenience in editing even if they have no build rules.
VERBATIM All arguments to the commands will be escaped properly for the build tool so that the invoked command receives each argument unchanged. Note that one level of escapes is still used by the CMake language processor before add_custom_target even sees the arguments. Use of VERBATIM is recommended as it enables correct behavior. When VERBATIM is not given the behavior is platform specific because there is no protection of tool-specific special characters.
USES_TERMINAL The command will be given direct access to the terminal if possible. With the Ninja generator, this places the command in the console pool.
WORKING_DIRECTORY Execute the command with the given current working directory. If it is a relative path it will be interpreted relative to the build tree directory corresponding to the current source directory. NINDENT
add_definitions(-DFOO -DBAR ...)NINDENT NINDENT Adds definitions to the compiler command line for targets in the current directory and below (whether added before or after this command is invoked). This command can be used to add any flags, but it is intended to add preprocessor definitions (see the add_compile_options() command to add other flags). Flags beginning in -D or /D that look like preprocessor definitions are automatically added to the COMPILE_DEFINITIONS directory property for the current directory. Definitions with non-trivial values may be left in the set of flags instead of being converted for reasons of backwards compatibility. See documentation of the directory, target, source file COMPILE_DEFINITIONS properties for details on adding preprocessor definitions to specific scopes and configurations. See the cmake-buildsystem(7) manual for more on defining buildsystem properties.
add_dependencies(<target> [<target-dependency>]...)NINDENT NINDENT Make a top-level <target> depend on other top-level targets to ensure that they build before <target> does. A top-level target is one created by one of the add_executable(), add_library(), or add_custom_target() commands (but not targets generated by CMake like install). Dependencies added to an imported target or an interface library are followed transitively in its place since the target itself does not build. See the DEPENDS option of add_custom_target() and add_custom_command() commands for adding file-level dependencies in custom rules. See the OBJECT_DEPENDS source file property to add file-level dependencies to object files.
add_executable(<name> [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] source1 [source2 ...])NINDENT NINDENT Adds an executable target called <name> to be built from the source files listed in the command invocation. The <name> corresponds to the logical target name and must be globally unique within a project. The actual file name of the executable built is constructed based on conventions of the native platform (such as <name>.exe or just <name>. By default the executable file will be created in the build tree directory corresponding to the source tree directory in which the command was invoked. See documentation of the RUNTIME_OUTPUT_DIRECTORY target property to change this location. See documentation of the OUTPUT_NAME target property to change the <name> part of the final file name. If WIN32 is given the property WIN32_EXECUTABLE will be set on the target created. See documentation of that target property for details. If MACOSX_BUNDLE is given the corresponding property will be set on the created target. See documentation of the MACOSX_BUNDLE target property for details. If EXCLUDE_FROM_ALL is given the corresponding property will be set on the created target. See documentation of the EXCLUDE_FROM_ALL target property for details. Source arguments to add_executable may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions. See the cmake-buildsystem(7) manual for more on defining buildsystem properties.
----
0 NDENT 0.0 NDENT 3.5
add_executable(<name> IMPORTED [GLOBAL])NINDENT NINDENT An IMPORTED executable target references an executable file located outside the project. No rules are generated to build it, and the IMPORTED target property is True. The target name has scope in the directory in which it is created and below, but the GLOBAL option extends visibility. It may be referenced like any target built within the project. IMPORTED executables are useful for convenient reference from commands like add_custom_command(). Details about the imported executable are specified by setting properties whose names begin in IMPORTED_. The most important such property is IMPORTED_LOCATION (and its per-configuration version IMPORTED_LOCATION_<CONFIG>) which specifies the location of the main executable file on disk. See documentation of the IMPORTED_* properties for more information.
----
0 NDENT 0.0 NDENT 3.5
add_executable(<name> ALIAS <target>)NINDENT NINDENT Creates an Alias Target, such that <name> can be used to refer to <target> in subsequent commands. The <name> does not appear in the generated buildsystem as a make target. The <target> may not be an Imported Target or an ALIAS. ALIAS targets can be used as targets to read properties from, executables for custom commands and custom targets. They can also be tested for existance with the regular if(TARGET) subcommand. The <name> may not be used to modify properties of <target>, that is, it may not be used as the operand of set_property(), set_target_properties(), target_link_libraries() etc. An ALIAS target may not be installed or exported.
add_library(<name> [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] source1 [source2 ...])NINDENT NINDENT Adds a library target called <name> to be built from the source files listed in the command invocation. The <name> corresponds to the logical target name and must be globally unique within a project. The actual file name of the library built is constructed based on conventions of the native platform (such as lib<name>.a or <name>.lib). STATIC, SHARED, or MODULE may be given to specify the type of library to be created. STATIC libraries are archives of object files for use when linking other targets. SHARED libraries are linked dynamically and loaded at runtime. MODULE libraries are plugins that are not linked into other targets but may be loaded dynamically at runtime using dlopen-like functionality. If no type is given explicitly the type is STATIC or SHARED based on whether the current value of the variable BUILD_SHARED_LIBS is ON. For SHARED and MODULE libraries the POSITION_INDEPENDENT_CODE target property is set to ON automatically. By default the library file will be created in the build tree directory corresponding to the source tree directory in which the command was invoked. See documentation of the ARCHIVE_OUTPUT_DIRECTORY, LIBRARY_OUTPUT_DIRECTORY, and RUNTIME_OUTPUT_DIRECTORY target properties to change this location. See documentation of the OUTPUT_NAME target property to change the <name> part of the final file name. If EXCLUDE_FROM_ALL is given the corresponding property will be set on the created target. See documentation of the EXCLUDE_FROM_ALL target property for details. Source arguments to add_library may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions. See the cmake-buildsystem(7) manual for more on defining buildsystem properties.
add_library(<name> <SHARED|STATIC|MODULE|UNKNOWN> IMPORTED [GLOBAL])NINDENT NINDENT An IMPORTED library target references a library file located outside the project. No rules are generated to build it, and the IMPORTED target property is True. The target name has scope in the directory in which it is created and below, but the GLOBAL option extends visibility. It may be referenced like any target built within the project. IMPORTED libraries are useful for convenient reference from commands like target_link_libraries(). Details about the imported library are specified by setting properties whose names begin in IMPORTED_ and INTERFACE_. The most important such property is IMPORTED_LOCATION (and its per-configuration variant IMPORTED_LOCATION_<CONFIG>) which specifies the location of the main library file on disk. See documentation of the IMPORTED_* and INTERFACE_* properties for more information.
add_library(<name> OBJECT <src>...)NINDENT NINDENT Creates an Object Library. An object library compiles source files but does not archive or link their object files into a library. Instead other targets created by \%add_library() or add_executable() may reference the objects using an expression of the form $<TARGET_OBJECTS:objlib> as a source, where objlib is the object library name. For example: NDENT 0.0 NDENT 3.5
add_library(... $<TARGET_OBJECTS:objlib> ...) add_executable(... $<TARGET_OBJECTS:objlib> ...)NINDENT NINDENT will include objlib\(aqs object files in a library and an executable along with those compiled from their own sources. Object libraries may contain only sources that compile, header files, and other files that would not affect linking of a normal library (e.g. .txt). They may contain custom commands generating such sources, but not PRE_BUILD, PRE_LINK, or POST_BUILD commands. Object libraries cannot be imported, exported, installed, or linked. Some native build systems may not like targets that have only object files, so consider adding at least one real source file to any target that references $<TARGET_OBJECTS:objlib>.
add_library(<name> ALIAS <target>)NINDENT NINDENT Creates an Alias Target, such that <name> can be used to refer to <target> in subsequent commands. The <name> does not appear in the generatedbuildsystem as a make target. The <target> may not be an Imported Target or an ALIAS. ALIAS targets can be used as linkable targets and as targets to read properties from. They can also be tested for existance with the regular if(TARGET) subcommand. The <name> may not be used to modify properties of <target>, that is, it may not be used as the operand of set_property(), set_target_properties(), target_link_libraries() etc. An ALIAS target may not be installed or exported.
add_library(<name> INTERFACE [IMPORTED [GLOBAL]])NINDENT NINDENT Creates an Interface Library. An INTERFACE library target does not directly create build output, though it may have properties set on it and it may be installed, exported and imported. Typically the INTERFACE_* properties are populated on the interface target using the commands: NDENT 0.0
add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL])NINDENT NINDENT Add a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.txt and code files are located. If it is a relative path it will be evaluated with respect to the current directory (the typical usage), but it may also be an absolute path. The binary_dir specifies the directory in which to place the output files. If it is a relative path it will be evaluated with respect to the current output directory, but it may also be an absolute path. If binary_dir is not specified, the value of source_dir, before expanding any relative path, will be used (the typical usage). The CMakeLists.txt file in the specified source directory will be processed immediately by CMake before processing in the current input file continues beyond this command. If the EXCLUDE_FROM_ALL argument is provided then targets in the subdirectory will not be included in the ALL target of the parent directory by default, and will be excluded from IDE project files. Users must explicitly build targets in the subdirectory. This is meant for use when the subdirectory contains a separate part of the project that is useful but not necessary, such as a set of examples. Typically the subdirectory should contain its own project() command invocation so that a full build system will be generated in the subdirectory (such as a VS IDE solution file). Note that inter-target dependencies supercede this exclusion. If a target built by the parent project depends on a target in the subdirectory, the dependee target will be included in the parent project build system to satisfy the dependency.
add_test(NAME <name> COMMAND <command> [<arg>...] [CONFIGURATIONS <config>...] [WORKING_DIRECTORY <dir>])NINDENT NINDENT Add a test called <name>. The test name may not contain spaces, quotes, or other characters special in CMake syntax. The options are: NDENT 0.0
COMMAND Specify the test command-line. If <command> specifies an executable target (created by add_executable()) it will automatically be replaced by the location of the executable created at build time.
CONFIGURATIONS Restrict execution of the test only to the named configurations.
WORKING_DIRECTORY Set the WORKING_DIRECTORY test property to specify the working directory in which to execute the test. If not specified the test will be run with the current working directory set to the build directory corresponding to the current source directory. NINDENT The COMMAND and WORKING_DIRECTORY options may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions. Example usage: NDENT 0.0 NDENT 3.5
add_test(NAME mytest COMMAND testDriver --config $<CONFIGURATION> --exe $<TARGET_FILE:myexe>)NINDENT NINDENT This creates a test mytest whose command runs a testDriver tool passing the configuration name and the full path to the executable file produced by target myexe. NOTE: NDENT 0.0 NDENT 3.5 CMake will generate tests only if the enable_testing() command has been invoked. The CTest module invokes the command automatically when the BUILD_TESTING option is ON. NINDENT NINDENT
----
0 NDENT 0.0 NDENT 3.5
add_test(<name> <command> [<arg>...])NINDENT NINDENT Add a test called <name> with the given command-line. Unlike the above NAME signature no transformation is performed on the command-line to support target names or generator expressions.
aux_source_directory(<dir> <variable>)NINDENT NINDENT Collects the names of all the source files in the specified directory and stores the list in the <variable> provided. This command is intended to be used by projects that use explicit template instantiation. Template instantiation files can be stored in a "Templates" subdirectory and collected automatically using this command to avoid manually listing all instantiations. It is tempting to use this command to avoid writing the list of source files for a library or executable target. While this seems to work, there is no way for CMake to generate a build system that knows when a new source file has been added. Normally the generated build system knows when it needs to rerun CMake because the CMakeLists.txt file is modified to add a new source. When the source is just added to the directory without modifying this file, one would have to manually rerun CMake to generate a build system incorporating the new file.
break()NINDENT NINDENT Breaks from an enclosing foreach loop or while loop See also the continue() command.
build_command(<variable> [CONFIGURATION <config>] [TARGET <target>] [PROJECT_NAME <projname>] # legacy, causes warning )NINDENT NINDENT Sets the given <variable> to a command-line string of the form: NDENT 0.0 NDENT 3.5
<cmake> --build . [--config <config>] [--target <target>] [-- -i]NINDENT NINDENT where <cmake> is the location of the cmake(1) command-line tool, and <config> and <target> are the values provided to the CONFIGURATION and TARGET options, if any. The trailing -- -i option is added for Makefile Generators if policy CMP0061 is not set to NEW. When invoked, this cmake --build command line will launch the underlying build system tool. NDENT 0.0 NDENT 3.5
build_command(<cachevariable> <makecommand>)NINDENT NINDENT This second signature is deprecated, but still available for backwards compatibility. Use the first signature instead. It sets the given <cachevariable> to a command-line string as above but without the --target option. The <makecommand> is ignored but should be the full path to msdev, devenv, nmake, make or one of the end user build tools for legacy invocations. NOTE: NDENT 0.0 NDENT 3.5 In CMake versions prior to 3.0 this command returned a command line that directly invokes the native build tool for the current generator. Their implementation of the PROJECT_NAME option had no useful effects, so CMake now warns on use of the option. NINDENT NINDENT
cmake_host_system_information(RESULT <variable> QUERY <key> ...)NINDENT NINDENT Queries system information of the host system on which cmake runs. One or more <key> can be provided to select the information to be queried. The list of queried values is stored in <variable>. <key> can be one of the following values: NDENT 0.0 NDENT 3.5
NUMBER_OF_LOGICAL_CORES = Number of logical cores. NUMBER_OF_PHYSICAL_CORES = Number of physical cores. HOSTNAME = Hostname. FQDN = Fully qualified domain name. TOTAL_VIRTUAL_MEMORY = Total virtual memory in megabytes. AVAILABLE_VIRTUAL_MEMORY = Available virtual memory in megabytes. TOTAL_PHYSICAL_MEMORY = Total physical memory in megabytes. AVAILABLE_PHYSICAL_MEMORY = Available physical memory in megabytes.NINDENT NINDENT
cmake_minimum_required(VERSION major[.minor[.patch[.tweak]]] [FATAL_ERROR])NINDENT NINDENT If the current version of CMake is lower than that required it will stop processing the project and report an error. When a version higher than 2.4 is specified the command implicitly invokes NDENT 0.0 NDENT 3.5
cmake_policy(VERSION major[.minor[.patch[.tweak]]])NINDENT NINDENT which sets the cmake policy version level to the version specified. When version 2.4 or lower is given the command implicitly invokes NDENT 0.0 NDENT 3.5
cmake_policy(VERSION 2.4)NINDENT NINDENT which enables compatibility features for CMake 2.4 and lower. The FATAL_ERROR option is accepted but ignored by CMake 2.6 and higher. It should be specified so CMake versions 2.4 and lower fail with an error instead of just a warning. NOTE: NDENT 0.0 NDENT 3.5 Call the cmake_minimum_required() command at the beginning of the top-level CMakeLists.txt file even before calling the project() command. It is important to establish version and policy settings before invoking other commands whose behavior they may affect. See also policy CMP0000. Calling cmake_minimum_required() inside a function() limits some effects to the function scope when invoked. Such calls should not be made with the intention of having global effects. NINDENT NINDENT
cmake_policy(VERSION major.minor[.patch[.tweak]])NINDENT NINDENT Specify that the current CMake code is written for the given version of CMake. All policies introduced in the specified version or earlier will be set to use NEW behavior. All policies introduced after the specified version will be unset (unless the CMAKE_POLICY_DEFAULT_CMP<NNNN> variable sets a default). This effectively requests behavior preferred as of a given CMake version and tells newer CMake versions to warn about their new policies. The policy version specified must be at least 2.4 or the command will report an error. Note that the cmake_minimum_required(VERSION) command implicitly calls cmake_policy(VERSION) too.
cmake_policy(SET CMP<NNNN> NEW) cmake_policy(SET CMP<NNNN> OLD)NINDENT NINDENT Tell CMake to use the OLD or NEW behavior for a given policy. Projects depending on the old behavior of a given policy may silence a policy warning by setting the policy state to OLD. Alternatively one may fix the project to work with the new behavior and set the policy state to NEW. NOTE: NDENT 0.0 NDENT 3.5 The OLD behavior of a policy is deprecated by definition and may be removed in a future version of CMake. NINDENT NINDENT
cmake_policy(GET CMP<NNNN> <variable>)NINDENT NINDENT Check whether a given policy is set to OLD or NEW behavior. The output <variable> value will be OLD or NEW if the policy is set, and empty otherwise.
cmake_policy(PUSH) cmake_policy(POP)NINDENT NINDENT Each PUSH must have a matching POP to erase any changes. This is useful to make temporary changes to policy settings. Calls to the cmake_minimum_required(VERSION), cmake_policy(VERSION), or cmake_policy(SET) commands influence only the current top of the policy stack. Commands created by the function() and macro() commands record policy settings when they are created and use the pre-record policies when they are invoked. If the function or macro implementation sets policies, the changes automatically propagate up through callers until they reach the closest nested policy stack entry.
configure_file(<input> <output> [COPYONLY] [ESCAPE_QUOTES] [@ONLY] [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])NINDENT NINDENT Copies an <input> file to an <output> file and substitutes variable values referenced as @VAR@ or ${VAR} in the input file content. Each variable reference will be replaced with the current value of the variable, or the empty string if the variable is not defined. Furthermore, input lines of the form: NDENT 0.0 NDENT 3.5
#cmakedefine VAR ...NINDENT NINDENT will be replaced with either: NDENT 0.0 NDENT 3.5
#define VAR ...NINDENT NINDENT or: NDENT 0.0 NDENT 3.5
/* #undef VAR */NINDENT NINDENT depending on whether VAR is set in CMake to any value not considered a false constant by the if() command. The "..." content on the line after the variable name, if any, is processed as above. Input file lines of the form #cmakedefine01 VAR will be replaced with either #define VAR 1 or #define VAR 0 similarly. If the input file is modified the build system will re-run CMake to re-configure the file and generate the build system again. The arguments are: NDENT 0.0
<input> Path to the input file. A relative path is treated with respect to the value of CMAKE_CURRENT_SOURCE_DIR. The input path must be a file, not a directory.
<output> Path to the output file or directory. A relative path is treated with respect to the value of CMAKE_CURRENT_BINARY_DIR. If the path names an existing directory the output file is placed in that directory with the same file name as the input file.
COPYONLY Copy the file without replacing any variable references or other content. This option may not be used with NEWLINE_STYLE.
ESCAPE_QUOTES Escape any substituted quotes with backslashes (C-style).
@ONLY Restrict variable replacement to references of the form @VAR@. This is useful for configuring scripts that use ${VAR} syntax.
NEWLINE_STYLE <style> Specify the newline style for the output file. Specify UNIX or LF for \en newlines, or specify DOS, WIN32, or CRLF for \er\en newlines. This option may not be used with COPYONLY. NINDENT
#cmakedefine FOO_ENABLE #cmakedefine FOO_STRING "@FOO_STRING@"NINDENT NINDENT An adjacent CMakeLists.txt may use configure_file to configure the header: NDENT 0.0 NDENT 3.5
option(FOO_ENABLE "Enable Foo" ON) if(FOO_ENABLE) set(FOO_STRING "foo") endif() configure_file(foo.h.in foo.h @ONLY)NINDENT NINDENT This creates a foo.h in the build directory corresponding to this source directory. If the FOO_ENABLE option is on, the configured file will contain: NDENT 0.0 NDENT 3.5
#define FOO_ENABLE #define FOO_STRING "foo"NINDENT NINDENT Otherwise it will contain: NDENT 0.0 NDENT 3.5
/* #undef FOO_ENABLE */ /* #undef FOO_STRING */NINDENT NINDENT One may then use the include_directories() command to specify the output directory as an include directory: NDENT 0.0 NDENT 3.5
include_directories(${CMAKE_CURRENT_BINARY_DIR})NINDENT NINDENT so that sources may include the header as #include <foo.h>.
continue()NINDENT NINDENT The continue command allows a cmake script to abort the rest of a block in a foreach() or while() loop, and start at the top of the next iteration. See also the break() command.
create_test_sourcelist(sourceListName driverName test1 test2 test3 EXTRA_INCLUDE include.h FUNCTION function)NINDENT NINDENT A test driver is a program that links together many small tests into a single executable. This is useful when building static executables with large libraries to shrink the total required size. The list of source files needed to build the test driver will be in sourceListName. DriverName is the name of the test driver program. The rest of the arguments consist of a list of test source files, can be semicolon separated. Each test source file should have a function in it that is the same name as the file with no extension (foo.cxx should have int foo(int, char*[]);) DriverName will be able to call each of the tests by name on the command line. If EXTRA_INCLUDE is specified, then the next argument is included into the generated file. If FUNCTION is specified, then the next argument is taken as a function name that is passed a pointer to ac and av. This can be used to add extra command line processing to each test. The cmake variable CMAKE_TESTDRIVER_BEFORE_TESTMAIN can be set to have code that will be placed directly before calling the test main function. CMAKE_TESTDRIVER_AFTER_TESTMAIN can be set to have code that will be placed directly after the call to the test main function.
define_property(<GLOBAL | DIRECTORY | TARGET | SOURCE | TEST | VARIABLE | CACHED_VARIABLE> PROPERTY <name> [INHERITED] BRIEF_DOCS <brief-doc> [docs...] FULL_DOCS <full-doc> [docs...])NINDENT NINDENT Define one property in a scope for use with the set_property and get_property commands. This is primarily useful to associate documentation with property names that may be retrieved with the get_property command. The first argument determines the kind of scope in which the property should be used. It must be one of the following: NDENT 0.0 NDENT 3.5
GLOBAL = associated with the global namespace DIRECTORY = associated with one directory TARGET = associated with one target SOURCE = associated with one source file TEST = associated with a test named with add_test VARIABLE = documents a CMake language variable CACHED_VARIABLE = documents a CMake cache variableNINDENT NINDENT Note that unlike set_property and get_property no actual scope needs to be given; only the kind of scope is important. The required PROPERTY option is immediately followed by the name of the property being defined. If the INHERITED option then the get_property command will chain up to the next higher scope when the requested property is not set in the scope given to the command. DIRECTORY scope chains to GLOBAL. TARGET, SOURCE, and TEST chain to DIRECTORY. The BRIEF_DOCS and FULL_DOCS options are followed by strings to be associated with the property as its brief and full documentation. Corresponding options to the get_property command will retrieve the documentation.
elseif(expression)NINDENT NINDENT See the if command.
else(expression)NINDENT NINDENT See the if command.
enable_language(<lang> [OPTIONAL] )NINDENT NINDENT This command enables support for the named language in CMake. This is the same as the project command but does not create any of the extra variables that are created by the project command. Example languages are CXX, C, Fortran. This command must be called in file scope, not in a function call. Furthermore, it must be called in the highest directory common to all targets using the named language directly for compiling sources or indirectly through link dependencies. It is simplest to enable all needed languages in the top-level directory of a project. The OPTIONAL keyword is a placeholder for future implementation and does not currently work.
enable_testing()NINDENT NINDENT Enables testing for this directory and below. See also the add_test command. Note that ctest expects to find a test file in the build directory root. Therefore, this command should be in the source directory root.
endforeach(expression)NINDENT NINDENT See the FOREACH command.
endfunction(expression)NINDENT NINDENT See the function command.
endif(expression)NINDENT NINDENT See the if command.
endmacro(expression)NINDENT NINDENT See the macro command.
endwhile(expression)NINDENT NINDENT See the while command.
execute_process(COMMAND <cmd1> [args1...]] [COMMAND <cmd2> [args2...] [...]] [WORKING_DIRECTORY <directory>] [TIMEOUT <seconds>] [RESULT_VARIABLE <variable>] [OUTPUT_VARIABLE <variable>] [ERROR_VARIABLE <variable>] [INPUT_FILE <file>] [OUTPUT_FILE <file>] [ERROR_FILE <file>] [OUTPUT_QUIET] [ERROR_QUIET] [OUTPUT_STRIP_TRAILING_WHITESPACE] [ERROR_STRIP_TRAILING_WHITESPACE])NINDENT NINDENT Runs the given sequence of one or more commands with the standard output of each process piped to the standard input of the next. A single standard error pipe is used for all processes. Options: NDENT 0.0
COMMAND A child process command line. CMake executes the child process using operating system APIs directly. All arguments are passed VERBATIM to the child process. No intermediate shell is used, so shell operators such as > are treated as normal arguments. (Use the INPUT_*, OUTPUT_*, and ERROR_* options to redirect stdin, stdout, and stderr.)
WORKING_DIRECTORY The named directory will be set as the current working directory of the child processes.
TIMEOUT The child processes will be terminated if they do not finish in the specified number of seconds (fractions are allowed).
RESULT_VARIABLE The variable will be set to contain the result of running the processes. This will be an integer return code from the last child or a string describing an error condition.
OUTPUT_VARIABLE, ERROR_VARIABLE The variable named will be set with the contents of the standard output and standard error pipes, respectively. If the same variable is named for both pipes their output will be merged in the order produced.
INPUT_FILE, OUTPUT_FILE, ERROR_FILE The file named will be attached to the standard input of the first process, standard output of the last process, or standard error of all processes, respectively. If the same file is named for both output and error then it will be used for both.
OUTPUT_QUIET, ERROR_QUIET The standard output or standard error results will be quietly ignored. NINDENT If more than one OUTPUT_* or ERROR_* option is given for the same pipe the precedence is not specified. If no OUTPUT_* or ERROR_* options are given the output will be shared with the corresponding pipes of the CMake process itself. The \%execute_process() command is a newer more powerful version of exec_program(), but the old command has been kept for compatibility. Both commands run while CMake is processing the project prior to build system generation. Use add_custom_target() and add_custom_command() to create custom commands that run at build time.
export(EXPORT <export-name> [NAMESPACE <namespace>] [FILE <filename>])NINDENT NINDENT Create a file <filename> that may be included by outside projects to import targets from the current project\(aqs build tree. This is useful during cross-compiling to build utility executables that can run on the host platform in one project and then import them into another project being compiled for the target platform. If the NAMESPACE option is given the <namespace> string will be prepended to all target names written to the file. Target installations are associated with the export <export-name> using the EXPORT option of the install(TARGETS) command. The file created by this command is specific to the build tree and should never be installed. See the install(EXPORT) command to export targets from an installation tree. The properties set on the generated IMPORTED targets will have the same values as the final values of the input TARGETS. NDENT 0.0 NDENT 3.5
export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>] [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES])NINDENT NINDENT This signature is similar to the EXPORT signature, but targets are listed explicitly rather than specified as an export-name. If the APPEND option is given the generated code will be appended to the file instead of overwriting it. The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if present, causes the contents of the properties matching (IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)? to be exported, when policy CMP0022 is NEW. If a library target is included in the export but a target to which it links is not included the behavior is unspecified. NDENT 0.0 NDENT 3.5
export(PACKAGE <name>)NINDENT NINDENT Store the current build directory in the CMake user package registry for package <name>. The find_package command may consider the directory while searching for package <name>. This helps dependent projects find and use a package from the current project\(aqs build tree without help from the user. Note that the entry in the package registry that this command creates works only in conjunction with a package configuration file (<name>Config.cmake) that works with the build tree. In some cases, for example for packaging and for system wide installations, it is not desirable to write the user package registry. If the CMAKE_EXPORT_NO_PACKAGE_REGISTRY variable is enabled, the export(PACKAGE) command will do nothing.
----
0 NDENT 0.0 NDENT 3.5
file(WRITE <filename> <content>...) file(APPEND <filename> <content>...)NINDENT NINDENT Write <content> into a file called <filename>. If the file does not exist, it will be created. If the file already exists, WRITE mode will overwrite it and APPEND mode will append to the end. (If the file is a build input, use the configure_file() command to update the file only when its content changes.)
----
0 NDENT 0.0 NDENT 3.5
file(READ <filename> <variable> [OFFSET <offset>] [LIMIT <max-in>] [HEX])NINDENT NINDENT Read content from a file called <filename> and store it in a <variable>. Optionally start from the given <offset> and read at most <max-in> bytes. The HEX option causes data to be converted to a hexadecimal representation (useful for binary data).
----
0 NDENT 0.0 NDENT 3.5
file(STRINGS <filename> <variable> [<options>...])NINDENT NINDENT Parse a list of ASCII strings from <filename> and store it in <variable>. Binary data in the file are ignored. Carriage return (\er, CR) characters are ignored. The options are: NDENT 0.0
LENGTH_MAXIMUM <max-len> Consider only strings of at most a given length.
LENGTH_MINIMUM <min-len> Consider only strings of at least a given length.
LIMIT_COUNT <max-num> Limit the number of distinct strings to be extracted.
LIMIT_INPUT <max-in> Limit the number of input bytes to read from the file.
LIMIT_OUTPUT <max-out> Limit the number of total bytes to store in the <variable>.
NEWLINE_CONSUME Treat newline characters (\en, LF) as part of string content instead of terminating at them.
NO_HEX_CONVERSION Intel Hex and Motorola S-record files are automatically converted to binary while reading unless this option is given.
REGEX <regex> Consider only strings that match the given regular expression.
ENCODING <encoding-type> Consider strings of a given encoding. Currently supported encodings are: UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE. If the ENCODING option is not provided and the file has a Byte Order Mark, the ENCODING option will be defaulted to respect the Byte Order Mark. NINDENT For example, the code NDENT 0.0 NDENT 3.5
file(STRINGS myfile.txt myfile)NINDENT NINDENT stores a list in the variable myfile in which each item is a line from the input file.
----
0 NDENT 0.0 NDENT 3.5
file(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512> <filename> <variable>)NINDENT NINDENT Compute a cryptographic hash of the content of <filename> and store it in a <variable>.
----
0 NDENT 0.0 NDENT 3.5
file(GLOB <variable> [LIST_DIRECTORIES true|false] [RELATIVE <path>] [<globbing-expressions>...]) file(GLOB_RECURSE <variable> [FOLLOW_SYMLINKS] [LIST_DIRECTORIES true|false] [RELATIVE <path>] [<globbing-expressions>...])NINDENT NINDENT Generate a list of files that match the <globbing-expressions> and store it into the <variable>. Globbing expressions are similar to regular expressions, but much simpler. If RELATIVE flag is specified, the results will be returned as relative paths to the given path. By default GLOB lists directories - directories are omited in result if LIST_DIRECTORIES is set to false. NOTE: NDENT 0.0 NDENT 3.5 We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate. NINDENT NINDENT Examples of globbing expressions include: NDENT 0.0 NDENT 3.5
*.cxx - match all files with extension cxx *.vt? - match all files with extension vta,...,vtz f[3-5].txt - match files f3.txt, f4.txt, f5.txtNINDENT NINDENT The GLOB_RECURSE mode will traverse all the subdirectories of the matched directory and match the files. Subdirectories that are symlinks are only traversed if FOLLOW_SYMLINKS is given or policy CMP0009 is not set to NEW. By default GLOB_RECURSE omits directories from result list - setting LIST_DIRECTORIES to true adds directories to result list. If FOLLOW_SYMLINKS is given or policy CMP0009 is not set to OLD then LIST_DIRECTORIES treats symlinks as directories. Examples of recursive globbing include: NDENT 0.0 NDENT 3.5
/dir/*.py - match all python files in /dir and subdirectoriesNINDENT NINDENT
----
0 NDENT 0.0 NDENT 3.5
file(RENAME <oldname> <newname>)NINDENT NINDENT Move a file or directory within a filesystem from <oldname> to <newname>, replacing the destination atomically.
----
0 NDENT 0.0 NDENT 3.5
file(REMOVE [<files>...]) file(REMOVE_RECURSE [<files>...])NINDENT NINDENT Remove the given files. The REMOVE_RECURSE mode will remove the given files and directories, also non-empty directories
----
0 NDENT 0.0 NDENT 3.5
file(MAKE_DIRECTORY [<directories>...])NINDENT NINDENT Create the given directories and their parents as needed.
----
0 NDENT 0.0 NDENT 3.5
file(RELATIVE_PATH <variable> <directory> <file>)NINDENT NINDENT Compute the relative path from a <directory> to a <file> and store it in the <variable>.
----
0 NDENT 0.0 NDENT 3.5
file(TO_CMAKE_PATH "<path>" <variable>) file(TO_NATIVE_PATH "<path>" <variable>)NINDENT NINDENT The TO_CMAKE_PATH mode converts a native <path> into a cmake-style path with forward-slashes (/). The input can be a single path or a system search path like $ENV{PATH}. A search path will be converted to a cmake-style list separated by ; characters. The TO_NATIVE_PATH mode converts a cmake-style <path> into a native path with platform-specific slashes (\e on Windows and / elsewhere). Always use double quotes around the <path> to be sure it is treated as a single argument to this command.
----
0 NDENT 0.0 NDENT 3.5
file(DOWNLOAD <url> <file> [<options>...]) file(UPLOAD <file> <url> [<options>...])NINDENT NINDENT The DOWNLOAD mode downloads the given <url> to a local <file>. The UPLOAD mode uploads a local <file> to a given <url>. Options to both DOWNLOAD and UPLOAD are: NDENT 0.0
INACTIVITY_TIMEOUT <seconds> Terminate the operation after a period of inactivity.
LOG <variable> Store a human-readable log of the operation in a variable.
SHOW_PROGRESS Print progress information as status messages until the operation is complete.
STATUS <variable> Store the resulting status of the operation in a variable. The status is a ; 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> Terminate the operation after a given total time has elapsed. NINDENT Additional options to DOWNLOAD are: EXPECTED_HASH ALGO=<value> NDENT 0.0 NDENT 3.5 Verify that the downloaded content hash matches the expected value, where ALGO is one of MD5, SHA1, SHA224, SHA256, SHA384, or SHA512. If it does not match, the operation fails with an error. NINDENT NINDENT NDENT 0.0
EXPECTED_MD5 <value> Historical short-hand for EXPECTED_HASH MD5=<value>.
TLS_VERIFY <ON|OFF> Specify whether to verify the server certificate for https:// URLs. The default is to not verify.
TLS_CAINFO <file> Specify a custom Certificate Authority file for https:// URLs. NINDENT For https:// URLs CMake must be built with OpenSSL support. TLS/SSL certificates are not checked by default. Set TLS_VERIFY to ON to check certificates and/or use EXPECTED_HASH to verify downloaded content. If neither TLS option is given CMake will check variables CMAKE_TLS_VERIFY and CMAKE_TLS_CAINFO, respectively.
----
0 NDENT 0.0 NDENT 3.5
file(TIMESTAMP <filename> <variable> [<format>] [UTC])NINDENT NINDENT Compute a string representation of the modification time of <filename> and store it in <variable>. Should the command be unable to obtain a timestamp variable will be set to the empty string (""). See the string(TIMESTAMP) command for documentation of the <format> and UTC options.
----
0 NDENT 0.0 NDENT 3.5
file(GENERATE OUTPUT output-file <INPUT input-file|CONTENT content> [CONDITION expression])NINDENT NINDENT Generate an output file for each build configuration supported by the current CMake Generator. Evaluate generator expressions from the input content to produce the output content. The options are: NDENT 0.0
CONDITION <condition> Generate the output file for a particular configuration only if the condition is true. The condition must be either 0 or 1 after evaluating generator expressions.
CONTENT <content> Use the content given explicitly as input.
INPUT <input-file> Use the content from a given file as input.
OUTPUT <output-file> Specify the output file name to generate. Use generator expressions such as $<CONFIG> to specify a configuration-specific output file name. Multiple configurations may generate the same output file only if the generated content is identical. Otherwise, the <output-file> must evaluate to an unique name for each configuration. NINDENT Exactly one CONTENT or INPUT option must be given. A specific OUTPUT file may be named by at most one invocation of file(GENERATE). Generated files are modified on subsequent cmake runs only if their content is changed.
----
0 NDENT 0.0 NDENT 3.5
file(<COPY|INSTALL> <files>... DESTINATION <dir> [FILE_PERMISSIONS <permissions>...] [DIRECTORY_PERMISSIONS <permissions>...] [NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS] [FILES_MATCHING] [[PATTERN <pattern> | REGEX <regex>] [EXCLUDE] [PERMISSIONS <permissions>...]] [...])NINDENT NINDENT The COPY signature copies files, directories, and symlinks to a destination folder. Relative input paths are evaluated with respect to the current source directory, and a relative destination is evaluated with respect to the current build directory. Copying preserves input file timestamps, and optimizes out a file if it exists at the destination with the same timestamp. Copying preserves input permissions unless explicit permissions or NO_SOURCE_PERMISSIONS are given (default is USE_SOURCE_PERMISSIONS). See the install(DIRECTORY) command for documentation of permissions, FILES_MATCHING, PATTERN, REGEX, and EXCLUDE options. Copying directories preserves the structure of their content even if options are used to select a subset of files. The INSTALL signature differs slightly from COPY: it prints status messages (subject to the CMAKE_INSTALL_MESSAGE variable), and NO_SOURCE_PERMISSIONS is default. Installation scripts generated by the install() command use this signature (with some undocumented options for internal use).
----
0 NDENT 0.0 NDENT 3.5
file(LOCK <path> [DIRECTORY] [RELEASE] [GUARD <FUNCTION|FILE|PROCESS>] [RESULT_VARIABLE <variable>] [TIMEOUT <seconds>])NINDENT NINDENT Lock a file specified by <path> if no DIRECTORY option present and file <path>/cmake.lock otherwise. File will be locked for scope defined by GUARD option (default value is PROCESS). RELEASE option can be used to unlock file explicitly. If option TIMEOUT is not specified CMake will wait until lock succeed or until fatal error occurs. If TIMEOUT is set to 0 lock will be tried once and result will be reported immediately. If TIMEOUT is not 0 CMake will try to lock file for the period specified by <seconds> value. Any errors will be interpreted as fatal if there is no RESULT_VARIABLE option. Otherwise result will be stored in <variable> and will be 0 on success or error message on failure. Note that lock is advisory - there is no guarantee that other processes will respect this lock, i.e. lock synchronize two or more CMake instances sharing some modifiable resources. Similar logic applied to DIRECTORY option - locking parent directory doesn\(aqt prevent other LOCK commands to lock any child directory or file. Trying to lock file twice is not allowed. Any intermediate directories and file itself will be created if they not exist. GUARD and TIMEOUT options ignored on RELEASE operation.
find_file (<VAR> name1 [path1 path2 ...])NINDENT NINDENT The general signature is: NDENT 0.0 NDENT 3.5
find_file ( <VAR> name | NAMES name1 [name2 ...] [HINTS path1 [path2 ... ENV var]] [PATHS path1 [path2 ... ENV var]] [PATH_SUFFIXES suffix1 [suffix2 ...]] [DOC "cache documentation string"] [NO_DEFAULT_PATH] [NO_CMAKE_ENVIRONMENT_PATH] [NO_CMAKE_PATH] [NO_SYSTEM_ENVIRONMENT_PATH] [NO_CMAKE_SYSTEM_PATH] [CMAKE_FIND_ROOT_PATH_BOTH | ONLY_CMAKE_FIND_ROOT_PATH | NO_CMAKE_FIND_ROOT_PATH] )NINDENT NINDENT This command is used to find a full path to named file. A cache entry named by <VAR> is created to store the result of this command. If the full path to a file is found the result is stored in the variable and the search will not be repeated unless the variable is cleared. If nothing is found, the result will be <VAR>-NOTFOUND, and the search will be attempted again the next time find_file is invoked with the same variable. The name of the full path to a file that is searched for is specified by the names listed after the NAMES argument. Additional search locations can be specified after the PATHS argument. If ENV var is found in the HINTS or PATHS section the environment variable var will be read and converted from a system environment variable to a cmake style list of paths. For example ENV PATH would be a way to list the system path variable. The argument after DOC will be used for the documentation string in the cache. PATH_SUFFIXES specifies additional subdirectories to check below each search path. If NO_DEFAULT_PATH is specified, then no additional paths are added to the search. If NO_DEFAULT_PATH is not specified, the search process is as follows: NDENT 0.0
find_file (<VAR> NAMES name PATHS paths... NO_DEFAULT_PATH) find_file (<VAR> NAMES name)NINDENT NINDENT Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.
find_library (<VAR> name1 [path1 path2 ...])NINDENT NINDENT The general signature is: NDENT 0.0 NDENT 3.5
find_library ( <VAR> name | NAMES name1 [name2 ...] [NAMES_PER_DIR] [HINTS path1 [path2 ... ENV var]] [PATHS path1 [path2 ... ENV var]] [PATH_SUFFIXES suffix1 [suffix2 ...]] [DOC "cache documentation string"] [NO_DEFAULT_PATH] [NO_CMAKE_ENVIRONMENT_PATH] [NO_CMAKE_PATH] [NO_SYSTEM_ENVIRONMENT_PATH] [NO_CMAKE_SYSTEM_PATH] [CMAKE_FIND_ROOT_PATH_BOTH | ONLY_CMAKE_FIND_ROOT_PATH | NO_CMAKE_FIND_ROOT_PATH] )NINDENT NINDENT This command is used to find a library. A cache entry named by <VAR> is created to store the result of this command. If the library is found the result is stored in the variable and the search will not be repeated unless the variable is cleared. If nothing is found, the result will be <VAR>-NOTFOUND, and the search will be attempted again the next time find_library is invoked with the same variable. The name of the library that is searched for is specified by the names listed after the NAMES argument. Additional search locations can be specified after the PATHS argument. If ENV var is found in the HINTS or PATHS section the environment variable var will be read and converted from a system environment variable to a cmake style list of paths. For example ENV PATH would be a way to list the system path variable. The argument after DOC will be used for the documentation string in the cache. PATH_SUFFIXES specifies additional subdirectories to check below each search path. If NO_DEFAULT_PATH is specified, then no additional paths are added to the search. If NO_DEFAULT_PATH is not specified, the search process is as follows: NDENT 0.0
find_library (<VAR> NAMES name PATHS paths... NO_DEFAULT_PATH) find_library (<VAR> NAMES name)NINDENT NINDENT Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again. When more than one value is given to the NAMES option this command by default will consider one name at a time and search every directory for it. The NAMES_PER_DIR option tells this command to consider one directory at a time and search for all names in it. Each library name given to the NAMES option is first considered as a library file name and then considered with platform-specific prefixes (e.g. lib) and suffixes (e.g. .so). Therefore one may specify library file names such as libfoo.a directly. This can be used to locate static libraries on UNIX-like systems. If the library found is a framework, then VAR will be set to the full path to the framework <fullPath>/A.framework. When a full path to a framework is used as a library, CMake will use a -framework A, and a -F<fullPath> to link the framework to the target. If the global property FIND_LIBRARY_USE_LIB64_PATHS is set all search paths will be tested as normal, with "64/" appended, and with all matches of "lib/" replaced with "lib64/". This property is automatically set for the platforms that are known to need it if at least one of the languages supported by the PROJECT command is enabled.
find_package(<package> [version] [EXACT] [QUIET] [MODULE] [REQUIRED] [[COMPONENTS] [components...]] [OPTIONAL_COMPONENTS components...] [NO_POLICY_SCOPE])NINDENT NINDENT Finds and loads settings from an external project. <package>_FOUND will be set to indicate whether the package was found. When the package is found package-specific information is provided through variables and Imported Targets documented by the package itself. The QUIET option disables messages if the package cannot be found. The MODULE option disables the second signature documented below. The REQUIRED option stops processing with an error message if the package cannot be found. A package-specific list of required components may be listed after the COMPONENTS option (or after the REQUIRED option if present). Additional optional components may be listed after OPTIONAL_COMPONENTS. Available components and their influence on whether a package is considered to be found are defined by the target package. The [version] argument requests a version with which the package found should be compatible (format is major[.minor[.patch[.tweak]]]). The EXACT option requests that the version be matched exactly. If no [version] and/or component list is given to a recursive invocation inside a find-module, the corresponding arguments are forwarded automatically from the outer call (including the EXACT flag for [version]). Version support is currently provided only on a package-by-package basis (details below). User code should generally look for packages using the above simple signature. The remainder of this command documentation specifies the full command signature and details of the search process. Project maintainers wishing to provide a package to be found by this command are encouraged to read on. The command has two modes by which it searches for packages: "Module" mode and "Config" mode. Module mode is available when the command is invoked with the above reduced signature. CMake searches for a file called Find<package>.cmake in the CMAKE_MODULE_PATH followed by the CMake installation. If the file is found, it is read and processed by CMake. It is responsible for finding the package, checking the version, and producing any needed messages. Many find-modules provide limited or no support for versioning; check the module documentation. If no module is found and the MODULE option is not given the command proceeds to Config mode. The complete Config mode command signature is: NDENT 0.0 NDENT 3.5
find_package(<package> [version] [EXACT] [QUIET] [REQUIRED] [[COMPONENTS] [components...]] [CONFIG|NO_MODULE] [NO_POLICY_SCOPE] [NAMES name1 [name2 ...]] [CONFIGS config1 [config2 ...]] [HINTS path1 [path2 ... ]] [PATHS path1 [path2 ... ]] [PATH_SUFFIXES suffix1 [suffix2 ...]] [NO_DEFAULT_PATH] [NO_CMAKE_ENVIRONMENT_PATH] [NO_CMAKE_PATH] [NO_SYSTEM_ENVIRONMENT_PATH] [NO_CMAKE_PACKAGE_REGISTRY] [NO_CMAKE_BUILDS_PATH] # Deprecated; does nothing. [NO_CMAKE_SYSTEM_PATH] [NO_CMAKE_SYSTEM_PACKAGE_REGISTRY] [CMAKE_FIND_ROOT_PATH_BOTH | ONLY_CMAKE_FIND_ROOT_PATH | NO_CMAKE_FIND_ROOT_PATH])NINDENT NINDENT The CONFIG option may be used to skip Module mode explicitly and switch to Config mode. It is synonymous to using NO_MODULE. Config mode is also implied by use of options not specified in the reduced signature. Config mode attempts to locate a configuration file provided by the package to be found. A cache entry called <package>_DIR is created to hold the directory containing the file. By default the command searches for a package with the name <package>. If the NAMES option is given the names following it are used instead of <package>. The command searches for a file called <name>Config.cmake or <lower-case-name>-config.cmake for each name specified. A replacement set of possible configuration file names may be given using the CONFIGS option. The search procedure is specified below. Once found, the configuration file is read and processed by CMake. Since the file is provided by the package it already knows the location of package contents. The full path to the configuration file is stored in the cmake variable <package>_CONFIG. All configuration files which have been considered by CMake while searching for an installation of the package with an appropriate version are stored in the cmake variable <package>_CONSIDERED_CONFIGS, the associated versions in <package>_CONSIDERED_VERSIONS. If the package configuration file cannot be found CMake will generate an error describing the problem unless the QUIET argument is specified. If REQUIRED is specified and the package is not found a fatal error is generated and the configure step stops executing. If <package>_DIR has been set to a directory not containing a configuration file CMake will ignore it and search from scratch. When the [version] argument is given Config mode will only find a version of the package that claims compatibility with the requested version (format is major[.minor[.patch[.tweak]]]). If the EXACT option is given only a version of the package claiming an exact match of the requested version may be found. CMake does not establish any convention for the meaning of version numbers. Package version numbers are checked by "version" files provided by the packages themselves. For a candidate package configuration file <config-file>.cmake the corresponding version file is located next to it and named either <config-file>-version.cmake or <config-file>Version.cmake. If no such version file is available then the configuration file is assumed to not be compatible with any requested version. A basic version file containing generic version matching code can be created using the CMakePackageConfigHelpers module. When a version file is found it is loaded to check the requested version number. The version file is loaded in a nested scope in which the following variables have been defined: NDENT 0.0
PACKAGE_FIND_NAME the <package> name
PACKAGE_FIND_VERSION full requested version string
PACKAGE_FIND_VERSION_MAJOR major version if requested, else 0
PACKAGE_FIND_VERSION_MINOR minor version if requested, else 0
PACKAGE_FIND_VERSION_PATCH patch version if requested, else 0
PACKAGE_FIND_VERSION_TWEAK tweak version if requested, else 0
PACKAGE_FIND_VERSION_COUNT number of version components, 0 to 4 NINDENT The version file checks whether it satisfies the requested version and sets these variables: NDENT 0.0
PACKAGE_VERSION full provided version string
PACKAGE_VERSION_EXACT true if version is exact match
PACKAGE_VERSION_COMPATIBLE true if version is compatible
PACKAGE_VERSION_UNSUITABLE true if unsuitable as any version NINDENT These variables are checked by the find_package command to determine whether the configuration file provides an acceptable version. They are not available after the find_package call returns. If the version is acceptable the following variables are set: NDENT 0.0
<package>_VERSION full provided version string
<package>_VERSION_MAJOR major version if provided, else 0
<package>_VERSION_MINOR minor version if provided, else 0
<package>_VERSION_PATCH patch version if provided, else 0
<package>_VERSION_TWEAK tweak version if provided, else 0
<package>_VERSION_COUNT number of version components, 0 to 4 NINDENT and the corresponding package configuration file is loaded. When multiple package configuration files are available whose version files claim compatibility with the version requested it is unspecified which one is chosen. No attempt is made to choose a highest or closest version number. Config mode provides an elaborate interface and search procedure. Much of the interface is provided for completeness and for use internally by find-modules loaded by Module mode. Most user code should simply call: NDENT 0.0 NDENT 3.5
find_package(<package> [major[.minor]] [EXACT] [REQUIRED|QUIET])NINDENT NINDENT in order to find a package. Package maintainers providing CMake package configuration files are encouraged to name and install them such that the procedure outlined below will find them without requiring use of additional options. CMake constructs a set of possible installation prefixes for the package. Under each prefix several directories are searched for a configuration file. The tables below show the directories searched. Each entry is meant for installation trees following Windows (W), UNIX (U), or Apple (A) conventions: NDENT 0.0 NDENT 3.5
<prefix>/ (W) <prefix>/(cmake|CMake)/ (W) <prefix>/<name>*/ (W) <prefix>/<name>*/(cmake|CMake)/ (W) <prefix>/(lib/<arch>|lib|share)/cmake/<name>*/ (U) <prefix>/(lib/<arch>|lib|share)/<name>*/ (U) <prefix>/(lib/<arch>|lib|share)/<name>*/(cmake|CMake)/ (U)NINDENT NINDENT On systems supporting OS X Frameworks and Application Bundles the following directories are searched for frameworks or bundles containing a configuration file: NDENT 0.0 NDENT 3.5
<prefix>/<name>.framework/Resources/ (A) <prefix>/<name>.framework/Resources/CMake/ (A) <prefix>/<name>.framework/Versions/*/Resources/ (A) <prefix>/<name>.framework/Versions/*/Resources/CMake/ (A) <prefix>/<name>.app/Contents/Resources/ (A) <prefix>/<name>.app/Contents/Resources/CMake/ (A)NINDENT NINDENT In all cases the <name> is treated as case-insensitive and corresponds to any of the names specified (<package> or names given by NAMES). Paths with lib/<arch> are enabled if the CMAKE_LIBRARY_ARCHITECTURE variable is set. If PATH_SUFFIXES is specified the suffixes are appended to each (W) or (U) directory entry one-by-one. This set of directories is intended to work in cooperation with projects that provide configuration files in their installation trees. Directories above marked with (W) are intended for installations on Windows where the prefix may point at the top of an application\(aqs installation directory. Those marked with (U) are intended for installations on UNIX platforms where the prefix is shared by multiple packages. This is merely a convention, so all (W) and (U) directories are still searched on all platforms. Directories marked with (A) are intended for installations on Apple platforms. The cmake variables CMAKE_FIND_FRAMEWORK and CMAKE_FIND_APPBUNDLE determine the order of preference as specified below. The set of installation prefixes is constructed using the following steps. If NO_DEFAULT_PATH is specified all NO_* options are enabled. NDENT 0.0
CMAKE_PREFIX_PATH CMAKE_FRAMEWORK_PATH CMAKE_APPBUNDLE_PATHNINDENT NINDENT
<package>_DIR CMAKE_PREFIX_PATH CMAKE_FRAMEWORK_PATH CMAKE_APPBUNDLE_PATHNINDENT NINDENT
PATHNINDENT NINDENT
CMAKE_SYSTEM_PREFIX_PATH CMAKE_SYSTEM_FRAMEWORK_PATH CMAKE_SYSTEM_APPBUNDLE_PATHNINDENT NINDENT
find_package (<package> PATHS paths... NO_DEFAULT_PATH) find_package (<package>)NINDENT NINDENT Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again. Every non-REQUIRED find_package call can be disabled by setting the CMAKE_DISABLE_FIND_PACKAGE_<PackageName> variable to TRUE. When loading a find module or package configuration file find_package defines variables to provide information about the call arguments (and restores their original state before returning): NDENT 0.0
CMAKE_FIND_PACKAGE_NAME the <package> name which is searched for
<package>_FIND_REQUIRED true if REQUIRED option was given
<package>_FIND_QUIETLY true if QUIET option was given
<package>_FIND_VERSION full requested version string
<package>_FIND_VERSION_MAJOR major version if requested, else 0
<package>_FIND_VERSION_MINOR minor version if requested, else 0
<package>_FIND_VERSION_PATCH patch version if requested, else 0
<package>_FIND_VERSION_TWEAK tweak version if requested, else 0
<package>_FIND_VERSION_COUNT number of version components, 0 to 4
<package>_FIND_VERSION_EXACT true if EXACT option was given
<package>_FIND_COMPONENTS list of requested components
<package>_FIND_REQUIRED_<c> true if component <c> is required, false if component <c> is optional NINDENT In Module mode the loaded find module is responsible to honor the request detailed by these variables; see the find module for details. In Config mode find_package handles REQUIRED, QUIET, and [version] options automatically but leaves it to the package configuration file to handle components in a way that makes sense for the package. The package configuration file may set <package>_FOUND to false to tell find_package that component requirements are not satisfied. See the cmake_policy() command documentation for discussion of the NO_POLICY_SCOPE option.
find_path (<VAR> name1 [path1 path2 ...])NINDENT NINDENT The general signature is: NDENT 0.0 NDENT 3.5
find_path ( <VAR> name | NAMES name1 [name2 ...] [HINTS path1 [path2 ... ENV var]] [PATHS path1 [path2 ... ENV var]] [PATH_SUFFIXES suffix1 [suffix2 ...]] [DOC "cache documentation string"] [NO_DEFAULT_PATH] [NO_CMAKE_ENVIRONMENT_PATH] [NO_CMAKE_PATH] [NO_SYSTEM_ENVIRONMENT_PATH] [NO_CMAKE_SYSTEM_PATH] [CMAKE_FIND_ROOT_PATH_BOTH | ONLY_CMAKE_FIND_ROOT_PATH | NO_CMAKE_FIND_ROOT_PATH] )NINDENT NINDENT This command is used to find a directory containing the named file. A cache entry named by <VAR> is created to store the result of this command. If the file in a directory is found the result is stored in the variable and the search will not be repeated unless the variable is cleared. If nothing is found, the result will be <VAR>-NOTFOUND, and the search will be attempted again the next time find_path is invoked with the same variable. The name of the file in a directory that is searched for is specified by the names listed after the NAMES argument. Additional search locations can be specified after the PATHS argument. If ENV var is found in the HINTS or PATHS section the environment variable var will be read and converted from a system environment variable to a cmake style list of paths. For example ENV PATH would be a way to list the system path variable. The argument after DOC will be used for the documentation string in the cache. PATH_SUFFIXES specifies additional subdirectories to check below each search path. If NO_DEFAULT_PATH is specified, then no additional paths are added to the search. If NO_DEFAULT_PATH is not specified, the search process is as follows: NDENT 0.0
find_path (<VAR> NAMES name PATHS paths... NO_DEFAULT_PATH) find_path (<VAR> NAMES name)NINDENT NINDENT Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again. When searching for frameworks, if the file is specified as A/b.h, then the framework search will look for A.framework/Headers/b.h. If that is found the path will be set to the path to the framework. CMake will convert this to the correct -F option to include the file.
find_program (<VAR> name1 [path1 path2 ...])NINDENT NINDENT The general signature is: NDENT 0.0 NDENT 3.5
find_program ( <VAR> name | NAMES name1 [name2 ...] [HINTS path1 [path2 ... ENV var]] [PATHS path1 [path2 ... ENV var]] [PATH_SUFFIXES suffix1 [suffix2 ...]] [DOC "cache documentation string"] [NO_DEFAULT_PATH] [NO_CMAKE_ENVIRONMENT_PATH] [NO_CMAKE_PATH] [NO_SYSTEM_ENVIRONMENT_PATH] [NO_CMAKE_SYSTEM_PATH] [CMAKE_FIND_ROOT_PATH_BOTH | ONLY_CMAKE_FIND_ROOT_PATH | NO_CMAKE_FIND_ROOT_PATH] )NINDENT NINDENT This command is used to find a program. A cache entry named by <VAR> is created to store the result of this command. If the program is found the result is stored in the variable and the search will not be repeated unless the variable is cleared. If nothing is found, the result will be <VAR>-NOTFOUND, and the search will be attempted again the next time find_program is invoked with the same variable. The name of the program that is searched for is specified by the names listed after the NAMES argument. Additional search locations can be specified after the PATHS argument. If ENV var is found in the HINTS or PATHS section the environment variable var will be read and converted from a system environment variable to a cmake style list of paths. For example ENV PATH would be a way to list the system path variable. The argument after DOC will be used for the documentation string in the cache. PATH_SUFFIXES specifies additional subdirectories to check below each search path. If NO_DEFAULT_PATH is specified, then no additional paths are added to the search. If NO_DEFAULT_PATH is not specified, the search process is as follows: NDENT 0.0
find_program (<VAR> NAMES name PATHS paths... NO_DEFAULT_PATH) find_program (<VAR> NAMES name)NINDENT NINDENT Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.
fltk_wrap_ui(resultingLibraryName source1 source2 ... sourceN )NINDENT NINDENT Produce .h and .cxx files for all the .fl and .fld files listed. The resulting .h and .cxx files will be added to a variable named resultingLibraryName_FLTK_UI_SRCS which should be added to your library.
foreach(loop_var arg1 arg2 ...) COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... endforeach(loop_var)NINDENT NINDENT All commands between foreach and the matching endforeach are recorded without being invoked. Once the endforeach is evaluated, the recorded list of commands is invoked once for each argument listed in the original foreach command. Before each iteration of the loop "${loop_var}" will be set as a variable with the current value in the list. NDENT 0.0 NDENT 3.5
foreach(loop_var RANGE total) foreach(loop_var RANGE start stop [step])NINDENT NINDENT Foreach can also iterate over a generated range of numbers. There are three types of this iteration: NDENT 0.0
foreach(loop_var IN [LISTS [list1 [...]]] [ITEMS [item1 [...]]])NINDENT NINDENT Iterates over a precise list of items. The LISTS option names list-valued variables to be traversed, including empty elements (an empty string is a zero-length list). (Note macro arguments are not variables.) The ITEMS option ends argument parsing and includes all arguments following it in the iteration.
function(<name> [arg1 [arg2 [arg3 ...]]]) COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... endfunction(<name>)NINDENT NINDENT Define a function named <name> that takes arguments named arg1, arg2, arg3, (...). Commands listed after function, but before the matching endfunction(), are not invoked until the function is invoked. When it is invoked, the commands recorded in the function are first modified by replacing formal parameters (${arg1}) with the arguments passed, and then invoked as normal commands. In addition to referencing the formal parameters you can reference the ARGC variable which will be set to the number of arguments passed into the function as well as ARGV0, ARGV1, ARGV2, ... which will have the actual values of the arguments passed in. This facilitates creating functions with optional arguments. Additionally ARGV holds the list of all arguments given to the function and ARGN holds the list of arguments past the last expected argument. Referencing to ARGV# arguments beyond ARGC have undefined behavior. Checking that ARGC is greater than # is the only way to ensure that ARGV# was passed to the function as an extra argument. A function opens a new scope: see set(var PARENT_SCOPE) for details. See the cmake_policy() command documentation for the behavior of policies inside functions.
get_cmake_property(VAR property)NINDENT NINDENT Get a property from the CMake instance. The value of the property is stored in the variable VAR. If the property is not found, VAR will be set to "NOTFOUND". Some supported properties include: VARIABLES, CACHE_VARIABLES, COMMANDS, MACROS, and COMPONENTS. See also the more general get_property() command.
get_directory_property(<variable> [DIRECTORY <dir>] <prop-name>)NINDENT NINDENT Store a property of directory scope in the named variable. If the property is not defined the empty-string is returned. The DIRECTORY argument specifies another directory from which to retrieve the property value. The specified directory must have already been traversed by CMake. NDENT 0.0 NDENT 3.5
get_directory_property(<variable> [DIRECTORY <dir>] DEFINITION <var-name>)NINDENT NINDENT Get a variable definition from a directory. This form is useful to get a variable definition from another directory. See also the more general get_property() command.
get_filename_component(<VAR> <FileName> <COMP> [CACHE])NINDENT NINDENT Set <VAR> to a component of <FileName>, where <COMP> is one of: NDENT 0.0 NDENT 3.5
DIRECTORY = Directory without file name NAME = File name without directory EXT = File name longest extension (.b.c from d/a.b.c) NAME_WE = File name without directory or longest extension ABSOLUTE = Full path to file REALPATH = Full path to existing file with symlinks resolved PATH = Legacy alias for DIRECTORY (use for CMake <= 2.8.11)NINDENT NINDENT Paths are returned with forward slashes and have no trailing slahes. The longest file extension is always considered. If the optional CACHE argument is specified, the result variable is added to the cache. NDENT 0.0 NDENT 3.5
get_filename_component(<VAR> FileName PROGRAM [PROGRAM_ARGS <ARG_VAR>] [CACHE])NINDENT NINDENT The program in FileName will be found in the system search path or left as a full path. If PROGRAM_ARGS is present with PROGRAM, then any command-line arguments present in the FileName string are split from the program name and stored in <ARG_VAR>. This is used to separate a program name from its arguments in a command line string.
get_property(<variable> <GLOBAL | DIRECTORY [dir] | TARGET <target> | SOURCE <source> | INSTALL <file> | TEST <test> | CACHE <entry> | VARIABLE> PROPERTY <name> [SET | DEFINED | BRIEF_DOCS | FULL_DOCS])NINDENT NINDENT Get one property from one object in a scope. The first argument specifies the variable in which to store the result. The second argument determines the scope from which to get the property. It must be one of the following: NDENT 0.0
GLOBAL Scope is unique and does not accept a name.
DIRECTORY Scope defaults to the current directory but another directory (already processed by CMake) may be named by full or relative path.
TARGET Scope must name one existing target.
SOURCE Scope must name one source file.
INSTALL Scope must name one installed file path.
TEST Scope must name one existing test.
CACHE Scope must name one cache entry.
VARIABLE Scope is unique and does not accept a name. NINDENT The required PROPERTY option is immediately followed by the name of the property to get. If the property is not set an empty value is returned. If the SET option is given the variable is set to a boolean value indicating whether the property has been set. If the DEFINED option is given the variable is set to a boolean value indicating whether the property has been defined such as with the define_property() command. If BRIEF_DOCS or FULL_DOCS is given then the variable is set to a string containing documentation for the requested property. If documentation is requested for a property that has not been defined NOTFOUND is returned.
get_source_file_property(VAR file property)NINDENT NINDENT Get a property from a source file. The value of the property is stored in the variable VAR. If the property is not found, VAR will be set to "NOTFOUND". Use set_source_files_properties to set property values. Source file properties usually control how the file is built. One property that is always there is LOCATION See also the more general get_property() command.
get_target_property(VAR target property)NINDENT NINDENT Get a property from a target. The value of the property is stored in the variable VAR. If the property is not found, VAR will be set to "NOTFOUND". Use set_target_properties to set property values. Properties are usually used to control how a target is built, but some query the target instead. This command can get properties for any target so far created. The targets do not need to be in the current CMakeLists.txt file. See also the more general get_property() command.
get_test_property(test property VAR)NINDENT NINDENT Get a property from the test. The value of the property is stored in the variable VAR. If the test or property is not found, VAR will be set to "NOTFOUND". For a list of standard properties you can type cmake --help-property-list. See also the more general get_property() command.
if(expression) # then section. COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... elseif(expression2) # elseif section. COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... else(expression) # else section. COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... endif(expression)NINDENT NINDENT Evaluates the given expression. If the result is true, the commands in the THEN section are invoked. Otherwise, the commands in the else section are invoked. The elseif and else sections are optional. You may have multiple elseif clauses. Note that the expression in the else and endif clause is optional. Long expressions can be used and there is a traditional order of precedence. Parenthetical expressions are evaluated first followed by unary tests such as EXISTS, COMMAND, and DEFINED. Then any binary tests such as EQUAL, LESS, GREATER, STRLESS, STRGREATER, STREQUAL, and MATCHES will be evaluated. Then boolean NOT operators and finally boolean AND and then OR operators will be evaluated. Possible expressions are: NDENT 0.0
if(<constant>) True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number. False if the constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, the empty string, or ends in the suffix -NOTFOUND. Named boolean constants are case-insensitive. If the argument is not one of these specific constants, it is treated as a variable or string and the following signature is used.
if(<variable|string>) True if given a variable that is defined to a value that is not a false constant. False otherwise. (Note macro arguments are not variables.)
if(NOT <expression>) True if the expression is not true.
if(<expr1> AND <expr2>) True if both expressions would be considered true individually.
if(<expr1> OR <expr2>) True if either expression would be considered true individually.
if(COMMAND command-name) True if the given name is a command, macro or function that can be invoked.
if(POLICY policy-id) True if the given name is an existing policy (of the form CMP<NNNN>).
if(TARGET target-name) True if the given name is an existing logical target name such as those created by the add_executable(), add_library(), or add_custom_target() commands.
if(EXISTS path-to-file-or-directory) True if the named file or directory exists. Behavior is well-defined only for full paths.
if(file1 IS_NEWER_THAN file2) True if file1 is newer than file2 or if one of the two files doesn\(aqt exist. Behavior is well-defined only for full paths. If the file time stamps are exactly the same, an IS_NEWER_THAN comparison returns true, so that any dependent build operations will occur in the event of a tie. This includes the case of passing the same file name for both file1 and file2.
if(IS_DIRECTORY path-to-directory) True if the given name is a directory. Behavior is well-defined only for full paths.
if(IS_SYMLINK file-name) True if the given name is a symbolic link. Behavior is well-defined only for full paths.
if(IS_ABSOLUTE path) True if the given path is an absolute path.
if(<variable|string> MATCHES regex) True if the given string or variable\(aqs value matches the given regular expression.
if(<variable|string> LESS <variable|string>) True if the given string or variable\(aqs value is a valid number and less than that on the right.
if(<variable|string> GREATER <variable|string>) True if the given string or variable\(aqs value is a valid number and greater than that on the right.
if(<variable|string> EQUAL <variable|string>) True if the given string or variable\(aqs value is a valid number and equal to that on the right.
if(<variable|string> STRLESS <variable|string>) True if the given string or variable\(aqs value is lexicographically less than the string or variable on the right.
if(<variable|string> STRGREATER <variable|string>) True if the given string or variable\(aqs value is lexicographically greater than the string or variable on the right.
if(<variable|string> STREQUAL <variable|string>) True if the given string or variable\(aqs value is lexicographically equal to the string or variable on the right.
if(<variable|string> VERSION_LESS <variable|string>) Component-wise integer version number comparison (version format is major[.minor[.patch[.tweak]]]).
if(<variable|string> VERSION_EQUAL <variable|string>) Component-wise integer version number comparison (version format is major[.minor[.patch[.tweak]]]).
if(<variable|string> VERSION_GREATER <variable|string>) Component-wise integer version number comparison (version format is major[.minor[.patch[.tweak]]]).
if(<variable|string> IN_LIST <variable>) True if the given element is contained in the named list variable.
if(DEFINED <variable>) True if the given variable is defined. It does not matter if the variable is true or false just if it has been set. (Note macro arguments are not variables.)
if((expression) AND (expression OR (expression))) The expressions inside the parenthesis are evaluated first and then the remaining expression is evaluated as in the previous examples. Where there are nested parenthesis the innermost are evaluated as part of evaluating the expression that contains them. NINDENT The if command was written very early in CMake\(aqs history, predating the ${} variable evaluation syntax, and for convenience evaluates variables named by its arguments as shown in the above signatures. Note that normal variable evaluation with ${} applies before the if command even receives the arguments. Therefore code like: NDENT 0.0 NDENT 3.5
set(var1 OFF) set(var2 "var1") if(${var2})NINDENT NINDENT appears to the if command as: NDENT 0.0 NDENT 3.5
if(var1)NINDENT NINDENT and is evaluated according to the if(<variable>) case documented above. The result is OFF which is false. However, if we remove the ${} from the example then the command sees: NDENT 0.0 NDENT 3.5
if(var2)NINDENT NINDENT which is true because var2 is defined to "var1" which is not a false constant. Automatic evaluation applies in the other cases whenever the above-documented signature accepts <variable|string>: NDENT 0.0
include_directories([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...])NINDENT NINDENT Add the given directories to those the compiler uses to search for include files. Relative paths are interpreted as relative to the current source directory. The include directories are added to the INCLUDE_DIRECTORIES directory property for the current CMakeLists file. They are also added to the INCLUDE_DIRECTORIES target property for each target in the current CMakeLists file. The target property values are the ones used by the generators. By default the directories specified are appended onto the current list of directories. This default behavior can be changed by setting CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. By using AFTER or BEFORE explicitly, you can select between appending and prepending, independent of the default. If the SYSTEM option is given, the compiler will be told the directories are meant as system include directories on some platforms. Signalling this setting might achieve effects such as the compiler skipping warnings, or these fixed-install system files not being considered in dependency calculations - see compiler docs. Arguments to include_directories may use "generator expressions" with the syntax "$<...>". See the cmake-generator-expressions(7) manual for available expressions. See the cmake-buildsystem(7) manual for more on defining buildsystem properties.
include_external_msproject(projectname location [TYPE projectTypeGUID] [GUID projectGUID] [PLATFORM platformName] dep1 dep2 ...)NINDENT NINDENT Includes an external Microsoft project in the generated workspace file. Currently does nothing on UNIX. This will create a target named [projectname]. This can be used in the add_dependencies command to make things depend on the external project. TYPE, GUID and PLATFORM are optional parameters that allow one to specify the type of project, id (GUID) of the project and the name of the target platform. This is useful for projects requiring values other than the default (e.g. WIX projects). These options are not supported by the Visual Studio 6 generator.
include_regular_expression(regex_match [regex_complain])NINDENT NINDENT Set the regular expressions used in dependency checking. Only files matching regex_match will be traced as dependencies. Only files matching regex_complain will generate warnings if they cannot be found (standard header paths are not searched). The defaults are: NDENT 0.0 NDENT 3.5
regex_match = "^.*$" (match everything) regex_complain = "^$" (match empty string only)NINDENT NINDENT
include(<file|module> [OPTIONAL] [RESULT_VARIABLE <VAR>] [NO_POLICY_SCOPE])NINDENT NINDENT Load and run CMake code from the file given. Variable reads and writes access the scope of the caller (dynamic scoping). If OPTIONAL is present, then no error is raised if the file does not exist. If RESULT_VARIABLE is given the variable will be set to the full filename which has been included or NOTFOUND if it failed. If a module is specified instead of a file, the file with name <modulename>.cmake is searched first in CMAKE_MODULE_PATH, then in the CMake module directory. There is one exception to this: if the file which calls include() is located itself in the CMake module directory, then first the CMake module directory is searched and CMAKE_MODULE_PATH afterwards. See also policy CMP0017. See the cmake_policy() command documentation for discussion of the NO_POLICY_SCOPE option.
DESTINATION Specify the directory on disk to which a file will be installed. If a full path (with a leading slash or drive letter) is given it is used directly. If a relative path is given it is interpreted relative to the value of the CMAKE_INSTALL_PREFIX variable. The prefix can be relocated at install time using the DESTDIR mechanism explained in the CMAKE_INSTALL_PREFIX variable documentation.
PERMISSIONS Specify permissions for installed files. Valid permissions are OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ, GROUP_WRITE, GROUP_EXECUTE, WORLD_READ, WORLD_WRITE, WORLD_EXECUTE, SETUID, and SETGID. Permissions that do not make sense on certain platforms are ignored on those platforms.
CONFIGURATIONS Specify a list of build configurations for which the install rule applies (Debug, Release, etc.).
COMPONENT Specify an installation component name with which the install rule is associated, such as "runtime" or "development". During component-specific installation only install rules associated with the given component name will be executed. During a full installation all components are installed. If COMPONENT is not provided a default component "Unspecified" is created. The default component name may be controlled with the CMAKE_INSTALL_DEFAULT_COMPONENT_NAME variable.
RENAME Specify a name for an installed file that may be different from the original file. Renaming is allowed only when a single file is installed by the command.
OPTIONAL Specify that it is not an error if the file to be installed does not exist. NINDENT Command signatures that install files may print messages during installation. Use the CMAKE_INSTALL_MESSAGE variable to control which messages are printed.
install(TARGETS targets... [EXPORT <export-name>] [[ARCHIVE|LIBRARY|RUNTIME|FRAMEWORK|BUNDLE| PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE] [DESTINATION <dir>] [INCLUDES DESTINATION [<dir> ...]] [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [COMPONENT <component>] [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP] ] [...])NINDENT NINDENT The TARGETS form specifies rules for installing targets from a project. There are five kinds of target files that may be installed: ARCHIVE, LIBRARY, RUNTIME, FRAMEWORK, and BUNDLE. Executables are treated as RUNTIME targets, except that those marked with the MACOSX_BUNDLE property are treated as BUNDLE targets on OS X. Static libraries are always treated as ARCHIVE targets. Module libraries are always treated as LIBRARY targets. For non-DLL platforms shared libraries are treated as LIBRARY targets, except that those marked with the FRAMEWORK property are treated as FRAMEWORK targets on OS X. For DLL platforms the DLL part of a shared library is treated as a RUNTIME target and the corresponding import library is treated as an ARCHIVE target. All Windows-based systems including Cygwin are DLL platforms. The ARCHIVE, LIBRARY, RUNTIME, and FRAMEWORK arguments change the type of target to which the subsequent properties apply. If none is given the installation properties apply to all target types. If only one is given then only targets of that type will be installed (which can be used to install just a DLL or just an import library). The INCLUDES DESTINATION specifies a list of directories which will be added to the INTERFACE_INCLUDE_DIRECTORIES target property of the <targets> when exported by the \%install(EXPORT) command. If a relative path is specified, it is treated as relative to the $<INSTALL_PREFIX>. The PRIVATE_HEADER, PUBLIC_HEADER, and RESOURCE arguments cause subsequent properties to be applied to installing a FRAMEWORK shared library target\(aqs associated files on non-Apple platforms. Rules defined by these arguments are ignored on Apple platforms because the associated files are installed into the appropriate locations inside the framework folder. See documentation of the PRIVATE_HEADER, PUBLIC_HEADER, and RESOURCE target properties for details. Either NAMELINK_ONLY or NAMELINK_SKIP may be specified as a LIBRARY option. On some platforms a versioned shared library has a symbolic link such as: NDENT 0.0 NDENT 3.5
lib<name>.so -> lib<name>.so.1NINDENT NINDENT where lib<name>.so.1 is the soname of the library and lib<name>.so is a "namelink" allowing linkers to find the library when given -l<name>. The NAMELINK_ONLY option causes installation of only the namelink when a library target is installed. The NAMELINK_SKIP option causes installation of library files other than the namelink when a library target is installed. When neither option is given both portions are installed. On platforms where versioned shared libraries do not have namelinks or when a library is not versioned the NAMELINK_SKIP option installs the library and the NAMELINK_ONLY option installs nothing. See the VERSION and SOVERSION target properties for details on creating versioned shared libraries. One or more groups of properties may be specified in a single call to the TARGETS form of this command. A target may be installed more than once to different locations. Consider hypothetical targets myExe, mySharedLib, and myStaticLib. The code: NDENT 0.0 NDENT 3.5
install(TARGETS myExe mySharedLib myStaticLib RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib/static) install(TARGETS mySharedLib DESTINATION /some/full/path)NINDENT NINDENT will install myExe to <prefix>/bin and myStaticLib to <prefix>/lib/static. On non-DLL platforms mySharedLib will be installed to <prefix>/lib and /some/full/path. On DLL platforms the mySharedLib DLL will be installed to <prefix>/bin and /some/full/path and its import library will be installed to <prefix>/lib/static and /some/full/path. The EXPORT option associates the installed target files with an export called <export-name>. It must appear before any RUNTIME, LIBRARY, or ARCHIVE options. To actually install the export file itself, call install(EXPORT), documented below. Installing a target with the EXCLUDE_FROM_ALL target property set to TRUE has undefined behavior. The install destination given to the target install DESTINATION may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions.
install(<FILES|PROGRAMS> files... DESTINATION <dir> [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [COMPONENT <component>] [RENAME <name>] [OPTIONAL])NINDENT NINDENT The FILES form specifies rules for installing files for a project. File names given as relative paths are interpreted with respect to the current source directory. Files installed by this form are by default given permissions OWNER_WRITE, OWNER_READ, GROUP_READ, and WORLD_READ if no PERMISSIONS argument is given. The PROGRAMS form is identical to the FILES form except that the default permissions for the installed file also include OWNER_EXECUTE, GROUP_EXECUTE, and WORLD_EXECUTE. This form is intended to install programs that are not targets, such as shell scripts. Use the TARGETS form to install targets built within the project. The list of files... given to FILES or PROGRAMS may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions. However, if any item begins in a generator expression it must evaluate to a full path.
install(DIRECTORY dirs... DESTINATION <dir> [FILE_PERMISSIONS permissions...] [DIRECTORY_PERMISSIONS permissions...] [USE_SOURCE_PERMISSIONS] [OPTIONAL] [MESSAGE_NEVER] [CONFIGURATIONS [Debug|Release|...]] [COMPONENT <component>] [FILES_MATCHING] [[PATTERN <pattern> | REGEX <regex>] [EXCLUDE] [PERMISSIONS permissions...]] [...])NINDENT NINDENT The DIRECTORY form installs contents of one or more directories to a given destination. The directory structure is copied verbatim to the destination. The last component of each directory name is appended to the destination directory but a trailing slash may be used to avoid this because it leaves the last component empty. Directory names given as relative paths are interpreted with respect to the current source directory. If no input directory names are given the destination directory will be created but nothing will be installed into it. The FILE_PERMISSIONS and DIRECTORY_PERMISSIONS options specify permissions given to files and directories in the destination. If USE_SOURCE_PERMISSIONS is specified and FILE_PERMISSIONS is not, file permissions will be copied from the source directory structure. If no permissions are specified files will be given the default permissions specified in the FILES form of the command, and the directories will be given the default permissions specified in the PROGRAMS form of the command. The MESSAGE_NEVER option disables file installation status output. Installation of directories may be controlled with fine granularity using the PATTERN or REGEX options. These "match" options specify a globbing pattern or regular expression to match directories or files encountered within input directories. They may be used to apply certain options (see below) to a subset of the files and directories encountered. The full path to each input file or directory (with forward slashes) is matched against the expression. A PATTERN will match only complete file names: the portion of the full path matching the pattern must occur at the end of the file name and be preceded by a slash. A REGEX will match any portion of the full path but it may use / and $ to simulate the PATTERN behavior. By default all files and directories are installed whether or not they are matched. The FILES_MATCHING option may be given before the first match option to disable installation of files (but not directories) not matched by any expression. For example, the code NDENT 0.0 NDENT 3.5
install(DIRECTORY src/ DESTINATION include/myproj FILES_MATCHING PATTERN "*.h")NINDENT NINDENT will extract and install header files from a source tree. Some options may follow a PATTERN or REGEX expression and are applied only to files or directories matching them. The EXCLUDE option will skip the matched file or directory. The PERMISSIONS option overrides the permissions setting for the matched file or directory. For example the code NDENT 0.0 NDENT 3.5
install(DIRECTORY icons scripts/ DESTINATION share/myproj PATTERN "CVS" EXCLUDE PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ)NINDENT NINDENT will install the icons directory to share/myproj/icons and the scripts directory to share/myproj. The icons will get default file permissions, the scripts will be given specific permissions, and any CVS directories will be excluded.
install([[SCRIPT <file>] [CODE <code>]] [COMPONENT <component>] [...])NINDENT NINDENT The SCRIPT form will invoke the given CMake script files during installation. If the script file name is a relative path it will be interpreted with respect to the current source directory. The CODE form will invoke the given CMake code during installation. Code is specified as a single argument inside a double-quoted string. For example, the code NDENT 0.0 NDENT 3.5
install(CODE "MESSAGE(\e"Sample install message.\e")")NINDENT NINDENT will print a message during installation.
install(EXPORT <export-name> DESTINATION <dir> [NAMESPACE <namespace>] [FILE <name>.cmake] [PERMISSIONS permissions...] [CONFIGURATIONS [Debug|Release|...]] [EXPORT_LINK_INTERFACE_LIBRARIES] [COMPONENT <component>])NINDENT NINDENT The EXPORT form generates and installs a CMake file containing code to import targets from the installation tree into another project. Target installations are associated with the export <export-name> using the EXPORT option of the install(TARGETS) signature documented above. The NAMESPACE option will prepend <namespace> to the target names as they are written to the import file. By default the generated file will be called <export-name>.cmake but the FILE option may be used to specify a different name. The value given to the FILE option must be a file name with the .cmake extension. If a CONFIGURATIONS option is given then the file will only be installed when one of the named configurations is installed. Additionally, the generated import file will reference only the matching target configurations. The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if present, causes the contents of the properties matching (IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)? to be exported, when policy CMP0022 is NEW. If a COMPONENT option is specified that does not match that given to the targets associated with <export-name> the behavior is undefined. If a library target is included in the export but a target to which it links is not included the behavior is unspecified. The EXPORT form is useful to help outside projects use targets built and installed by the current project. For example, the code NDENT 0.0 NDENT 3.5
install(TARGETS myexe EXPORT myproj DESTINATION bin) install(EXPORT myproj NAMESPACE mp_ DESTINATION lib/myproj)NINDENT NINDENT will install the executable myexe to <prefix>/bin and code to import it in the file <prefix>/lib/myproj/myproj.cmake. An outside project may load this file with the include command and reference the myexe executable from the installation tree using the imported target name mp_myexe as if the target were built in its own tree. NOTE: NDENT 0.0 NDENT 3.5 This command supercedes the install_targets() command and the PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT target properties. It also replaces the FILES forms of the install_files() and install_programs() commands. The processing order of these install rules relative to those generated by install_targets(), install_files(), and install_programs() commands is not defined. NINDENT NINDENT
link_directories(directory1 directory2 ...)NINDENT NINDENT Specify the paths in which the linker should search for libraries. The command will apply only to targets created after it is called. Relative paths given to this command are interpreted as relative to the current source directory, see CMP0015. Note that this command is rarely necessary. Library locations returned by find_package() and find_library() are absolute paths. Pass these absolute library file paths directly to the target_link_libraries() command. CMake will ensure the linker finds them.
link_libraries([item1 [item2 [...]]] [[debug|optimized|general] <item>] ...)NINDENT NINDENT Specify libraries or flags to use when linking any targets created later in the current directory or below by commands such as add_executable() or add_library(). See the target_link_libraries() command for meaning of arguments. NOTE: NDENT 0.0 NDENT 3.5 The target_link_libraries() command should be preferred whenever possible. Library dependencies are chained automatically, so directory-wide specification of link libraries is rarely needed. NINDENT NINDENT
list(LENGTH <list> <output variable>) list(GET <list> <element index> [<element index> ...] <output variable>) list(APPEND <list> [<element> ...]) list(FIND <list> <value> <output variable>) list(INSERT <list> <element_index> <element> [<element> ...]) list(REMOVE_ITEM <list> <value> [<value> ...]) list(REMOVE_AT <list> <index> [<index> ...]) list(REMOVE_DUPLICATES <list>) list(REVERSE <list>) list(SORT <list>)NINDENT NINDENT LENGTH will return a given list\(aqs length. GET will return list of elements specified by indices from the list. APPEND will append elements to the list. FIND will return the index of the element specified in the list or -1 if it wasn\(aqt found. INSERT will insert elements to the list to the specified location. REMOVE_AT and REMOVE_ITEM will remove items from the list. The difference is that REMOVE_ITEM will remove the given items, while REMOVE_AT will remove the items at the given indices. REMOVE_DUPLICATES will remove duplicated items in the list. REVERSE reverses the contents of the list in-place. SORT sorts the list in-place alphabetically. The list subcommands APPEND, INSERT, REMOVE_AT, REMOVE_ITEM, REMOVE_DUPLICATES, REVERSE and SORT may create new values for the list within the current CMake variable scope. Similar to the SET command, the LIST command creates new variable values in the current scope, even if the list itself is actually defined in a parent scope. To propagate the results of these operations upwards, use SET with PARENT_SCOPE, SET with CACHE INTERNAL, or some other means of value propagation. NOTES: A list in cmake is a ; separated group of strings. To create a list the set command can be used. For example, set(var a b c d e) creates a list with a;b;c;d;e, and set(var "a b c d e") creates a string or a list with one item in it. (Note macro arguments are not variables, and therefore cannot be used in LIST commands.) When specifying index values, if <element index> is 0 or greater, it is indexed from the beginning of the list, with 0 representing the first list element. If <element index> is -1 or lesser, it is indexed from the end of the list, with -1 representing the last list element. Be careful when counting with negative indices: they do not start from 0. -0 is equivalent to 0, the first list element.
load_cache(pathToCacheFile READ_WITH_PREFIX prefix entry1...)NINDENT NINDENT Read the cache and store the requested entries in variables with their name prefixed with the given prefix. This only reads the values, and does not create entries in the local project\(aqs cache. NDENT 0.0 NDENT 3.5
load_cache(pathToCacheFile [EXCLUDE entry1...] [INCLUDE_INTERNALS entry1...])NINDENT NINDENT Load in the values from another cache and store them in the local project\(aqs cache as internal entries. This is useful for a project that depends on another project built in a different tree. EXCLUDE option can be used to provide a list of entries to be excluded. INCLUDE_INTERNALS can be used to provide a list of internal entries to be included. Normally, no internal entries are brought in. Use of this form of the command is strongly discouraged, but it is provided for backward compatibility.
load_command(COMMAND_NAME <loc1> [loc2 ...])NINDENT NINDENT The given locations are searched for a library whose name is cmCOMMAND_NAME. If found, it is loaded as a module and the command is added to the set of available CMake commands. Usually, TRY_COMPILE is used before this command to compile the module. If the command is successfully loaded a variable named NDENT 0.0 NDENT 3.5
CMAKE_LOADED_COMMAND_<COMMAND_NAME>NINDENT NINDENT will be set to the full path of the module that was loaded. Otherwise the variable will not be set.
macro(<name> [arg1 [arg2 [arg3 ...]]]) COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... endmacro(<name>)NINDENT NINDENT Define a macro named <name> that takes arguments named arg1, arg2, arg3, (...). Commands listed after macro, but before the matching endmacro(), are not invoked until the macro is invoked. When it is invoked, the commands recorded in the macro are first modified by replacing formal parameters (${arg1}) with the arguments passed, and then invoked as normal commands. In addition to referencing the formal parameters you can reference the values ${ARGC} which will be set to the number of arguments passed into the function as well as ${ARGV0}, ${ARGV1}, ${ARGV2}, ... which will have the actual values of the arguments passed in. This facilitates creating macros with optional arguments. Additionally ${ARGV} holds the list of all arguments given to the macro and ${ARGN} holds the list of arguments past the last expected argument. Referencing to ${ARGV#} arguments beyond ${ARGC} have undefined behavior. Checking that ${ARGC} is greater than # is the only way to ensure that ${ARGV#} was passed to the function as an extra argument. See the cmake_policy() command documentation for the behavior of policies inside macros.
if(ARGV1) # ARGV1 is not a variable if(DEFINED ARGV2) # ARGV2 is not a variable if(ARGC GREATER 2) # ARGC is not a variable foreach(loop_var IN LISTS ARGN) # ARGN is not a variableNINDENT NINDENT In the first case, you can use if(${ARGV1}). In the second and third case, the proper way to check if an optional variable was passed to the macro is to use if(${ARGC} GREATER 2). In the last case, you can use foreach(loop_var ${ARGN}) but this will skip empty arguments. If you need to include them, you can use: NDENT 0.0 NDENT 3.5
set(list_var "${ARGN}") foreach(loop_var IN LISTS list_var)NINDENT NINDENT Note that if you have a variable with the same name in the scope from which the macro is called, using unreferenced names will use the existing variable instead of the arguments. For example: NDENT 0.0 NDENT 3.5
macro(_BAR) foreach(arg IN LISTS ARGN) [...] endforeach() endmacro() function(_FOO) _bar(x y z) endfunction() _foo(a b c)NINDENT NINDENT Will loop over a;b;c and not over x;y;z as one might be expecting. If you want true CMake variables and/or better CMake scope control you should look at the function command.
mark_as_advanced([CLEAR|FORCE] VAR [VAR2 ...])NINDENT NINDENT Mark the named cached variables as advanced. An advanced variable will not be displayed in any of the cmake GUIs unless the show advanced option is on. If CLEAR is the first argument advanced variables are changed back to unadvanced. If FORCE is the first argument, then the variable is made advanced. If neither FORCE nor CLEAR is specified, new values will be marked as advanced, but if the variable already has an advanced/non-advanced state, it will not be changed. It does nothing in script mode.
math(EXPR <output variable> <math expression>)NINDENT NINDENT EXPR evaluates mathematical expression and returns result in the output variable. Example mathematical expression is \(aq5 * ( 10 + 13 )\(aq. Supported operators are + - * / % | & ^ ~ << >> * / %. They have the same meaning as they do in C code.
message([<mode>] "message to display" ...)NINDENT NINDENT The optional <mode> keyword determines the type of message: NDENT 0.0 NDENT 3.5
(none) = Important information STATUS = Incidental information WARNING = CMake Warning, continue processing AUTHOR_WARNING = CMake Warning (dev), continue processing SEND_ERROR = CMake Error, continue processing, but skip generation FATAL_ERROR = CMake Error, stop processing and generation DEPRECATION = CMake Deprecation Error or Warning if variable CMAKE_ERROR_DEPRECATED or CMAKE_WARN_DEPRECATED is enabled, respectively, else no message.NINDENT NINDENT The CMake command-line tool displays STATUS messages on stdout and all other message types on stderr. The CMake GUI displays all messages in its log area. The interactive dialogs (ccmake and CMakeSetup) show STATUS messages one at a time on a status line and other messages in interactive pop-up boxes. CMake Warning and Error message text displays using a simple markup language. Non-indented text is formatted in line-wrapped paragraphs delimited by newlines. Indented text is considered pre-formatted.
option(<option_variable> "help string describing option" [initial value])NINDENT NINDENT Provide an option for the user to select as ON or OFF. If no initial value is provided, OFF is used. If you have options that depend on the values of other options, see the module help for CMakeDependentOption.
project(<PROJECT-NAME> [LANGUAGES] [<language-name>...]) project(<PROJECT-NAME> [VERSION <major>[.<minor>[.<patch>[.<tweak>]]]] [LANGUAGES <language-name>...])NINDENT NINDENT Sets the name of the project and stores the name in the PROJECT_NAME variable. Additionally this sets variables NDENT 0.0
qt_wrap_cpp(resultingLibraryName DestName SourceLists ...)NINDENT NINDENT Produce moc files for all the .h files listed in the SourceLists. The moc files will be added to the library using the DestName source list.
qt_wrap_ui(resultingLibraryName HeadersDestName SourcesDestName SourceLists ...)NINDENT NINDENT Produce .h and .cxx files for all the .ui files listed in the SourceLists. The .h files will be added to the library using the HeadersDestNamesource list. The .cxx files will be added to the library using the SourcesDestNamesource list.
remove_definitions(-DFOO -DBAR ...)NINDENT NINDENT Removes flags (added by add_definitions) from the compiler command line for sources in the current directory and below.
return()NINDENT NINDENT Returns from a file, directory or function. When this command is encountered in an included file (via include() or find_package()), it causes processing of the current file to stop and control is returned to the including file. If it is encountered in a file which is not included by another file, e.g. a CMakeLists.txt, control is returned to the parent directory if there is one. If return is called in a function, control is returned to the caller of the function. Note that a macro is not a function and does not handle return like a function does.
separate_arguments(<var> <UNIX|WINDOWS>_COMMAND "<args>")NINDENT NINDENT Parses a unix- or windows-style command-line string "<args>" and stores a semicolon-separated list of the arguments in <var>. The entire command line must be given in one "<args>" argument. The UNIX_COMMAND mode separates arguments by unquoted whitespace. It recognizes both single-quote and double-quote pairs. A backslash escapes the next literal character (" is "); there are no special escapes (n is just n). The WINDOWS_COMMAND mode parses a windows command-line using the same syntax the runtime library uses to construct argv at startup. It separates arguments by whitespace that is not double-quoted. Backslashes are literal unless they precede double-quotes. See the MSDN article "Parsing C Command-Line Arguments" for details. NDENT 0.0 NDENT 3.5
separate_arguments(VARIABLE)NINDENT NINDENT Convert the value of VARIABLE to a semi-colon separated list. All spaces are replaced with \(aq;\(aq. This helps with generating command lines.
set_directory_properties(PROPERTIES prop1 value1 prop2 value2)NINDENT NINDENT Set a property for the current directory and subdirectories. See Directory Properties for the list of properties known to CMake.
set_property(<GLOBAL | DIRECTORY [dir] | TARGET [target1 [target2 ...]] | SOURCE [src1 [src2 ...]] | INSTALL [file1 [file2 ...]] | TEST [test1 [test2 ...]] | CACHE [entry1 [entry2 ...]]> [APPEND] [APPEND_STRING] PROPERTY <name> [value1 [value2 ...]])NINDENT NINDENT Set one property on zero or more objects of a scope. The first argument determines the scope in which the property is set. It must be one of the following: NDENT 0.0
GLOBAL Scope is unique and does not accept a name.
DIRECTORY Scope defaults to the current directory but another directory (already processed by CMake) may be named by full or relative path.
TARGET Scope may name zero or more existing targets.
SOURCE Scope may name zero or more source files. Note that source file properties are visible only to targets added in the same directory (CMakeLists.txt).
INSTALL Scope may name zero or more installed file paths. These are made available to CPack to influence deployment. Both the property key and value may use generator expressions. Specific properties may apply to installed files and/or directories. Path components have to be separated by forward slashes, must be normalized and are case sensitive. To reference the installation prefix itself with a relative path use ".". Currently installed file properties are only defined for the WIX generator where the given paths are relative to the installation prefix.
TEST Scope may name zero or more existing tests.
CACHE Scope must name zero or more cache existing entries. NINDENT The required PROPERTY option is immediately followed by the name of the property to set. Remaining arguments are used to compose the property value in the form of a semicolon-separated list. If the APPEND option is given the list is appended to any existing property value. If the APPEND_STRING option is given the string is append to any existing property value as string, i.e. it results in a longer string and not a list of strings.
set(<variable> <value>... [PARENT_SCOPE])NINDENT NINDENT Set the given <variable> in the current function or directory scope. If the PARENT_SCOPE option is given the variable will be set in the scope above the current scope. Each new directory or function creates a new scope. This command will set the value of a variable into the parent directory or calling function (whichever is applicable to the case at hand).
set(<variable> <value>... CACHE <type> <docstring> [FORCE])NINDENT NINDENT Set the given cache <variable> (cache entry). Since cache entries are meant to provide user-settable values this does not overwrite existing cache entries by default. Use the FORCE option to overwrite existing entries. The <type> must be specified as one of: NDENT 0.0
BOOL Boolean ON/OFF value. cmake-gui(1) offers a checkbox.
FILEPATH Path to a file on disk. cmake-gui(1) offers a file dialog.
PATH Path to a directory on disk. cmake-gui(1) offers a file dialog.
STRING A line of text. cmake-gui(1) offers a text field or a drop-down selection if the STRINGS cache entry property is set.
INTERNAL A line of text. cmake-gui(1) does not show internal entries. They may be used to store variables persistently across runs. Use of this type implies FORCE. NINDENT The <docstring> must be specified as a line of text providing a quick summary of the option for presentation to cmake-gui(1) users. If the cache entry does not exist prior to the call or the FORCE option is given then the cache entry will be set to the given value. Furthermore, any normal variable binding in the current scope will be removed to expose the newly cached value to any immediately following evaluation. It is possible for the cache entry to exist prior to the call but have no type set if it was created on the cmake(1) command line by a user through the -D<var>=<value> option without specifying a type. In this case the set command will add the type. Furthermore, if the <type> is PATH or FILEPATH and the <value> provided on the command line is a relative path, then the set command will treat the path as relative to the current working directory and convert it to an absolute path.
set(ENV{<variable>} <value>...)NINDENT NINDENT Set the current process environment <variable> to the given value.
set_source_files_properties([file1 [file2 [...]]] PROPERTIES prop1 value1 [prop2 value2 [...]])NINDENT NINDENT Set properties associated with source files using a key/value paired list. See Source File Properties for the list of properties known to CMake. Source file properties are visible only to targets added in the same directory (CMakeLists.txt).
set_target_properties(target1 target2 ... PROPERTIES prop1 value1 prop2 value2 ...)NINDENT NINDENT Set properties on a target. The syntax for the command is to list all the files you want to change, and then provide the values you want to set next. You can use any prop value pair you want and extract it later with the GET_TARGET_PROPERTY command. Properties that affect the name of a target\(aqs output file are as follows. The PREFIX and SUFFIX properties override the default target name prefix (such as "lib") and suffix (such as ".so"). IMPORT_PREFIX and IMPORT_SUFFIX are the equivalent properties for the import library corresponding to a DLL (for SHARED library targets). OUTPUT_NAME sets the real name of a target when it is built and can be used to help create two targets of the same name even though CMake requires unique logical target names. There is also a <CONFIG>_OUTPUT_NAME that can set the output name on a per-configuration basis. <CONFIG>_POSTFIX sets a postfix for the real name of the target when it is built under the configuration named by <CONFIG> (in upper-case, such as "DEBUG_POSTFIX"). The value of this property is initialized when the target is created to the value of the variable CMAKE_<CONFIG>_POSTFIX (except for executable targets because earlier CMake versions which did not use this variable for executables). The LINK_FLAGS property can be used to add extra flags to the link step of a target. LINK_FLAGS_<CONFIG> will add to the configuration <CONFIG>, for example, DEBUG, RELEASE, MINSIZEREL, RELWITHDEBINFO. DEFINE_SYMBOL sets the name of the preprocessor symbol defined when compiling sources in a shared library. If not set here then it is set to target_EXPORTS by default (with some substitutions if the target is not a valid C identifier). This is useful for headers to know whether they are being included from inside their library or outside to properly setup dllexport/dllimport decorations. The COMPILE_FLAGS property sets additional compiler flags used to build sources within the target. It may also be used to pass additional preprocessor definitions. The LINKER_LANGUAGE property is used to change the tool used to link an executable or shared library. The default is set the language to match the files in the library. CXX and C are common values for this property. For shared libraries VERSION and SOVERSION can be used to specify the build version and API version respectively. When building or installing appropriate symlinks are created if the platform supports symlinks and the linker supports so-names. If only one of both is specified the missing is assumed to have the same version number. For executables VERSION can be used to specify the build version. When building or installing appropriate symlinks are created if the platform supports symlinks. For shared libraries and executables on Windows the VERSION attribute is parsed to extract a "major.minor" version number. These numbers are used as the image version of the binary. There are a few properties used to specify RPATH rules. INSTALL_RPATH is a semicolon-separated list specifying the rpath to use in installed targets (for platforms that support it). INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to true will append directories in the linker search path and outside the project to the INSTALL_RPATH. SKIP_BUILD_RPATH is a boolean specifying whether to skip automatic generation of an rpath allowing the target to run from the build tree. BUILD_WITH_INSTALL_RPATH is a boolean specifying whether to link the target in the build tree with the INSTALL_RPATH. This takes precedence over SKIP_BUILD_RPATH and avoids the need for relinking before installation. INSTALL_NAME_DIR is a string specifying the directory portion of the "install_name" field of shared libraries on Mac OSX to use in the installed targets. When the target is created the values of the variables CMAKE_INSTALL_RPATH, CMAKE_INSTALL_RPATH_USE_LINK_PATH, CMAKE_SKIP_BUILD_RPATH, CMAKE_BUILD_WITH_INSTALL_RPATH, and CMAKE_INSTALL_NAME_DIR are used to initialize these properties. PROJECT_LABEL can be used to change the name of the target in an IDE like visual studio. VS_KEYWORD can be set to change the visual studio keyword, for example Qt integration works better if this is set to Qt4VSv1.0. VS_SCC_PROJECTNAME, VS_SCC_LOCALPATH, VS_SCC_PROVIDER and VS_SCC_AUXPATH can be set to add support for source control bindings in a Visual Studio project file. VS_GLOBAL_<variable> can be set to add a Visual Studio project-specific global variable. Qt integration works better if VS_GLOBAL_QtVersion is set to the Qt version FindQt4.cmake found. For example, "4.7.3" The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the old way to specify CMake scripts to run before and after installing a target. They are used only when the old INSTALL_TARGETS command is used to install the target. Use the INSTALL command instead. The EXCLUDE_FROM_DEFAULT_BUILD property is used by the visual studio generators. If it is set to 1 the target will not be part of the default build when you select "Build Solution". This can also be set on a per-configuration basis using EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>.
set_tests_properties(test1 [test2...] PROPERTIES prop1 value1 prop2 value2)NINDENT NINDENT Set a property for the tests. If the test is not found, CMake will report an error. Generator expressions will be expanded the same as supported by the test\(aqs add_test() call. See Test Properties for the list of properties known to CMake.
site_name(variable)NINDENT NINDENT
source_group(<name> [FILES <src>...] [REGULAR_EXPRESSION <regex>])NINDENT NINDENT Defines a group into which sources will be placed in project files. This is intended to set up file tabs in Visual Studio. The options are: NDENT 0.0
FILES Any source file specified explicitly will be placed in group <name>. Relative paths are interpreted with respect to the current source directory.
REGULAR_EXPRESSION Any source file whose name matches the regular expression will be placed in group <name>. NINDENT If a source file matches multiple groups, the last group that explicitly lists the file with FILES will be favored, if any. If no group explicitly lists the file, the last group whose regular expression matches the file will be favored. The <name> of the group may contain backslashes to specify subgroups: NDENT 0.0 NDENT 3.5
source_group(outer\e\einner ...)NINDENT NINDENT For backwards compatibility, the short-hand signature NDENT 0.0 NDENT 3.5
source_group(<name> <regex>)NINDENT NINDENT is equivalent to NDENT 0.0 NDENT 3.5
source_group(<name> REGULAR_EXPRESSION <regex>)NINDENT NINDENT
string(REGEX MATCH <regular_expression> <output variable> <input> [<input>...]) string(REGEX MATCHALL <regular_expression> <output variable> <input> [<input>...]) string(REGEX REPLACE <regular_expression> <replace_expression> <output variable> <input> [<input>...]) string(REPLACE <match_string> <replace_string> <output variable> <input> [<input>...]) string(CONCAT <output variable> [<input>...]) string(<MD5|SHA1|SHA224|SHA256|SHA384|SHA512> <output variable> <input>) string(COMPARE EQUAL <string1> <string2> <output variable>) string(COMPARE NOTEQUAL <string1> <string2> <output variable>) string(COMPARE LESS <string1> <string2> <output variable>) string(COMPARE GREATER <string1> <string2> <output variable>) string(ASCII <number> [<number> ...] <output variable>) string(CONFIGURE <string1> <output variable> [@ONLY] [ESCAPE_QUOTES]) string(TOUPPER <string1> <output variable>) string(TOLOWER <string1> <output variable>) string(LENGTH <string> <output variable>) string(SUBSTRING <string> <begin> <length> <output variable>) string(STRIP <string> <output variable>) string(RANDOM [LENGTH <length>] [ALPHABET <alphabet>] [RANDOM_SEED <seed>] <output variable>) string(FIND <string> <substring> <output variable> [REVERSE]) string(TIMESTAMP <output variable> [<format string>] [UTC]) string(MAKE_C_IDENTIFIER <input string> <output variable>) string(GENEX_STRIP <input string> <output variable>) string(UUID <output variable> NAMESPACE <namespace> NAME <name> TYPE <MD5|SHA1> [UPPER])NINDENT NINDENT REGEX MATCH will match the regular expression once and store the match in the output variable. REGEX MATCHALL will match the regular expression as many times as possible and store the matches in the output variable as a list. REGEX REPLACE will match the regular expression as many times as possible and substitute the replacement expression for the match in the output. The replace expression may refer to paren-delimited subexpressions of the match using 1, 2, ..., 9. Note that two backslashes (\e1) are required in CMake code to get a backslash through argument parsing. REPLACE will replace all occurrences of match_string in the input with replace_string and store the result in the output. CONCAT will concatenate all the input arguments together and store the result in the named output variable. MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 will compute a cryptographic hash of the input string. COMPARE EQUAL/NOTEQUAL/LESS/GREATER will compare the strings and store true or false in the output variable. ASCII will convert all numbers into corresponding ASCII characters. CONFIGURE will transform a string like CONFIGURE_FILE transforms a file. TOUPPER/TOLOWER will convert string to upper/lower characters. LENGTH will return a given string\(aqs length. SUBSTRING will return a substring of a given string. If length is -1 the remainder of the string starting at begin will be returned. If string is shorter than length then end of string is used instead. NOTE: NDENT 0.0 NDENT 3.5 CMake 3.1 and below reported an error if length pointed past the end of string. NINDENT NINDENT STRIP will return a substring of a given string with leading and trailing spaces removed. RANDOM will return a random string of given length consisting of characters from the given alphabet. Default length is 5 characters and default alphabet is all numbers and upper and lower case letters. If an integer RANDOM_SEED is given, its value will be used to seed the random number generator. FIND will return the position where the given substring was found in the supplied string. If the REVERSE flag was used, the command will search for the position of the last occurrence of the specified substring. The following characters have special meaning in regular expressions: NDENT 0.0 NDENT 3.5
^ Matches at beginning of input $ Matches at end of input . Matches any single character [ ] Matches any character(s) inside the brackets [^ ] Matches any character(s) not inside the brackets - Inside brackets, specifies an inclusive range between characters on either side e.g. [a-f] is [abcdef] To match a literal - using brackets, make it the first or the last character e.g. [+*/-] matches basic mathematical operators. * Matches preceding pattern zero or more times + Matches preceding pattern one or more times ? Matches preceding pattern zero or once only | Matches a pattern on either side of the | () Saves a matched subexpression, which can be referenced in the REGEX REPLACE operation. Additionally it is saved by all regular expression-related commands, including e.g. if( MATCHES ), in the variables CMAKE_MATCH_(0..9).NINDENT NINDENT *, + and ? have higher precedence than concatenation. | has lower precedence than concatenation. This means that the regular expression "^ab+d$" matches "abbd" but not "ababd", and the regular expression "^(ab|cd)$" matches "ab" but not "abd". TIMESTAMP will write a string representation of the current date and/or time to the output variable. Should the command be unable to obtain a timestamp the output variable will be set to the empty string "". The optional UTC flag requests the current date/time representation to be in Coordinated Universal Time (UTC) rather than local time. The optional <format string> may contain the following format specifiers: NDENT 0.0 NDENT 3.5
%d The day of the current month (01-31). %H The hour on a 24-hour clock (00-23). %I The hour on a 12-hour clock (01-12). %j The day of the current year (001-366). %m The month of the current year (01-12). %M The minute of the current hour (00-59). %S The second of the current minute. 60 represents a leap second. (00-60) %U The week number of the current year (00-53). %w The day of the current week. 0 is Sunday. (0-6) %y The last two digits of the current year (00-99) %Y The current year.NINDENT NINDENT Unknown format specifiers will be ignored and copied to the output as-is. If no explicit <format string> is given it will default to: NDENT 0.0 NDENT 3.5
%Y-%m-%dT%H:%M:%S for local time. %Y-%m-%dT%H:%M:%SZ for UTC.NINDENT NINDENT MAKE_C_IDENTIFIER will write a string which can be used as an identifier in C. GENEX_STRIP will strip any generator expressions from the input string and store the result in the output variable. UUID creates a univerally unique identifier (aka GUID) as per RFC4122 based on the hash of the combined values of <namespace> (which itself has to be a valid UUID) and <name>. The hash algorithm can be either MD5 (Version 3 UUID) or SHA1 (Version 5 UUID). A UUID has the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx where each x represents a lower case hexadecimal character. Where required an uppercase representation can be requested with the optional UPPER flag.
target_compile_definitions(<target> <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])NINDENT NINDENT Specify compile definitions to use when compiling a given <target>. The named <target> must have been created by a command such as add_executable() or add_library() and must not be an Imported Target. The INTERFACE, PUBLIC and PRIVATE keywords are required to specify the scope of the following arguments. PRIVATE and PUBLIC items will populate the COMPILE_DEFINITIONS property of <target>. PUBLIC and INTERFACE items will populate the INTERFACE_COMPILE_DEFINITIONS property of <target>. The following arguments specify compile definitions. Repeated calls for the same <target> append items in the order called. Arguments to target_compile_definitions may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions. See the cmake-buildsystem(7) manual for more on defining buildsystem properties.
target_compile_features(<target> <PRIVATE|PUBLIC|INTERFACE> <feature> [...])NINDENT NINDENT Specify compiler features required when compiling a given target. If the feature is not listed in the CMAKE_C_COMPILE_FEATURES variable or CMAKE_CXX_COMPILE_FEATURES variable, then an error will be reported by CMake. If the use of the feature requires an additional compiler flag, such as -std=gnu++11, the flag will be added automatically. The INTERFACE, PUBLIC and PRIVATE keywords are required to specify the scope of the features. PRIVATE and PUBLIC items will populate the COMPILE_FEATURES property of <target>. PUBLIC and INTERFACE items will populate the INTERFACE_COMPILE_FEATURES property of <target>. Repeated calls for the same <target> append items. The named <target> must have been created by a command such as add_executable() or add_library() and must not be an IMPORTED target. Arguments to target_compile_features may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions. See the cmake-compile-features(7) manual for information on compile features and a list of supported compilers.
target_compile_options(<target> [BEFORE] <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])NINDENT NINDENT Specify compile options to use when compiling a given target. The named <target> must have been created by a command such as add_executable() or add_library() and must not be an IMPORTED Target. If BEFORE is specified, the content will be prepended to the property instead of being appended. This command can be used to add any options, but alternative commands exist to add preprocessor definitions (target_compile_definitions() and add_definitions()) or include directories (target_include_directories() and include_directories()). See documentation of the directory and target COMPILE_OPTIONS properties. The INTERFACE, PUBLIC and PRIVATE keywords are required to specify the scope of the following arguments. PRIVATE and PUBLIC items will populate the COMPILE_OPTIONS property of <target>. PUBLIC and INTERFACE items will populate the INTERFACE_COMPILE_OPTIONS property of <target>. The following arguments specify compile options. Repeated calls for the same <target> append items in the order called. Arguments to target_compile_options may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions. See the cmake-buildsystem(7) manual for more on defining buildsystem properties.
target_include_directories(<target> [SYSTEM] [BEFORE] <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])NINDENT NINDENT Specify include directories to use when compiling a given target. The named <target> must have been created by a command such as add_executable() or add_library() and must not be an IMPORTED target. If BEFORE is specified, the content will be prepended to the property instead of being appended. The INTERFACE, PUBLIC and PRIVATE keywords are required to specify the scope of the following arguments. PRIVATE and PUBLIC items will populate the INCLUDE_DIRECTORIES property of <target>. PUBLIC and INTERFACE items will populate the INTERFACE_INCLUDE_DIRECTORIES property of <target>. The following arguments specify include directories. Specified include directories may be absolute paths or relative paths. Repeated calls for the same <target> append items in the order called. If SYSTEM is specified, the compiler will be told the directories are meant as system include directories on some platforms (signalling this setting might achieve effects such as the compiler skipping warnings, or these fixed-install system files not being considered in dependency calculations - see compiler docs). If SYSTEM is used together with PUBLIC or INTERFACE, the INTERFACE_SYSTEM_INCLUDE_DIRECTORIES target property will be populated with the specified directories. Arguments to target_include_directories may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions. See the cmake-buildsystem(7) manual for more on defining buildsystem properties. Include directories usage requirements commonly differ between the build-tree and the install-tree. The BUILD_INTERFACE and INSTALL_INTERFACE generator expressions can be used to describe separate usage requirements based on the usage location. Relative paths are allowed within the INSTALL_INTERFACE expression and are interpreted relative to the installation prefix. For example: NDENT 0.0 NDENT 3.5
target_include_directories(mylib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/mylib> $<INSTALL_INTERFACE:include/mylib> # <prefix>/include/mylib )NINDENT NINDENT
target_link_libraries(<target> ... <item>... ...)NINDENT NINDENT The named <target> must have been created in the current directory by a command such as add_executable() or add_library(). Repeated calls for the same <target> append items in the order called. Each <item> may be: NDENT 0.0
target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> <item>... [<PRIVATE|PUBLIC|INTERFACE> <item>...]...)NINDENT NINDENT The PUBLIC, PRIVATE and INTERFACE keywords can be used to specify both the link dependencies and the link interface in one command. Libraries and targets following PUBLIC are linked to, and are made part of the link interface. Libraries and targets following PRIVATE are linked to, but are not made part of the link interface. Libraries following INTERFACE are appended to the link interface and are not used for linking <target>.
target_link_libraries(<target> <item>...)NINDENT NINDENT Library dependencies are transitive by default with this signature. When this target is linked into another target then the libraries linked to this target will appear on the link line for the other target too. This transitive "link interface" is stored in the INTERFACE_LINK_LIBRARIES target property and may be overridden by setting the property directly. When CMP0022 is not set to NEW, transitive linking is built in but may be overridden by the LINK_INTERFACE_LIBRARIES property. Calls to other signatures of this command may set the property making any libraries linked exclusively by this signature private. NDENT 0.0 NDENT 3.5
target_link_libraries(<target> <LINK_PRIVATE|LINK_PUBLIC> <lib>... [<LINK_PRIVATE|LINK_PUBLIC> <lib>...]...)NINDENT NINDENT The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify both the link dependencies and the link interface in one command. This signature is for compatibility only. Prefer the PUBLIC or PRIVATE keywords instead. Libraries and targets following LINK_PUBLIC are linked to, and are made part of the INTERFACE_LINK_LIBRARIES. If policy CMP0022 is not NEW, they are also made part of the LINK_INTERFACE_LIBRARIES. Libraries and targets following LINK_PRIVATE are linked to, but are not made part of the INTERFACE_LINK_LIBRARIES (or LINK_INTERFACE_LIBRARIES).
target_link_libraries(<target> LINK_INTERFACE_LIBRARIES <item>...)NINDENT NINDENT The LINK_INTERFACE_LIBRARIES mode appends the libraries to the INTERFACE_LINK_LIBRARIES target property instead of using them for linking. If policy CMP0022 is not NEW, then this mode also appends libraries to the LINK_INTERFACE_LIBRARIES and its per-configuration equivalent. This signature is for compatibility only. Prefer the INTERFACE mode instead. Libraries specified as debug are wrapped in a generator expression to correspond to debug builds. If policy CMP0022 is not NEW, the libraries are also appended to the LINK_INTERFACE_LIBRARIES_DEBUG property (or to the properties corresponding to configurations listed in the DEBUG_CONFIGURATIONS global property if it is set). Libraries specified as optimized are appended to the INTERFACE_LINK_LIBRARIES property. If policy CMP0022 is not NEW, they are also appended to the LINK_INTERFACE_LIBRARIES property. Libraries specified as general (or without any keyword) are treated as if specified for both debug and optimized.
add_library(A STATIC a.c) add_library(B STATIC b.c) target_link_libraries(A B) target_link_libraries(B A) add_executable(main main.c) target_link_libraries(main A)NINDENT NINDENT links main to A B A B. While one repetition is usually sufficient, pathological object file and symbol arrangements can require more. One may handle such cases by using the LINK_INTERFACE_MULTIPLICITY target property or by manually repeating the component in the last target_link_libraries call. However, if two archives are really so interdependent they should probably be combined into a single archive, perhaps by using Object Libraries.
target_sources(<target> <INTERFACE|PUBLIC|PRIVATE> [items1...] [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])NINDENT NINDENT Specify sources to use when compiling a given target. The named <target> must have been created by a command such as add_executable() or add_library() and must not be an IMPORTED Target. The INTERFACE, PUBLIC and PRIVATE keywords are required to specify the scope of the following arguments. PRIVATE and PUBLIC items will populate the SOURCES property of <target>. PUBLIC and INTERFACE items will populate the INTERFACE_SOURCES property of <target>. The following arguments specify sources. Repeated calls for the same <target> append items in the order called. Arguments to target_sources may use "generator expressions" with the syntax $<...>. See the cmake-generator-expressions(7) manual for available expressions. See the cmake-buildsystem(7) manual for more on defining buildsystem properties.
try_compile(RESULT_VAR <bindir> <srcdir> <projectName> [<targetName>] [CMAKE_FLAGS <flags>...] [OUTPUT_VARIABLE <var>])NINDENT NINDENT Try building a project. The success or failure of the try_compile, i.e. TRUE or FALSE respectively, is returned in RESULT_VAR. In this form, <srcdir> should contain a complete CMake project with a CMakeLists.txt file and all sources. The <bindir> and <srcdir> will not be deleted after this command is run. Specify <targetName> to build a specific target instead of the all or ALL_BUILD target. See below for the meaning of other options.
try_compile(RESULT_VAR <bindir> <srcfile|SOURCES srcfile...> [CMAKE_FLAGS <flags>...] [COMPILE_DEFINITIONS <defs>...] [LINK_LIBRARIES <libs>...] [OUTPUT_VARIABLE <var>] [COPY_FILE <fileName> [COPY_FILE_ERROR <var>]])NINDENT NINDENT Try building an executable from one or more source files. The success or failure of the try_compile, i.e. TRUE or FALSE respectively, is returned in RESULT_VAR. In this form the user need only supply one or more source files that include a definition for main. CMake will create a CMakeLists.txt file to build the source(s) as an executable that looks something like this: NDENT 0.0 NDENT 3.5
add_definitions(<expanded COMPILE_DEFINITIONS from caller>) include_directories(${INCLUDE_DIRECTORIES}) link_directories(${LINK_DIRECTORIES}) add_executable(cmTryCompileExec <srcfile>...) target_link_libraries(cmTryCompileExec ${LINK_LIBRARIES})NINDENT NINDENT The options are: NDENT 0.0
CMAKE_FLAGS <flags>... Specify flags of the form -DVAR:TYPE=VALUE to be passed to the cmake command-line used to drive the test build. The above example shows how values for variables INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and LINK_LIBRARIES are used.
COMPILE_DEFINITIONS <defs>... Specify -Ddefinition arguments to pass to add_definitions in the generated test project.
COPY_FILE <fileName> Copy the linked executable to the given <fileName>.
COPY_FILE_ERROR <var> Use after COPY_FILE to capture into variable <var> any error message encountered while trying to copy the file.
LINK_LIBRARIES <libs>... Specify libraries to be linked in the generated project. The list of libraries may refer to system libraries and to Imported Targets from the calling project. If this option is specified, any -DLINK_LIBRARIES=... value given to the CMAKE_FLAGS option will be ignored.
OUTPUT_VARIABLE <var> Store the output from the build process the given variable. NINDENT In this version all files in <bindir>/CMakeFiles/CMakeTmp will be cleaned automatically. For debugging, --debug-trycompile can be passed to cmake to avoid this clean. However, multiple sequential try_compile operations reuse this single output directory. If you use --debug-trycompile, you can only debug one try_compile call at a time. The recommended procedure is to protect all try_compile calls in your project by if(NOT DEFINED RESULT_VAR) logic, configure with cmake all the way through once, then delete the cache entry associated with the try_compile call of interest, and then re-run cmake again with --debug-trycompile.
try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR bindir srcfile [CMAKE_FLAGS <flags>...] [COMPILE_DEFINITIONS <defs>...] [LINK_LIBRARIES <libs>...] [COMPILE_OUTPUT_VARIABLE <var>] [RUN_OUTPUT_VARIABLE <var>] [OUTPUT_VARIABLE <var>] [ARGS <args>...])NINDENT NINDENT Try compiling a <srcfile>. Returns TRUE or FALSE for success or failure in COMPILE_RESULT_VAR. If the compile succeeded, runs the executable and returns its exit code in RUN_RESULT_VAR. If the executable was built, but failed to run, then RUN_RESULT_VAR will be set to FAILED_TO_RUN. See the try_compile() command for information on how the test project is constructed to build the source file. The options are: NDENT 0.0
CMAKE_FLAGS <flags>... Specify flags of the form -DVAR:TYPE=VALUE to be passed to the cmake command-line used to drive the test build. The example in try_compile() shows how values for variables INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and LINK_LIBRARIES are used.
COMPILE_DEFINITIONS <defs>... Specify -Ddefinition arguments to pass to add_definitions in the generated test project.
COMPILE_OUTPUT_VARIABLE <var> Report the compile step build output in a given variable.
LINK_LIBRARIES <libs>... Specify libraries to be linked in the generated project. The list of libraries may refer to system libraries and to Imported Targets from the calling project. If this option is specified, any -DLINK_LIBRARIES=... value given to the CMAKE_FLAGS option will be ignored.
OUTPUT_VARIABLE <var> Report the compile build output and the output from running the executable in the given variable. This option exists for legacy reasons. Prefer COMPILE_OUTPUT_VARIABLE and RUN_OUTPUT_VARIABLE instead.
RUN_OUTPUT_VARIABLE <var> Report the output from running the executable in a given variable. NINDENT
<RUN_RESULT_VAR> Exit code if the executable were to be run on the target platform.
<RUN_RESULT_VAR>__TRYRUN_OUTPUT Output from stdout and stderr if the executable were to be run on the target platform. This is created only if the RUN_OUTPUT_VARIABLE or OUTPUT_VARIABLE option was used. NINDENT In order to make cross compiling your project easier, use try_run only if really required. If you use try_run, use the RUN_OUTPUT_VARIABLE or OUTPUT_VARIABLE options only if really required. Using them will require that when cross-compiling, the cache variables will have to be set manually to the output of the executable. You can also "guard" the calls to try_run with an if() block checking the CMAKE_CROSSCOMPILING variable and provide an easy-to-preset alternative for this case.
unset(<variable> [CACHE | PARENT_SCOPE])NINDENT NINDENT Removes the specified variable causing it to become undefined. If CACHE is present then the variable is removed from the cache instead of the current scope. If PARENT_SCOPE is present then the variable is removed from the scope above the current scope. See the same option in the set() command for further details. <variable> can be an environment variable such as: NDENT 0.0 NDENT 3.5
unset(ENV{LD_LIBRARY_PATH})NINDENT NINDENT in which case the variable will be removed from the current environment.
variable_watch(<variable name> [<command to execute>])NINDENT NINDENT If the specified variable changes, the message will be printed about the variable being changed. If the command is specified, the command will be executed. The command will receive the following arguments: COMMAND(<variable> <access> <value> <current list file> <stack>)
while(condition) COMMAND1(ARGS ...) COMMAND2(ARGS ...) ... endwhile(condition)NINDENT NINDENT All commands between while and the matching endwhile are recorded without being invoked. Once the endwhile is evaluated, the recorded list of commands is invoked as long as the condition is true. The condition is evaluated using the same logic as the if command.
build_name(variable)NINDENT NINDENT Sets the specified variable to a string representing the platform and compiler settings. These values are now available through the CMAKE_SYSTEM and CMAKE_CXX_COMPILER variables.
exec_program(Executable [directory in which to run] [ARGS <arguments to executable>] [OUTPUT_VARIABLE <var>] [RETURN_VALUE <var>])NINDENT NINDENT The executable is run in the optionally specified directory. The executable can include arguments if it is double quoted, but it is better to use the optional ARGS argument to specify arguments to the program. This is because cmake will then be able to escape spaces in the executable path. An optional argument OUTPUT_VARIABLE specifies a variable in which to store the output. To capture the return value of the execution, provide a RETURN_VALUE. If OUTPUT_VARIABLE is specified, then no output will go to the stdout/stderr of the console running cmake.
export_library_dependencies(<file> [APPEND])NINDENT NINDENT Create a file named <file> that can be included into a CMake listfile with the INCLUDE command. The file will contain a number of SET commands that will set all the variables needed for library dependency information. This should be the last command in the top level CMakeLists.txt file of the project. If the APPEND option is specified, the SET commands will be appended to the given file instead of replacing it.
install_files(<dir> extension file file ...)NINDENT NINDENT Create rules to install the listed files with the given extension into the given directory. Only files existing in the current source tree or its corresponding location in the binary tree may be listed. If a file specified already has an extension, that extension will be removed first. This is useful for providing lists of source files such as foo.cxx when you want the corresponding foo.h to be installed. A typical extension is \(aq.h\(aq. NDENT 0.0 NDENT 3.5
install_files(<dir> regexp)NINDENT NINDENT Any files in the current source directory that match the regular expression will be installed. NDENT 0.0 NDENT 3.5
install_files(<dir> FILES file file ...)NINDENT NINDENT Any files listed after the FILES keyword will be installed explicitly from the names given. Full paths are allowed in this form. The directory <dir> is relative to the installation prefix, which is stored in the variable CMAKE_INSTALL_PREFIX.
install_programs(<dir> file1 file2 [file3 ...]) install_programs(<dir> FILES file1 [file2 ...])NINDENT NINDENT Create rules to install the listed programs into the given directory. Use the FILES argument to guarantee that the file list version of the command will be used even when there is only one argument. NDENT 0.0 NDENT 3.5
install_programs(<dir> regexp)NINDENT NINDENT In the second form any program in the current source directory that matches the regular expression will be installed. This command is intended to install programs that are not built by cmake, such as shell scripts. See the TARGETS form of the INSTALL command to create installation rules for targets built by cmake. The directory <dir> is relative to the installation prefix, which is stored in the variable CMAKE_INSTALL_PREFIX.
install_targets(<dir> [RUNTIME_DIRECTORY dir] target target)NINDENT NINDENT Create rules to install the listed targets into the given directory. The directory <dir> is relative to the installation prefix, which is stored in the variable CMAKE_INSTALL_PREFIX. If RUNTIME_DIRECTORY is specified, then on systems with special runtime files (Windows DLL), the files will be copied to that directory.
make_directory(directory)NINDENT NINDENT Creates the specified directory. Full paths should be given. Any parent directories that do not exist will also be created. Use with care.
output_required_files(srcfile outputfile)NINDENT NINDENT Outputs a list of all the source files that are required by the specified srcfile. This list is written into outputfile. This is similar to writing out the dependencies for srcfile except that it jumps from .h files into .cxx, .c and .cpp files if possible.
remove(VAR VALUE VALUE ...)NINDENT NINDENT Removes VALUE from the variable VAR. This is typically used to remove entries from a vector (e.g. semicolon separated list). VALUE is expanded.
subdir_depends(subdir dep1 dep2 ...)NINDENT NINDENT Does not do anything. This command used to help projects order parallel builds correctly. This functionality is now automatic.
subdirs(dir1 dir2 ...[EXCLUDE_FROM_ALL exclude_dir1 exclude_dir2 ...] [PREORDER] )NINDENT NINDENT Add a list of subdirectories to the build. The add_subdirectory command should be used instead of subdirs although subdirs will still work. This will cause any CMakeLists.txt files in the sub directories to be processed by CMake. Any directories after the PREORDER flag are traversed first by makefile builds, the PREORDER flag has no effect on IDE projects. Any directories after the EXCLUDE_FROM_ALL marker will not be included in the top level makefile or project file. This is useful for having CMake create makefiles or projects for a set of examples in a project. You would want CMake to generate makefiles or project files for all the examples at the same time, but you would not want them to show up in the top level project or be built each time make is run from the top.
use_mangled_mesa(PATH_TO_MESA OUTPUT_DIRECTORY)NINDENT NINDENT The path to mesa includes, should contain gl_mangle.h. The mesa headers are copied to the specified output directory. This allows mangled mesa headers to override other GL headers by being added to the include directory path earlier.
utility_source(cache_entry executable_name path_to_source [file1 file2 ...])NINDENT NINDENT When a third-party utility\(aqs source is included in the distribution, this command specifies its location and name. The cache entry will not be set unless the path_to_source and all listed files exist. It is assumed that the source tree of the utility will have been built before it is needed. When cross compiling CMake will print a warning if a utility_source() command is executed, because in many cases it is used to build an executable which is executed later on. This doesn\(aqt work when cross compiling, since the executable can run only on their target platform. So in this case the cache entry has to be adjusted manually so it points to an executable which is runnable on the build host.
variable_requires(TEST_VARIABLE RESULT_VARIABLE REQUIRED_VARIABLE1 REQUIRED_VARIABLE2 ...)NINDENT NINDENT The first argument (TEST_VARIABLE) is the name of the variable to be tested, if that variable is false nothing else is done. If TEST_VARIABLE is true, then the next argument (RESULT_VARIABLE) is a variable that is set to true if all the required variables are set. The rest of the arguments are variables that must be true or not set to NOTFOUND to avoid an error. If any are not true, an error is reported.
write_file(filename "message to write"... [APPEND])NINDENT NINDENT The first argument is the file name, the rest of the arguments are messages to write. If the argument APPEND is specified, then the message will be appended. NOTE 1: file(WRITE ... and file(APPEND ... do exactly the same as this one but add some more functionality. NOTE 2: When using write_file the produced file cannot be used as an input to CMake (CONFIGURE_FILE, source file ...) because it will lead to an infinite loop. Use configure_file if you want to generate input files to CMake.
ctest_build([BUILD <build-dir>] [APPEND] [CONFIGURATION <config>] [FLAGS <flags>] [PROJECT_NAME <project-name>] [TARGET <target-name>] [NUMBER_ERRORS <num-err-var>] [NUMBER_WARNINGS <num-warn-var>] [RETURN_VALUE <result-var>] )NINDENT NINDENT Build the project and store results in Build.xml for submission with the ctest_submit() command. The CTEST_BUILD_COMMAND variable may be set to explicitly specify the build command line. Otherwise the build command line is computed automatically based on the options given. The options are: NDENT 0.0
BUILD <build-dir> Specify the top-level build directory. If not given, the CTEST_BINARY_DIRECTORY variable is used.
APPEND Mark results for append to those previously submitted to a dashboard server since the last ctest_start() call. Append semantics are defined by the dashboard server in use.
CONFIGURATION <config> Specify the build configuration (e.g. Debug). If not specified the CTEST_BUILD_CONFIGURATION variable will be checked. Otherwise the -C <cfg> option given to the ctest(1) command will be used, if any.
FLAGS <flags> Pass additional arguments to the underlying build command. If not specified the CTEST_BUILD_FLAGS variable will be checked. This can, e.g., be used to trigger a parallel build using the -j option of make. See the ProcessorCount module for an example.
PROJECT_NAME <project-name> Set the name of the project to build. This should correspond to the top-level call to the project() command. If not specified the CTEST_PROJECT_NAME variable will be checked.
TARGET <target-name> Specify the name of a target to build. If not specified the CTEST_BUILD_TARGET variable will be checked. Otherwise the default target will be built. This is the "all" target (called ALL_BUILD in Visual Studio Generators).
NUMBER_ERRORS <num-err-var> Store the number of build errors detected in the given variable.
NUMBER_WARNINGS <num-warn-var> Store the number of build warnings detected in the given variable.
RETURN_VALUE <result-var> Store the return value of the native build tool in the given variable.
QUIET Suppress any CTest-specific non-error output that would have been printed to the console otherwise. The summary of warnings / errors, as well as the output from the native build tool is unaffected by this option. NINDENT
ctest_configure([BUILD <build-dir>] [SOURCE <source-dir>] [APPEND] [OPTIONS <options>] [RETURN_VALUE <result-var>] [QUIET])NINDENT NINDENT Configure the project build tree and record results in Configure.xml for submission with the ctest_submit() command. The options are: NDENT 0.0
BUILD <build-dir> Specify the top-level build directory. If not given, the CTEST_BINARY_DIRECTORY variable is used.
SOURCE <source-dir> Specify the source directory. If not given, the CTEST_SOURCE_DIRECTORY variable is used.
APPEND Mark results for append to those previously submitted to a dashboard server since the last ctest_start() call. Append semantics are defined by the dashboard server in use.
OPTIONS <options> Specify command-line arguments to pass to the configuration tool.
RETURN_VALUE <result-var> Store in the <result-var> variable the return value of the native configuration tool.
QUIET Suppress any CTest-specific non-error messages that would have otherwise been printed to the console. Output from the underlying configure command is not affected. NINDENT
ctest_coverage([BUILD <build-dir>] [APPEND] [LABELS <label>...] [RETURN_VALUE <result-var>] [QUIET] )NINDENT NINDENT Collect coverage tool results and stores them in Coverage.xml for submission with the ctest_submit() command. The options are: NDENT 0.0
BUILD <build-dir> Specify the top-level build directory. If not given, the CTEST_BINARY_DIRECTORY variable is used.
APPEND Mark results for append to those previously submitted to a dashboard server since the last ctest_start() call. Append semantics are defined by the dashboard server in use.
LABELS Filter the coverage report to include only source files labeled with at least one of the labels specified.
RETURN_VALUE <result-var> Store in the <result-var> variable 0 if coverage tools ran without error and non-zero otherwise.
QUIET Suppress any CTest-specific non-error output that would have been printed to the console otherwise. The summary indicating how many lines of code were covered is unaffected by this option. NINDENT
ctest_empty_binary_directory( directory )NINDENT NINDENT Removes a binary directory. This command will perform some checks prior to deleting the directory in an attempt to avoid malicious or accidental directory deletion.
ctest_memcheck([BUILD <build-dir>] [APPEND] [START <start-number>] [END <end-number>] [STRIDE <stride-number>] [EXCLUDE <exclude-regex>] [INCLUDE <include-regex>] [EXCLUDE_LABEL <label-exclude-regex>] [INCLUDE_LABEL <label-include-regex>] [PARALLEL_LEVEL <level>] [SCHEDULE_RANDOM <ON|OFF>] [STOP_TIME <time-of-day>] [RETURN_VALUE <result-var>] [QUIET] )NINDENT NINDENT Run tests with a dynamic analysis tool and store results in MemCheck.xml for submission with the ctest_submit() command. The options are the same as those for the ctest_test() command.
ctest_read_custom_files( directory ... )NINDENT NINDENT Read all the CTestCustom.ctest or CTestCustom.cmake files from the given directory.
ctest_run_script([NEW_PROCESS] script_file_name script_file_name1 script_file_name2 ... [RETURN_VALUE var])NINDENT NINDENT Runs a script or scripts much like if it was run from ctest -S. If no argument is provided then the current script is run using the current settings of the variables. If NEW_PROCESS is specified then each script will be run in a separate process.If RETURN_VALUE is specified the return value of the last script run will be put into var.
ctest_sleep(<seconds>)NINDENT NINDENT Sleep for given number of seconds. NDENT 0.0 NDENT 3.5
ctest_sleep(<time1> <duration> <time2>)NINDENT NINDENT Sleep for t=(time1 + duration - time2) seconds if t > 0.
ctest_start(Model [TRACK <track>] [APPEND] [source [binary]] [QUIET])NINDENT NINDENT Starts the testing for a given model. The command should be called after the binary directory is initialized. If the \(aqsource\(aq and \(aqbinary\(aq directory are not specified, it reads the CTEST_SOURCE_DIRECTORY and CTEST_BINARY_DIRECTORY. If the track is specified, the submissions will go to the specified track. If APPEND is used, the existing TAG is used rather than creating a new one based on the current time stamp. If QUIET is used, CTest will suppress any non-error messages that it otherwise would have printed to the console. If the CTEST_CHECKOUT_COMMAND variable (or the CTEST_CVS_CHECKOUT variable) is set, its content is treated as command-line. The command is invoked with the current working directory set to the parent of the source directory, even if the source directory already exists. This can be used to create the source tree from a version control repository.
ctest_submit([PARTS <part>...] [FILES <file>...] [RETRY_COUNT <count>] [RETRY_DELAY <delay>] [RETURN_VALUE <result-var>] [QUIET] )NINDENT NINDENT Submit results to a dashboard server. By default all available parts are submitted. The options are: NDENT 0.0
PARTS <part>... Specify a subset of parts to submit. Valid part names are: NDENT 7.0 NDENT 3.5
Start = nothing Update = ctest_update results, in Update.xml Configure = ctest_configure results, in Configure.xml Build = ctest_build results, in Build.xml Test = ctest_test results, in Test.xml Coverage = ctest_coverage results, in Coverage.xml MemCheck = ctest_memcheck results, in DynamicAnalysis.xml Notes = Files listed by CTEST_NOTES_FILES, in Notes.xml ExtraFiles = Files listed by CTEST_EXTRA_SUBMIT_FILES Upload = Files prepared for upload by ctest_upload(), in Upload.xml Submit = nothingNINDENT NINDENT
FILES <file>... Specify an explicit list of specific files to be submitted. Each individual file must exist at the time of the call.
RETRY_COUNT <count> Specify how many times to retry a timed-out submission.
RETRY_DELAY <delay> Specify how long (in seconds) to wait after a timed-out submission before attempting to re-submit.
RETURN_VALUE <result-var> Store in the <result-var> variable 0 for success and non-zero on failure.
QUIET Suppress all non-error messages that would have otherwise been printed to the console. NINDENT
ctest_submit(CDASH_UPLOAD <file> [CDASH_UPLOAD_TYPE <type>])NINDENT NINDENT This second signature is used to upload files to CDash via the CDash file upload API. The api first sends a request to upload to CDash along with a content hash of the file. If CDash does not already have the file, then it is uploaded. Along with the file, a CDash type string is specified to tell CDash which handler to use to process the data.
ctest_test([BUILD <build-dir>] [APPEND] [START <start-number>] [END <end-number>] [STRIDE <stride-number>] [EXCLUDE <exclude-regex>] [INCLUDE <include-regex>] [EXCLUDE_LABEL <label-exclude-regex>] [INCLUDE_LABEL <label-include-regex>] [PARALLEL_LEVEL <level>] [SCHEDULE_RANDOM <ON|OFF>] [STOP_TIME <time-of-day>] [RETURN_VALUE <result-var>] [QUIET] )NINDENT NINDENT Run tests in the project build tree and store results in Test.xml for submission with the ctest_submit() command. The options are: NDENT 0.0
BUILD <build-dir> Specify the top-level build directory. If not given, the CTEST_BINARY_DIRECTORY variable is used.
APPEND Mark results for append to those previously submitted to a dashboard server since the last ctest_start() call. Append semantics are defined by the dashboard server in use.
START <start-number> Specify the beginning of a range of test numbers.
END <end-number> Specify the end of a range of test numbers.
STRIDE <stride-number> Specify the stride by which to step acorss a range of test numbers.
EXCLUDE <exclude-regex> Specify a regular expression matching test names to exclude.
INCLUDE <include-regex> Specify a regular expression matching test names to include. Tests not matching this expression are excluded.
EXCLUDE_LABEL <label-exclude-regex> Specify a regular expression matching test labels to exclude.
INCLUDE_LABEL <label-include-regex> Specify a regular expression matching test labels to include. Tests not matching this expression are excluded.
PARALLEL_LEVEL <level> Specify a positive number representing the number of tests to be run in parallel.
SCHEDULE_RANDOM <ON|OFF> Launch tests in a random order. This may be useful for detecting implicit test dependencies.
STOP_TIME <time-of-day> Specify a time of day at which the tests should all stop running.
RETURN_VALUE <result-var> Store in the <result-var> variable 0 if all tests passed. Store non-zero if anything went wrong.
QUIET Suppress any CTest-specific non-error messages that would have otherwise been printed to the console. Output from the underlying test command is not affected. Summary info detailing the percentage of passing tests is also unaffected by the QUIET option. NINDENT
ctest_update([SOURCE <source-dir>] [RETURN_VALUE <result-var>] [QUIET])NINDENT NINDENT Update the source tree from version control and record results in Update.xml for submission with the ctest_submit() command. The options are: NDENT 0.0
SOURCE <source-dir> Specify the source directory. If not given, the CTEST_SOURCE_DIRECTORY variable is used.
RETURN_VALUE <result-var> Store in the <result-var> variable the number of files updated or -1 on error.
QUIET Tell CTest to suppress most non-error messages that it would have otherwise printed to the console. CTest will still report the new revision of the repository and any conflicting files that were found. NINDENT
ctest_upload(FILES <file>... [QUIET])NINDENT NINDENT The options are: NDENT 0.0
FILES <file>... Specify a list of files to be sent along with the build results to the dashboard server.
QUIET Suppress any CTest-specific non-error output that would have been printed to the console otherwise. NINDENT
.