<?xml version="1.0" ?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % addindex "IGNORE">
<!ENTITY % English "INCLUDE"> ]>
<article>
<articleinfo>
<title>ctest - ctest</title>
</articleinfo>
<sect1 id="ctest.Name">
<title>Name</title>
<para>
<programlisting>  ctest - Testing driver provided by CMake.</programlisting>
</para>
</sect1>
<sect1 id="ctest.Usage">
<title>Usage</title>
<para>
<programlisting>  ctest [options]</programlisting>
</para>
</sect1>
<sect1 id="ctest.Description">
<title>Description</title>
<para>The "ctest" executable is the CMake test driver program.  CMake-generated build trees created for projects that use the ENABLE_TESTING and ADD_TEST commands have testing support.  This program will run the tests and report results.</para>
</sect1>
<sect1 id="ctest.Options">
<title>Options</title>
<sect2 id="ctest.opt._C__cfg_____build_config__cfg_">
<title>-C &lt;cfg&gt;, --build-config &lt;cfg&gt;</title>
<abstract>
<para>Choose configuration to test.</para>
</abstract>
<para>Some CMake-generated build trees can have multiple build configurations in the same tree.  This option can be used to specify which one should be tested.  Example configurations are "Debug" and "Release".</para>
</sect2>
<sect2 id="ctest.opt._V___verbose">
<title>-V,--verbose</title>
<abstract>
<para>Enable verbose output from tests.</para>
</abstract>
<para>Test output is normally suppressed and only summary information is displayed.  This option will show all test output.</para>
</sect2>
<sect2 id="ctest.opt._VV___extra_verbose">
<title>-VV,--extra-verbose</title>
<abstract>
<para>Enable more verbose output from tests.</para>
</abstract>
<para>Test output is normally suppressed and only summary information is displayed.  This option will show even more test output.</para>
</sect2>
<sect2 id="ctest.opt.__debug">
<title>--debug</title>
<abstract>
<para>Displaying more verbose internals of CTest.</para>
</abstract>
<para>This feature will result in large number of output that is mostly useful for debugging dashboard problems.</para>
</sect2>
<sect2 id="ctest.opt.__output_on_failure">
<title>--output-on-failure</title>
<para>Output anything outputted by the test program if the test should fail.  This option can also be enabled by setting the environment variable CTEST_OUTPUT_ON_FAILURE</para>
</sect2>
<sect2 id="ctest.opt._F">
<title>-F</title>
<abstract>
<para>Enable failover.</para>
</abstract>
<para>This option allows ctest to resume a test set execution that was previously interrupted.  If no interruption occurred, the -F option will have no effect.</para>
</sect2>
<sect2 id="ctest.opt._j__jobs_____parallel__jobs_">
<title>-j &lt;jobs&gt;, --parallel &lt;jobs&gt;</title>
<abstract>
<para>Run the tests in parallel using thegiven number of jobs.</para>
</abstract>
<para>This option tells ctest to run the tests in parallel using given number of jobs.</para>
</sect2>
<sect2 id="ctest.opt._Q___quiet">
<title>-Q,--quiet</title>
<abstract>
<para>Make ctest quiet.</para>
</abstract>
<para>This option will suppress all the output. The output log file will still be generated if the --output-log is specified. Options such as --verbose, --extra-verbose, and --debug are ignored if --quiet is specified.</para>
</sect2>
<sect2 id="ctest.opt._O__file_____output_log__file_">
<title>-O &lt;file&gt;, --output-log &lt;file&gt;</title>
<abstract>
<para>Output to log file</para>
</abstract>
<para>This option tells ctest to write all its output to a log file.</para>
</sect2>
<sect2 id="ctest.opt._N___show_only">
<title>-N,--show-only</title>
<abstract>
<para>Disable actual execution of tests.</para>
</abstract>
<para>This option tells ctest to list the tests that would be run but not actually run them.  Useful in conjunction with the -R and -E options.</para>
</sect2>
<sect2 id="ctest.opt._L__regex_____label_regex__regex_">
<title>-L &lt;regex&gt;, --label-regex &lt;regex&gt;</title>
<abstract>
<para>Run tests with labels matching regular expression.</para>
</abstract>
<para>This option tells ctest to run only the tests whose labels match the given regular expression.</para>
</sect2>
<sect2 id="ctest.opt._R__regex_____tests_regex__regex_">
<title>-R &lt;regex&gt;, --tests-regex &lt;regex&gt;</title>
<abstract>
<para>Run tests matching regular expression.</para>
</abstract>
<para>This option tells ctest to run only the tests whose names match the given regular expression.</para>
</sect2>
<sect2 id="ctest.opt._E__regex_____exclude_regex__regex_">
<title>-E &lt;regex&gt;, --exclude-regex &lt;regex&gt;</title>
<abstract>
<para>Exclude tests matching regular expression.</para>
</abstract>
<para>This option tells ctest to NOT run the tests whose names match the given regular expression.</para>
</sect2>
<sect2 id="ctest.opt._LE__regex_____label_exclude__regex_">
<title>-LE &lt;regex&gt;, --label-exclude &lt;regex&gt;</title>
<abstract>
<para>Exclude tests with labels matching regular expression.</para>
</abstract>
<para>This option tells ctest to NOT run the tests whose labels match the given regular expression.</para>
</sect2>
<sect2 id="ctest.opt._D__dashboard_____dashboard__dashboard_">
<title>-D &lt;dashboard&gt;, --dashboard &lt;dashboard&gt;</title>
<abstract>
<para>Execute dashboard test</para>
</abstract>
<para>This option tells ctest to perform act as a Dart client and perform a dashboard test. All tests are &lt;Mode&gt;&lt;Test&gt;, where Mode can be Experimental, Nightly, and Continuous, and Test can be Start, Update, Configure, Build, Test, Coverage, and Submit.</para>
</sect2>
<sect2 id="ctest.opt._D__var___type___value_">
<title>-D &lt;var&gt;:&lt;type&gt;=&lt;value&gt;</title>
<abstract>
<para>Define a variable for script mode</para>
</abstract>
<para>Pass in variable values on the command line. Use in conjunction with -S to pass variable values to a dashboard script. Parsing -D arguments as variable values is only attempted if the value following -D does not match any of the known dashboard types.</para>
</sect2>
<sect2 id="ctest.opt._M__model_____test_model__model_">
<title>-M &lt;model&gt;, --test-model &lt;model&gt;</title>
<abstract>
<para>Sets the model for a dashboard</para>
</abstract>
<para>This option tells ctest to act as a Dart client where the TestModel can be Experimental, Nightly, and Continuous. Combining -M and -T is similar to -D</para>
</sect2>
<sect2 id="ctest.opt._T__action_____test_action__action_">
<title>-T &lt;action&gt;, --test-action &lt;action&gt;</title>
<abstract>
<para>Sets the dashboard action to perform</para>
</abstract>
<para>This option tells ctest to act as a Dart client and perform some action such as start, build, test etc. Combining -M and -T is similar to -D</para>
</sect2>
<sect2 id="ctest.opt.__track__track_">
<title>--track &lt;track&gt;</title>
<abstract>
<para>Specify the track to submit dashboard to</para>
</abstract>
<para>Submit dashboard to specified track instead of default one. By default, the dashboard is submitted to Nightly, Experimental, or Continuous track, but by specifying this option, the track can be arbitrary.</para>
</sect2>
<sect2 id="ctest.opt._S__script_____script__script_">
<title>-S &lt;script&gt;, --script &lt;script&gt;</title>
<abstract>
<para>Execute a dashboard for a configuration</para>
</abstract>
<para>This option tells ctest to load in a configuration script which sets a number of parameters such as the binary and source directories. Then ctest will do what is required to create and run a dashboard. This option basically sets up a dashboard and then runs ctest -D with the appropriate options.</para>
</sect2>
<sect2 id="ctest.opt._SP__script_____script_new_process__script_">
<title>-SP &lt;script&gt;, --script-new-process &lt;script&gt;</title>
<abstract>
<para>Execute a dashboard for a configuration</para>
</abstract>
<para>This option does the same operations as -S but it will do them in a separate process. This is primarily useful in cases where the script may modify the environment and you do not want the modified environment to impact other -S scripts.</para>
</sect2>
<sect2 id="ctest.opt._A__file_____add_notes__file_">
<title>-A &lt;file&gt;, --add-notes &lt;file&gt;</title>
<abstract>
<para>Add a notes file with submission</para>
</abstract>
<para>This option tells ctest to include a notes file when submitting dashboard. </para>
</sect2>
<sect2 id="ctest.opt._I__Start_End_Stride_test__test__Test_file_____tests_information">
<title>-I [Start,End,Stride,test#,test#|Test file], --tests-information</title>
<abstract>
<para>Run a specific number of tests by number.</para>
</abstract>
<para>This option causes ctest to run tests starting at number Start, ending at number End, and incrementing by Stride. Any additional numbers after Stride are considered individual test numbers.  Start, End,or stride can be empty.  Optionally a file can be given that contains the same syntax as the command line.</para>
</sect2>
<sect2 id="ctest.opt._U____union">
<title>-U, --union</title>
<abstract>
<para>Take the Union of -I and -R</para>
</abstract>
<para>When both -R and -I are specified by default the intersection of tests are run. By specifying -U the union of tests is run instead.</para>
</sect2>
<sect2 id="ctest.opt.__max_width__width_">
<title>--max-width &lt;width&gt;</title>
<abstract>
<para>Set the max width for a test name to output</para>
</abstract>
<para>Set the maximum width for each test name to show in the output.  This allows the user to widen the output to avoid clipping the test name which can be very annoying.</para>
</sect2>
<sect2 id="ctest.opt.__interactive_debug_mode__0_1_">
<title>--interactive-debug-mode [0|1]</title>
<abstract>
<para>Set the interactive mode to 0 or 1.</para>
</abstract>
<para>This option causes ctest to run tests in either an interactive mode or a non-interactive mode. On Windows this means that in non-interactive mode, all system debug pop up windows are blocked. In dashboard mode (Experimental, Nightly, Continuous), the default is non-interactive.  When just running tests not for a dashboard the default is to allow popups and interactive debugging.</para>
</sect2>
<sect2 id="ctest.opt.__no_label_summary">
<title>--no-label-summary</title>
<abstract>
<para>Disable timing summary information for labels.</para>
</abstract>
<para>This option tells ctest not to print summary information for each label associated with the tests run. If there are no labels on the tests, nothing extra is printed.</para>
</sect2>
<sect2 id="ctest.opt.__build_and_test">
<title>--build-and-test</title>
<abstract>
<para>Configure, build and run a test.</para>
</abstract>
<para>This option tells ctest to configure (i.e. run cmake on), build, and or execute a test. The configure and test steps are optional. The arguments to this command line are the source and binary directories. By default this will run CMake on the Source/Bin directories specified unless --build-nocmake is specified. Both --build-makeprogram and --build-generator MUST be provided to use --built-and-test. If --test-command is specified then that will be run after the build is complete. Other options that affect this mode are --build-target --build-nocmake, --build-run-dir, --build-two-config, --build-exe-dir, --build-project,--build-noclean, --build-options</para>
</sect2>
<sect2 id="ctest.opt.__build_target">
<title>--build-target</title>
<abstract>
<para>Specify a specific target to build.</para>
</abstract>
<para>This option goes with the --build-and-test option, if left out the all target is built.</para>
</sect2>
<sect2 id="ctest.opt.__build_nocmake">
<title>--build-nocmake</title>
<abstract>
<para>Run the build without running cmake first.</para>
</abstract>
<para>Skip the cmake step.</para>
</sect2>
<sect2 id="ctest.opt.__build_run_dir">
<title>--build-run-dir</title>
<abstract>
<para>Specify directory to run programs from.</para>
</abstract>
<para>Directory where programs will be after it has been compiled.</para>
</sect2>
<sect2 id="ctest.opt.__build_two_config">
<title>--build-two-config</title>
<para>Run CMake twice</para>
</sect2>
<sect2 id="ctest.opt.__build_exe_dir">
<title>--build-exe-dir</title>
<para>Specify the directory for the executable.</para>
</sect2>
<sect2 id="ctest.opt.__build_generator">
<title>--build-generator</title>
<para>Specify the generator to use.</para>
</sect2>
<sect2 id="ctest.opt.__build_project">
<title>--build-project</title>
<para>Specify the name of the project to build.</para>
</sect2>
<sect2 id="ctest.opt.__build_makeprogram">
<title>--build-makeprogram</title>
<para>Specify the make program to use.</para>
</sect2>
<sect2 id="ctest.opt.__build_noclean">
<title>--build-noclean</title>
<para>Skip the make clean step.</para>
</sect2>
<sect2 id="ctest.opt.__build_config_sample">
<title>--build-config-sample</title>
<abstract>
<para>A sample executable to use to determine the configuration</para>
</abstract>
<para>A sample executable to use to determine the configuration that should be used. e.g. Debug/Release/etc</para>
</sect2>
<sect2 id="ctest.opt.__build_options">
<title>--build-options</title>
<abstract>
<para>Add extra options to the build step.</para>
</abstract>
<para>This option must be the last option with the exception of --test-command</para>
</sect2>
<sect2 id="ctest.opt.__test_command">
<title>--test-command</title>
<para>The test to run with the --build-and-test option.</para>
</sect2>
<sect2 id="ctest.opt.__test_timeout">
<title>--test-timeout</title>
<para>The time limit in seconds, internal use only.</para>
</sect2>
<sect2 id="ctest.opt.__tomorrow_tag">
<title>--tomorrow-tag</title>
<abstract>
<para>Nightly or experimental starts with next day tag.</para>
</abstract>
<para>This is useful if the build will not finish in one day.</para>
</sect2>
<sect2 id="ctest.opt.__ctest_config">
<title>--ctest-config</title>
<abstract>
<para>The configuration file used to initialize CTest state when submitting dashboards.</para>
</abstract>
<para>This option tells CTest to use different initialization file instead of CTestConfiguration.tcl. This way multiple initialization files can be used for example to submit to multiple dashboards.</para>
</sect2>
<sect2 id="ctest.opt.__overwrite">
<title>--overwrite</title>
<abstract>
<para>Overwrite CTest configuration option.</para>
</abstract>
<para>By default ctest uses configuration options from configuration file. This option will overwrite the configuration option.</para>
</sect2>
<sect2 id="ctest.opt.__extra_submit__file____file__">
<title>--extra-submit &lt;file&gt;[;&lt;file&gt;]</title>
<abstract>
<para>Submit extra files to the dashboard.</para>
</abstract>
<para>This option will submit extra files to the dashboard.</para>
</sect2>
<sect2 id="ctest.opt.__force_new_ctest_process">
<title>--force-new-ctest-process</title>
<abstract>
<para>Run child CTest instances as new processes</para>
</abstract>
<para>By default CTest will run child CTest instances within the same process. If this behavior is not desired, this argument will enforce new processes for child CTest processes.</para>
</sect2>
<sect2 id="ctest.opt.__schedule_random">
<title>--schedule-random</title>
<abstract>
<para>Use a random order for scheduling tests</para>
</abstract>
<para>This option will run the tests in a random order. It is commonly used to detect implicit dependencies in a test suite.</para>
</sect2>
<sect2 id="ctest.opt.__submit_index">
<title>--submit-index</title>
<abstract>
<para>Submit individual dashboard tests with specific index</para>
</abstract>
<para>This option allows performing the same CTest action (such as test) multiple times and submit all stages to the same dashboard (Dart2 required). Each execution requires different index.</para>
</sect2>
<sect2 id="ctest.opt.__timeout__seconds_">
<title>--timeout &lt;seconds&gt;</title>
<abstract>
<para>Set a global timeout on all tests.</para>
</abstract>
<para>This option will set a global timeout on all tests that do not already have a timeout set on them.</para>
</sect2>
<sect2 id="ctest.opt.__stop_time__time_">
<title>--stop-time &lt;time&gt;</title>
<abstract>
<para>Set a time at which all tests should stop running.</para>
</abstract>
<para>Set a real time of day at which all tests should timeout. Example: 7:00:00 -0400. Any time format understood by the curl date parser is accepted. Local time is assumed if no timezone is specified.</para>
</sect2>
<sect2 id="ctest.opt.__http1_0">
<title>--http1.0</title>
<abstract>
<para>Submit using HTTP 1.0.</para>
</abstract>
<para>This option will force CTest to use HTTP 1.0 to submit files to the dashboard, instead of HTTP 1.1.</para>
</sect2>
<sect2 id="ctest.opt.__no_compress_output">
<title>--no-compress-output</title>
<abstract>
<para>Do not compress test output when submitting.</para>
</abstract>
<para>This flag will turn off automatic compression of test output.  Use this to maintain compatibility with an older version of CDash which doesn't support compressed test output.</para>
</sect2>
<sect2 id="ctest.opt.__print_labels">
<title>--print-labels</title>
<abstract>
<para>Print all available test labels.</para>
</abstract>
<para>This option will not run any tests, it will simply print the list of all labels associated with the test set.</para>
</sect2>
<sect2 id="ctest.opt.__help_command__cmd____file__">
<title>--help-command &lt;cmd&gt; [&lt;file&gt;]</title>
<abstract>
<para>Show help for a single command and exit.</para>
</abstract>
<para>Prints the help for the command to stdout or to the specified file.</para>
</sect2>
<sect2 id="ctest.opt.__help_command_list___file__">
<title>--help-command-list [&lt;file&gt;]</title>
<abstract>
<para>List available commands and exit.</para>
</abstract>
<para>Prints the list of all available listfile commands to stdout or the specified file.</para>
</sect2>
<sect2 id="ctest.opt.__help_commands___file__">
<title>--help-commands [&lt;file&gt;]</title>
<abstract>
<para>Print help for all commands and exit.</para>
</abstract>
<para>Prints the help for all commands to stdout or to the specified file.</para>
</sect2>
<sect2 id="ctest.opt.__copyright__file_">
<title>--copyright [file]</title>
<abstract>
<para>Print the CMake copyright and exit.</para>
</abstract>
<para>If a file is specified, the copyright is written into it.</para>
</sect2>
<sect2 id="ctest.opt.__help__help__usage__h__H___">
<title>--help,-help,-usage,-h,-H,/?</title>
<abstract>
<para>Print usage information and exit.</para>
</abstract>
<para>Usage describes the basic command line interface and its options.</para>
</sect2>
<sect2 id="ctest.opt.__help_full__file_">
<title>--help-full [file]</title>
<abstract>
<para>Print full help and exit.</para>
</abstract>
<para>Full help displays most of the documentation provided by the UNIX man page.  It is provided for use on non-UNIX platforms, but is also convenient if the man page is not installed.  If a file is specified, the help is written into it.</para>
</sect2>
<sect2 id="ctest.opt.__help_html__file_">
<title>--help-html [file]</title>
<abstract>
<para>Print full help in HTML format.</para>
</abstract>
<para>This option is used by CMake authors to help produce web pages.  If a file is specified, the help is written into it.</para>
</sect2>
<sect2 id="ctest.opt.__help_man__file_">
<title>--help-man [file]</title>
<abstract>
<para>Print full help as a UNIX man page and exit.</para>
</abstract>
<para>This option is used by the cmake build to generate the UNIX man page.  If a file is specified, the help is written into it.</para>
</sect2>
<sect2 id="ctest.opt.__version__version__V__file_">
<title>--version,-version,/V [file]</title>
<abstract>
<para>Show program name/version banner and exit.</para>
</abstract>
<para>If a file is specified, the version is written into it.</para>
</sect2>
</sect1>
<sect1 id="ctest.Generators">
<title>Generators</title>
<para>The following generators are available on this platform:</para>
</sect1>
<sect1 id="ctest.Commands">
<title>Commands</title>
<sect2 id="ctest.command.break">
<title>break</title>
<abstract>
<para>Break from an enclosing foreach or while loop.</para>
</abstract>
<para>
<programlisting>  break()
</programlisting>
</para>
<para>Breaks from an enclosing foreach loop or while loop</para>
</sect2>
<sect2 id="ctest.command.build_name">
<title>build_name</title>
<abstract>
<para>Deprecated.  Use ${CMAKE_SYSTEM} and ${CMAKE_CXX_COMPILER} instead.</para>
</abstract>
<para>
<programlisting>  build_name(variable)
</programlisting>
</para>
<para>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.</para>
</sect2>
<sect2 id="ctest.command.cmake_minimum_required">
<title>cmake_minimum_required</title>
<abstract>
<para>Set the minimum required version of cmake for a project.</para>
</abstract>
<para>
<programlisting>  cmake_minimum_required(VERSION major[.minor[.patch[.tweak]]]
                         [FATAL_ERROR])
</programlisting>
</para>
<para>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
</para>
<para>
<programlisting>  cmake_policy(VERSION major[.minor[.patch[.tweak]]])
</programlisting>
</para>
<para>which sets the cmake policy version level to the version specified.  When version 2.4 or lower is given the command implicitly invokes
</para>
<para>
<programlisting>  cmake_policy(VERSION 2.4)
</programlisting>
</para>
<para>which enables compatibility features for CMake 2.4 and lower.
</para>
<para>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.</para>
</sect2>
<sect2 id="ctest.command.cmake_policy">
<title>cmake_policy</title>
<abstract>
<para>Manage CMake Policy settings.</para>
</abstract>
<para>As CMake evolves it is sometimes necessary to change existing behavior in order to fix bugs or improve implementations of existing features.  The CMake Policy mechanism is designed to help keep existing projects building as new versions of CMake introduce changes in behavior.  Each new policy (behavioral change) is given an identifier of the form "CMP&lt;NNNN&gt;" where "&lt;NNNN&gt;" is an integer index.  Documentation associated with each policy describes the OLD and NEW behavior and the reason the policy was introduced.  Projects may set each policy to select the desired behavior.  When CMake needs to know which behavior to use it checks for a setting specified by the project.  If no setting is available the OLD behavior is assumed and a warning is produced requesting that the policy be set.
</para>
<para>The cmake_policy command is used to set policies to OLD or NEW behavior.  While setting policies individually is supported, we encourage projects to set policies based on CMake versions.
</para>
<para>
<programlisting>  cmake_policy(VERSION major.minor[.patch[.tweak]])
</programlisting>
</para>
<para>Specify that the current CMake list file 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 variable CMAKE_POLICY_DEFAULT_CMP&lt;NNNN&gt; 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.  In order to get compatibility features supporting versions earlier than 2.4 see documentation of policy CMP0001.
</para>
<para>
<programlisting>  cmake_policy(SET CMP&lt;NNNN&gt; NEW)
  cmake_policy(SET CMP&lt;NNNN&gt; OLD)
</programlisting>
</para>
<para>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.
</para>
<para>
<programlisting>  cmake_policy(GET CMP&lt;NNNN&gt; &lt;variable&gt;)
</programlisting>
</para>
<para>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.
</para>
<para>CMake keeps policy settings on a stack, so changes made by the cmake_policy command affect only the top of the stack.  A new entry on the policy stack is managed automatically for each subdirectory to protect its parents and siblings.  CMake also manages a new entry for scripts loaded by include() and find_package() commands except when invoked with the NO_POLICY_SCOPE option (see also policy CMP0011).  The cmake_policy command provides an interface to manage custom entries on the policy stack:
</para>
<para>
<programlisting>  cmake_policy(PUSH)
  cmake_policy(POP)
</programlisting>
</para>
<para>Each PUSH must have a matching POP to erase any changes.  This is useful to make temporary changes to policy settings.
</para>
<para>Functions and macros 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.</para>
</sect2>
<sect2 id="ctest.command.configure_file">
<title>configure_file</title>
<abstract>
<para>Copy a file to another location and modify its contents.</para>
</abstract>
<para>
<programlisting>  configure_file(&lt;input&gt; &lt;output&gt;
                 [COPYONLY] [ESCAPE_QUOTES] [@ONLY] 
                 [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])
</programlisting>
</para>
<para>Copies a file &lt;input&gt; to file &lt;output&gt; and substitutes variable values referenced in the file content.  If &lt;input&gt; is a relative path it is evaluated with respect to the current source directory.  The &lt;input&gt; must be a file, not a directory.  If &lt;output&gt; is a relative path it is evaluated with respect to the current binary directory.  If &lt;output&gt; names an existing directory the input file is placed in that directory with its original name.  
</para>
<para>This command replaces any variables in the input file referenced as ${VAR} or @VAR@ with their values as determined by CMake.  If a variable is not defined, it will be replaced with nothing.  If COPYONLY is specified, then no variable expansion will take place.  If ESCAPE_QUOTES is specified then any substituted quotes will be C-style escaped.  The file will be configured with the current values of CMake variables. If @ONLY is specified, only variables of the form @VAR@ will be replaces and ${VAR} will be ignored.  This is useful for configuring scripts that use ${VAR}. Any occurrences of #cmakedefine VAR will be replaced with either #define VAR or /* #undef VAR */ depending on the setting of VAR in CMake. Any occurrences of #cmakedefine01 VAR will be replaced with either #define VAR 1 or #define VAR 0 depending on whether VAR evaluates to TRUE or FALSE in CMake.
</para>
<para>With NEWLINE_STYLE the line ending could be adjusted: 
</para>
<para>
<programlisting>    'UNIX' or 'LF' for \n, 'DOS', 'WIN32' or 'CRLF' for \r\n.
</programlisting>
</para>
<para>COPYONLY must not be used with NEWLINE_STYLE.
</para>
</sect2>
<sect2 id="ctest.command.ctest_build">
<title>ctest_build</title>
<abstract>
<para>Build the project.</para>
</abstract>
<para>
<programlisting>  ctest_build([BUILD build_dir] [TARGET target] [RETURN_VALUE res]
              [APPEND][NUMBER_ERRORS val] [NUMBER_WARNINGS val])
</programlisting>
</para>
<para>Builds the given build directory and stores results in Build.xml. If no BUILD is given, the CTEST_BINARY_DIRECTORY variable is used.
</para>
<para>The TARGET variable can be used to specify a build target.  If none is specified, the "all" target will be built.
</para>
<para>The RETURN_VALUE option specifies a variable in which to store the return value of the native build tool. The NUMBER_ERRORS and NUMBER_WARNINGS options specify variables in which to store the number of build errors and warnings detected.
</para>
<para>The APPEND option marks results for append to those previously submitted to a dashboard server since the last ctest_start.  Append semantics are defined by the dashboard server in use.</para>
</sect2>
<sect2 id="ctest.command.ctest_configure">
<title>ctest_configure</title>
<abstract>
<para>Configure the project build tree.</para>
</abstract>
<para>
<programlisting>  ctest_configure([BUILD build_dir] [SOURCE source_dir] [APPEND]
                  [OPTIONS options] [RETURN_VALUE res])
</programlisting>
</para>
<para>Configures the given build directory and stores results in Configure.xml. If no BUILD is given, the CTEST_BINARY_DIRECTORY variable is used. If no SOURCE is given, the CTEST_SOURCE_DIRECTORY variable is used. The OPTIONS argument specifies command line arguments to pass to the configuration tool. The RETURN_VALUE option specifies a variable in which to store the return value of the native build tool.
</para>
<para>The APPEND option marks results for append to those previously submitted to a dashboard server since the last ctest_start.  Append semantics are defined by the dashboard server in use.</para>
</sect2>
<sect2 id="ctest.command.ctest_coverage">
<title>ctest_coverage</title>
<abstract>
<para>Collect coverage tool results.</para>
</abstract>
<para>
<programlisting>  ctest_coverage([BUILD build_dir] [RETURN_VALUE res] [APPEND]
                 [LABELS label1 [label2 [...]]])
</programlisting>
</para>
<para>Perform the coverage of the given build directory and stores results in Coverage.xml. The second argument is a variable that will hold value.
</para>
<para>The LABELS option filters the coverage report to include only source files labeled with at least one of the labels specified.
</para>
<para>The APPEND option marks results for append to those previously submitted to a dashboard server since the last ctest_start.  Append semantics are defined by the dashboard server in use.</para>
</sect2>
<sect2 id="ctest.command.ctest_empty_binary_directory">
<title>ctest_empty_binary_directory</title>
<abstract>
<para>empties the binary directory</para>
</abstract>
<para>
<programlisting>  ctest_empty_binary_directory( directory )
</programlisting>
</para>
<para>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.</para>
</sect2>
<sect2 id="ctest.command.ctest_memcheck">
<title>ctest_memcheck</title>
<abstract>
<para>Run tests with a dynamic analysis tool.</para>
</abstract>
<para>
<programlisting>  ctest_memcheck([BUILD build_dir] [RETURN_VALUE res] [APPEND]
             [START start number] [END end number]
             [STRIDE stride number] [EXCLUDE exclude regex ]
             [INCLUDE include regex] 
             [EXCLUDE_LABEL exclude regex] 
             [INCLUDE_LABEL label regex] 
             [PARALLEL_LEVEL level] )
</programlisting>
</para>
<para>Tests the given build directory and stores results in MemCheck.xml. The second argument is a variable that will hold value. Optionally, you can specify the starting test number START, the ending test number END, the number of tests to skip between each test STRIDE, a regular expression for tests to run INCLUDE, or a regular expression for tests not to run EXCLUDE. EXCLUDE_LABEL and INCLUDE_LABEL are regular expressions for tests to be included or excluded by the test property LABEL. PARALLEL_LEVEL should be set to a positive number representing the number of tests to be run in parallel.
</para>
<para>The APPEND option marks results for append to those previously submitted to a dashboard server since the last ctest_start.  Append semantics are defined by the dashboard server in use.</para>
</sect2>
<sect2 id="ctest.command.ctest_read_custom_files">
<title>ctest_read_custom_files</title>
<abstract>
<para>read CTestCustom files.</para>
</abstract>
<para>
<programlisting>  ctest_read_custom_files( directory ... )
</programlisting>
</para>
<para>Read all the CTestCustom.ctest or CTestCustom.cmake files from the given directory.</para>
</sect2>
<sect2 id="ctest.command.ctest_run_script">
<title>ctest_run_script</title>
<abstract>
<para>runs a ctest -S script</para>
</abstract>
<para>
<programlisting>  ctest_run_script([NEW_PROCESS] script_file_name script_file_name1 
              script_file_name2 ... [RETURN_VALUE var])
</programlisting>
</para>
<para>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.</para>
</sect2>
<sect2 id="ctest.command.ctest_sleep">
<title>ctest_sleep</title>
<abstract>
<para>sleeps for some amount of time</para>
</abstract>
<para>
<programlisting>  ctest_sleep(&lt;seconds&gt;)
</programlisting>
</para>
<para>Sleep for given number of seconds.
</para>
<para>
<programlisting>  ctest_sleep(&lt;time1&gt; &lt;duration&gt; &lt;time2&gt;)
</programlisting>
</para>
<para>Sleep for t=(time1 + duration - time2) seconds if t &gt; 0.</para>
</sect2>
<sect2 id="ctest.command.ctest_start">
<title>ctest_start</title>
<abstract>
<para>Starts the testing for a given model</para>
</abstract>
<para>
<programlisting>  ctest_start(Model [TRACK &lt;track&gt;] [APPEND] [source [binary]])
</programlisting>
</para>
<para>Starts the testing for a given model. The command should be called after the binary directory is initialized. If the 'source' and 'binary' 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.</para>
</sect2>
<sect2 id="ctest.command.ctest_submit">
<title>ctest_submit</title>
<abstract>
<para>Submit results to a dashboard server.</para>
</abstract>
<para>
<programlisting>  ctest_submit([PARTS ...] [FILES ...] [RETRY_COUNT count]                [RETRY_DELAY delay][RETURN_VALUE res])
</programlisting>
</para>
<para>By default all available parts are submitted if no PARTS or FILES are specified.  The PARTS option lists a subset of parts to be submitted.  Valid part names are:
</para>
<para>
<programlisting>  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
  Submit     = nothing
</programlisting>
</para>
<para>The FILES option explicitly lists specific files to be submitted.  Each individual file must exist at the time of the call.
</para>
<para>The RETRY_DELAY option specifies how long in seconds to wait after a timed-out submission before attempting to re-submit.
</para>
<para>The RETRY_COUNT option specifies how many times to retry a timed-out submission.
</para>
</sect2>
<sect2 id="ctest.command.ctest_test">
<title>ctest_test</title>
<abstract>
<para>Run tests in the project build tree.</para>
</abstract>
<para>
<programlisting>  ctest_test([BUILD build_dir] [APPEND]
             [START start number] [END end number]
             [STRIDE stride number] [EXCLUDE exclude regex ]
             [INCLUDE include regex] [RETURN_VALUE res] 
             [EXCLUDE_LABEL exclude regex] 
             [INCLUDE_LABEL label regex] 
             [PARALLEL_LEVEL level] 
             [SCHEDULE_RANDOM on] 
             [STOP_TIME time of day]) 
</programlisting>
</para>
<para>Tests the given build directory and stores results in Test.xml. The second argument is a variable that will hold value. Optionally, you can specify the starting test number START, the ending test number END, the number of tests to skip between each test STRIDE, a regular expression for tests to run INCLUDE, or a regular expression for tests to not run EXCLUDE. EXCLUDE_LABEL and INCLUDE_LABEL are regular expression for test to be included or excluded by the test property LABEL. PARALLEL_LEVEL should be set to a positive number representing the number of tests to be run in parallel. SCHEDULE_RANDOM will launch tests in a random order, and is typically used to detect implicit test dependencies. STOP_TIME is the time of day at which the tests should all stop running.
</para>
<para>The APPEND option marks results for append to those previously submitted to a dashboard server since the last ctest_start.  Append semantics are defined by the dashboard server in use.</para>
</sect2>
<sect2 id="ctest.command.ctest_update">
<title>ctest_update</title>
<abstract>
<para>Update the work tree from version control.</para>
</abstract>
<para>
<programlisting>  ctest_update([SOURCE source] [RETURN_VALUE res])
</programlisting>
</para>
<para>Updates the given source directory and stores results in Update.xml. If no SOURCE is given, the CTEST_SOURCE_DIRECTORY variable is used. The RETURN_VALUE option specifies a variable in which to store the result, which is the number of files updated or -1 on error.</para>
</sect2>
<sect2 id="ctest.command.ctest_upload">
<title>ctest_upload</title>
<abstract>
<para>Upload files to a dashboard server.</para>
</abstract>
<para>
<programlisting>  ctest_upload(FILES ...)
</programlisting>
</para>
<para>Pass a list of files to be sent along with the build results to the dashboard server.
</para>
</sect2>
<sect2 id="ctest.command.else">
<title>else</title>
<abstract>
<para>Starts the else portion of an if block.</para>
</abstract>
<para>
<programlisting>  else(expression)
</programlisting>
</para>
<para>See the if command.</para>
</sect2>
<sect2 id="ctest.command.elseif">
<title>elseif</title>
<abstract>
<para>Starts the elseif portion of an if block.</para>
</abstract>
<para>
<programlisting>  elseif(expression)
</programlisting>
</para>
<para>See the if command.</para>
</sect2>
<sect2 id="ctest.command.endforeach">
<title>endforeach</title>
<abstract>
<para>Ends a list of commands in a FOREACH block.</para>
</abstract>
<para>
<programlisting>  endforeach(expression)
</programlisting>
</para>
<para>See the FOREACH command.</para>
</sect2>
<sect2 id="ctest.command.endfunction">
<title>endfunction</title>
<abstract>
<para>Ends a list of commands in a function block.</para>
</abstract>
<para>
<programlisting>  endfunction(expression)
</programlisting>
</para>
<para>See the function command.</para>
</sect2>
<sect2 id="ctest.command.endif">
<title>endif</title>
<abstract>
<para>Ends a list of commands in an if block.</para>
</abstract>
<para>
<programlisting>  endif(expression)
</programlisting>
</para>
<para>See the if command.</para>
</sect2>
<sect2 id="ctest.command.endmacro">
<title>endmacro</title>
<abstract>
<para>Ends a list of commands in a macro block.</para>
</abstract>
<para>
<programlisting>  endmacro(expression)
</programlisting>
</para>
<para>See the macro command.</para>
</sect2>
<sect2 id="ctest.command.endwhile">
<title>endwhile</title>
<abstract>
<para>Ends a list of commands in a while block.</para>
</abstract>
<para>
<programlisting>  endwhile(expression)
</programlisting>
</para>
<para>See the while command.</para>
</sect2>
<sect2 id="ctest.command.exec_program">
<title>exec_program</title>
<abstract>
<para>Deprecated.  Use the execute_process() command instead.</para>
</abstract>
<para>Run an executable program during the processing of the CMakeList.txt file.
</para>
<para>
<programlisting>  exec_program(Executable [directory in which to run]
               [ARGS &lt;arguments to executable&gt;]
               [OUTPUT_VARIABLE &lt;var&gt;]
               [RETURN_VALUE &lt;var&gt;])
</programlisting>
</para>
<para>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.
</para>
</sect2>
<sect2 id="ctest.command.execute_process">
<title>execute_process</title>
<abstract>
<para>Execute one or more child processes.</para>
</abstract>
<para>
<programlisting>  execute_process(COMMAND &lt;cmd1&gt; [args1...]]
                  [COMMAND &lt;cmd2&gt; [args2...] [...]]
                  [WORKING_DIRECTORY &lt;directory&gt;]
                  [TIMEOUT &lt;seconds&gt;]
                  [RESULT_VARIABLE &lt;variable&gt;]
                  [OUTPUT_VARIABLE &lt;variable&gt;]
                  [ERROR_VARIABLE &lt;variable&gt;]
                  [INPUT_FILE &lt;file&gt;]
                  [OUTPUT_FILE &lt;file&gt;]
                  [ERROR_FILE &lt;file&gt;]
                  [OUTPUT_QUIET]
                  [ERROR_QUIET]
                  [OUTPUT_STRIP_TRAILING_WHITESPACE]
                  [ERROR_STRIP_TRAILING_WHITESPACE])
</programlisting>
</para>
<para>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.  If WORKING_DIRECTORY is given the named directory will be set as the current working directory of the child processes.  If TIMEOUT is given the child processes will be terminated if they do not finish in the specified number of seconds (fractions are allowed).  If RESULT_VARIABLE is given 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.  If OUTPUT_VARIABLE or ERROR_VARIABLE are given 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.  If INPUT_FILE, OUTPUT_FILE, or ERROR_FILE is given 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 OUTPUT_QUIET or ERROR_QUIET is given then the standard output or standard error results will be quietly ignored.  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.
</para>
<para>The execute_process command is a newer more powerful version of exec_program, but the old command has been kept for compatibility.</para>
</sect2>
<sect2 id="ctest.command.file">
<title>file</title>
<abstract>
<para>File manipulation command.</para>
</abstract>
<para>
<programlisting>  file(WRITE filename "message to write"... )
  file(APPEND filename "message to write"... )
  file(READ filename variable [LIMIT numBytes] [OFFSET offset] [HEX])
  file(&lt;MD5|SHA1|SHA224|SHA256|SHA384|SHA512&gt; filename variable)
  file(STRINGS filename variable [LIMIT_COUNT num]
       [LIMIT_INPUT numBytes] [LIMIT_OUTPUT numBytes]
       [LENGTH_MINIMUM numBytes] [LENGTH_MAXIMUM numBytes]
       [NEWLINE_CONSUME] [REGEX regex]
       [NO_HEX_CONVERSION])
  file(GLOB variable [RELATIVE path] [globbing expressions]...)
  file(GLOB_RECURSE variable [RELATIVE path] 
       [FOLLOW_SYMLINKS] [globbing expressions]...)
  file(RENAME &lt;oldname&gt; &lt;newname&gt;)
  file(REMOVE [file1 ...])
  file(REMOVE_RECURSE [file1 ...])
  file(MAKE_DIRECTORY [directory1 directory2 ...])
  file(RELATIVE_PATH variable directory file)
  file(TO_CMAKE_PATH path result)
  file(TO_NATIVE_PATH path result)
  file(DOWNLOAD url file [INACTIVITY_TIMEOUT timeout]
       [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS]
       [EXPECTED_HASH ALGO=value] [EXPECTED_MD5 sum]
       [TLS_VERIFY on|off] [TLS_CAINFO file])
  file(UPLOAD filename url [INACTIVITY_TIMEOUT timeout]
       [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS])
</programlisting>
</para>
<para>WRITE will write a message into a file called 'filename'. It overwrites the file if it already exists, and creates the file if it does not exist.
</para>
<para>APPEND will write a message into a file same as WRITE, except it will append it to the end of the file
</para>
<para>READ will read the content of a file and store it into the variable. It will start at the given offset and read up to numBytes. If the argument HEX is given, the binary data will be converted to hexadecimal representation and this will be stored in the variable.
</para>
<para>MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 will compute a cryptographic hash of the content of a file.
</para>
<para>STRINGS will parse a list of ASCII strings from a file and store it in a variable. Binary data in the file are ignored. Carriage return (CR) characters are ignored. It works also for Intel Hex and Motorola S-record files, which are automatically converted to binary format when reading them. Disable this using NO_HEX_CONVERSION.
</para>
<para>LIMIT_COUNT sets the maximum number of strings to return. LIMIT_INPUT sets the maximum number of bytes to read from the input file. LIMIT_OUTPUT sets the maximum number of bytes to store in the output variable. LENGTH_MINIMUM sets the minimum length of a string to return. Shorter strings are ignored. LENGTH_MAXIMUM sets the maximum length of a string to return.  Longer strings are split into strings no longer than the maximum length. NEWLINE_CONSUME allows newlines to be included in strings instead of terminating them.
</para>
<para>REGEX specifies a regular expression that a string must match to be returned. Typical usage 
</para>
<para>
<programlisting>  file(STRINGS myfile.txt myfile)
</programlisting>
</para>
<para>stores a list in the variable "myfile" in which each item is a line from the input file.
</para>
<para>GLOB will generate a list of all 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 for an expression, the results will be returned as a relative path to the given path.  (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.)
</para>
<para>Examples of globbing expressions include:
</para>
<para>
<programlisting>   *.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.txt
</programlisting>
</para>
<para>GLOB_RECURSE will generate a list similar to the regular GLOB, except it 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 cmake policy CMP0009 is not set to NEW. See cmake --help-policy CMP0009 for more information.
</para>
<para>Examples of recursive globbing include:
</para>
<para>
<programlisting>   /dir/*.py  - match all python files in /dir and subdirectories
</programlisting>
</para>
<para>MAKE_DIRECTORY will create the given directories, also if their parent directories don't exist yet
</para>
<para>RENAME moves a file or directory within a filesystem, replacing the destination atomically.
</para>
<para>REMOVE will remove the given files, also in subdirectories
</para>
<para>REMOVE_RECURSE will remove the given files and directories, also non-empty directories
</para>
<para>RELATIVE_PATH will determine relative path from directory to the given file.
</para>
<para>TO_CMAKE_PATH will convert path into a cmake style path with unix /.  The input can be a single path or a system path like "$ENV{PATH}".  Note the double quotes around the ENV call TO_CMAKE_PATH only takes  one argument. This command will also convert the native list delimiters for a list of paths like the PATH environment variable.
</para>
<para>TO_NATIVE_PATH works just like TO_CMAKE_PATH, but will convert from  a cmake style path into the native path style \ for windows and / for UNIX.
</para>
<para>DOWNLOAD will download the given URL to the given file. If LOG var is specified a log of the download will be put in var. If STATUS var is specified the status of the operation will be put in var. The status is returned in a 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. If TIMEOUT time is specified, the operation will timeout after time seconds, time should be specified as an integer. The INACTIVITY_TIMEOUT specifies an integer number of seconds of inactivity after which the operation should terminate. If EXPECTED_HASH ALGO=value is specified, the operation will verify that the downloaded file's actual 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. ("EXPECTED_MD5 sum" is short-hand for "EXPECTED_HASH MD5=sum".) If SHOW_PROGRESS is specified, progress information will be printed as status messages until the operation is complete. For https URLs CMake must be built with OpenSSL.  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.  Set TLS_CAINFO to specify a custom Certificate Authority file.  If either TLS option is not given CMake will check variables CMAKE_TLS_VERIFY and CMAKE_TLS_CAINFO, respectively.
</para>
<para>UPLOAD will upload the given file to the given URL. If LOG var is specified a log of the upload will be put in var. If STATUS var is specified the status of the operation will be put in var. The status is returned in a 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. If TIMEOUT time is specified, the operation will timeout after time seconds, time should be specified as an integer. The INACTIVITY_TIMEOUT specifies an integer number of seconds of inactivity after which the operation should terminate. If SHOW_PROGRESS is specified, progress information will be printed as status messages until the operation is complete.
</para>
<para>The file() command also provides COPY and INSTALL signatures:
</para>
<para>
<programlisting>  file(&lt;COPY|INSTALL&gt; files... DESTINATION &lt;dir&gt;
       [FILE_PERMISSIONS permissions...]
       [DIRECTORY_PERMISSIONS permissions...]
       [NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS]
       [FILES_MATCHING]
       [[PATTERN &lt;pattern&gt; | REGEX &lt;regex&gt;]
        [EXCLUDE] [PERMISSIONS permissions...]] [...])
</programlisting>
</para>
<para>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, PATTERN, REGEX, and EXCLUDE options.  
</para>
<para>The INSTALL signature differs slightly from COPY: it prints status messages, and NO_SOURCE_PERMISSIONS is default.  Installation scripts generated by the install() command use this signature (with some undocumented options for internal use).</para>
</sect2>
<sect2 id="ctest.command.find_file">
<title>find_file</title>
<abstract>
<para>Find the full path to a file.</para>
</abstract>
<para>
<programlisting>   find_file(&lt;VAR&gt; name1 [path1 path2 ...])
</programlisting>
</para>
<para>This is the short-hand signature for the command that is sufficient in many cases.  It is the same as find_file(&lt;VAR&gt; name1 [PATHS path1 path2 ...])
</para>
<para>
<programlisting>   find_file(
             &lt;VAR&gt;
             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]
            )
</programlisting>
</para>
<para>This command is used to find a full path to named file. A cache entry named by &lt;VAR&gt; 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 &lt;VAR&gt;-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.
</para>
<para>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:
</para>
<para>1. Search paths specified in cmake-specific cache variables.  These are intended to be used on the command line with a -DVAR=value.  This can be skipped if NO_CMAKE_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/include for each &lt;prefix&gt; in CMAKE_PREFIX_PATH
   CMAKE_INCLUDE_PATH
   CMAKE_FRAMEWORK_PATH
</programlisting>
</para>
<para>2. Search paths specified in cmake-specific environment variables.  These are intended to be set in the user's shell configuration.  This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/include for each &lt;prefix&gt; in CMAKE_PREFIX_PATH
   CMAKE_INCLUDE_PATH
   CMAKE_FRAMEWORK_PATH
</programlisting>
</para>
<para>3. Search the paths specified by the HINTS option.  These should be paths computed by system introspection, such as a hint provided by the location of another item already found.  Hard-coded guesses should be specified with the PATHS option.
</para>
<para>4. Search the standard system environment variables. This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.
</para>
<para>
<programlisting>   PATH
   INCLUDE
</programlisting>
</para>
<para>5. Search cmake variables defined in the Platform files for the current system.  This can be skipped if NO_CMAKE_SYSTEM_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/include for each &lt;prefix&gt; in CMAKE_SYSTEM_PREFIX_PATH
   CMAKE_SYSTEM_INCLUDE_PATH
   CMAKE_SYSTEM_FRAMEWORK_PATH
</programlisting>
</para>
<para>6. Search the paths specified by the PATHS option or in the short-hand version of the command.  These are typically hard-coded guesses.
</para>
<para>On Darwin or systems supporting OS X Frameworks, the cmake variable    CMAKE_FIND_FRAMEWORK can be set to empty or one of the following:
</para>
<para>
<programlisting>   "FIRST"  - Try to find frameworks before standard
              libraries or headers. This is the default on Darwin.
   "LAST"   - Try to find frameworks after standard
              libraries or headers.
   "ONLY"   - Only try to find frameworks.
   "NEVER" - Never try to find frameworks.
</programlisting>
</para>
<para>On Darwin or systems supporting OS X Application Bundles, the cmake variable CMAKE_FIND_APPBUNDLE can be set to empty or one of the following:
</para>
<para>
<programlisting>   "FIRST"  - Try to find application bundles before standard
              programs. This is the default on Darwin.
   "LAST"   - Try to find application bundles after standard
              programs.
   "ONLY"   - Only try to find application bundles.
   "NEVER" - Never try to find application bundles.
</programlisting>
</para>
<para>The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more directories to be prepended to all other search directories. This effectively "re-roots" the entire search under given locations. By default it is empty. It is especially useful when cross-compiling to point to the root directory of the target environment and CMake will search there too. By default at first the directories listed in CMAKE_FIND_ROOT_PATH and then the non-rooted directories will be searched. The default behavior can be adjusted by setting CMAKE_FIND_ROOT_PATH_MODE_INCLUDE.  This behavior can be manually overridden on a per-call basis. By using CMAKE_FIND_ROOT_PATH_BOTH the search order will be as described above. If NO_CMAKE_FIND_ROOT_PATH is used then CMAKE_FIND_ROOT_PATH will not be used. If ONLY_CMAKE_FIND_ROOT_PATH is used then only the re-rooted directories will be searched.
</para>
<para>The default search order is designed to be most-specific to least-specific for common use cases.  Projects may override the order by simply calling the command multiple times and using the NO_* options:
</para>
<para>
<programlisting>   find_file(&lt;VAR&gt; NAMES name PATHS paths... NO_DEFAULT_PATH)
   find_file(&lt;VAR&gt; NAMES name)
</programlisting>
</para>
<para>Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.</para>
</sect2>
<sect2 id="ctest.command.find_library">
<title>find_library</title>
<abstract>
<para>Find a library.</para>
</abstract>
<para>
<programlisting>   find_library(&lt;VAR&gt; name1 [path1 path2 ...])
</programlisting>
</para>
<para>This is the short-hand signature for the command that is sufficient in many cases.  It is the same as find_library(&lt;VAR&gt; name1 [PATHS path1 path2 ...])
</para>
<para>
<programlisting>   find_library(
             &lt;VAR&gt;
             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]
            )
</programlisting>
</para>
<para>This command is used to find a library. A cache entry named by &lt;VAR&gt; 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 &lt;VAR&gt;-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.
</para>
<para>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:
</para>
<para>1. Search paths specified in cmake-specific cache variables.  These are intended to be used on the command line with a -DVAR=value.  This can be skipped if NO_CMAKE_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/lib/&lt;arch&gt; if CMAKE_LIBRARY_ARCHITECTURE is set, and
   &lt;prefix&gt;/lib for each &lt;prefix&gt; in CMAKE_PREFIX_PATH
   CMAKE_LIBRARY_PATH
   CMAKE_FRAMEWORK_PATH
</programlisting>
</para>
<para>2. Search paths specified in cmake-specific environment variables.  These are intended to be set in the user's shell configuration.  This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/lib/&lt;arch&gt; if CMAKE_LIBRARY_ARCHITECTURE is set, and
   &lt;prefix&gt;/lib for each &lt;prefix&gt; in CMAKE_PREFIX_PATH
   CMAKE_LIBRARY_PATH
   CMAKE_FRAMEWORK_PATH
</programlisting>
</para>
<para>3. Search the paths specified by the HINTS option.  These should be paths computed by system introspection, such as a hint provided by the location of another item already found.  Hard-coded guesses should be specified with the PATHS option.
</para>
<para>4. Search the standard system environment variables. This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.
</para>
<para>
<programlisting>   PATH
   LIB
</programlisting>
</para>
<para>5. Search cmake variables defined in the Platform files for the current system.  This can be skipped if NO_CMAKE_SYSTEM_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/lib/&lt;arch&gt; if CMAKE_LIBRARY_ARCHITECTURE is set, and
   &lt;prefix&gt;/lib for each &lt;prefix&gt; in CMAKE_SYSTEM_PREFIX_PATH
   CMAKE_SYSTEM_LIBRARY_PATH
   CMAKE_SYSTEM_FRAMEWORK_PATH
</programlisting>
</para>
<para>6. Search the paths specified by the PATHS option or in the short-hand version of the command.  These are typically hard-coded guesses.
</para>
<para>On Darwin or systems supporting OS X Frameworks, the cmake variable    CMAKE_FIND_FRAMEWORK can be set to empty or one of the following:
</para>
<para>
<programlisting>   "FIRST"  - Try to find frameworks before standard
              libraries or headers. This is the default on Darwin.
   "LAST"   - Try to find frameworks after standard
              libraries or headers.
   "ONLY"   - Only try to find frameworks.
   "NEVER" - Never try to find frameworks.
</programlisting>
</para>
<para>On Darwin or systems supporting OS X Application Bundles, the cmake variable CMAKE_FIND_APPBUNDLE can be set to empty or one of the following:
</para>
<para>
<programlisting>   "FIRST"  - Try to find application bundles before standard
              programs. This is the default on Darwin.
   "LAST"   - Try to find application bundles after standard
              programs.
   "ONLY"   - Only try to find application bundles.
   "NEVER" - Never try to find application bundles.
</programlisting>
</para>
<para>The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more directories to be prepended to all other search directories. This effectively "re-roots" the entire search under given locations. By default it is empty. It is especially useful when cross-compiling to point to the root directory of the target environment and CMake will search there too. By default at first the directories listed in CMAKE_FIND_ROOT_PATH and then the non-rooted directories will be searched. The default behavior can be adjusted by setting CMAKE_FIND_ROOT_PATH_MODE_LIBRARY.  This behavior can be manually overridden on a per-call basis. By using CMAKE_FIND_ROOT_PATH_BOTH the search order will be as described above. If NO_CMAKE_FIND_ROOT_PATH is used then CMAKE_FIND_ROOT_PATH will not be used. If ONLY_CMAKE_FIND_ROOT_PATH is used then only the re-rooted directories will be searched.
</para>
<para>The default search order is designed to be most-specific to least-specific for common use cases.  Projects may override the order by simply calling the command multiple times and using the NO_* options:
</para>
<para>
<programlisting>   find_library(&lt;VAR&gt; NAMES name PATHS paths... NO_DEFAULT_PATH)
   find_library(&lt;VAR&gt; NAMES name)
</programlisting>
</para>
<para>Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.
</para>
<para>If the library found is a framework, then VAR will be set to the full path to the framework &lt;fullPath&gt;/A.framework. When a full path to a framework is used as a library, CMake will use a -framework A, and a -F&lt;fullPath&gt; to link the framework to the target.
</para>
<para>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.</para>
</sect2>
<sect2 id="ctest.command.find_package">
<title>find_package</title>
<abstract>
<para>Load settings for an external project.</para>
</abstract>
<para>
<programlisting>  find_package(&lt;package&gt; [version] [EXACT] [QUIET] [MODULE]
               [REQUIRED] [[COMPONENTS] [components...]]
               [OPTIONAL_COMPONENTS components...]
               [NO_POLICY_SCOPE])
</programlisting>
</para>
<para>Finds and loads settings from an external project.  &lt;package&gt;_FOUND will be set to indicate whether the package was found.  When the package is found package-specific information is provided through variables 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.
</para>
<para>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.
</para>
<para>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).
</para>
<para>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.
</para>
<para>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&lt;package&gt;.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.
</para>
<para>The complete Config mode command signature is:
</para>
<para>
<programlisting>  find_package(&lt;package&gt; [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]
               [NO_CMAKE_SYSTEM_PATH]
               [NO_CMAKE_SYSTEM_PACKAGE_REGISTRY]
               [CMAKE_FIND_ROOT_PATH_BOTH |
                ONLY_CMAKE_FIND_ROOT_PATH |
                NO_CMAKE_FIND_ROOT_PATH])
</programlisting>
</para>
<para>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.  
</para>
<para>Config mode attempts to locate a configuration file provided by the package to be found.  A cache entry called &lt;package&gt;_DIR is created to hold the directory containing the file.  By default the command searches for a package with the name &lt;package&gt;.  If the NAMES option is given the names following it are used instead of &lt;package&gt;.  The command searches for a file called "&lt;name&gt;Config.cmake" or "&lt;lower-case-name&gt;-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 &lt;package&gt;_CONFIG.
</para>
<para>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 &lt;package&gt;_CONSIDERED_CONFIGS, the associated versions in &lt;package&gt;_CONSIDERED_VERSIONS. 
</para>
<para>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 &lt;package&gt;_DIR has been set to a directory not containing a configuration file CMake will ignore it and search from scratch.
</para>
<para>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 "&lt;config-file&gt;.cmake" the corresponding version file is located next to it and named either "&lt;config-file&gt;-version.cmake" or "&lt;config-file&gt;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 macro write_basic_package_version_file(), see its documentation for more details.  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:
</para>
<para>
<programlisting>  PACKAGE_FIND_NAME          = the &lt;package&gt; 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
</programlisting>
</para>
<para>The version file checks whether it satisfies the requested version and sets these variables:
</para>
<para>
<programlisting>  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
</programlisting>
</para>
<para>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:
</para>
<para>
<programlisting>  &lt;package&gt;_VERSION       = full provided version string
  &lt;package&gt;_VERSION_MAJOR = major version if provided, else 0
  &lt;package&gt;_VERSION_MINOR = minor version if provided, else 0
  &lt;package&gt;_VERSION_PATCH = patch version if provided, else 0
  &lt;package&gt;_VERSION_TWEAK = tweak version if provided, else 0
  &lt;package&gt;_VERSION_COUNT = number of version components, 0 to 4
</programlisting>
</para>
<para>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.
</para>
<para>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
</para>
<para>
<programlisting>  find_package(&lt;package&gt; [major[.minor]] [EXACT] [REQUIRED|QUIET])
</programlisting>
</para>
<para>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.
</para>
<para>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.
</para>
<para>
<programlisting>  &lt;prefix&gt;/                                               (W)
  &lt;prefix&gt;/(cmake|CMake)/                                 (W)
  &lt;prefix&gt;/&lt;name&gt;*/                                       (W)
  &lt;prefix&gt;/&lt;name&gt;*/(cmake|CMake)/                         (W)
  &lt;prefix&gt;/(lib/&lt;arch&gt;|lib|share)/cmake/&lt;name&gt;*/          (U)
  &lt;prefix&gt;/(lib/&lt;arch&gt;|lib|share)/&lt;name&gt;*/                (U)
  &lt;prefix&gt;/(lib/&lt;arch&gt;|lib|share)/&lt;name&gt;*/(cmake|CMake)/  (U)
</programlisting>
</para>
<para>On systems supporting OS X Frameworks and Application Bundles the following directories are searched for frameworks or bundles containing a configuration file:
</para>
<para>
<programlisting>  &lt;prefix&gt;/&lt;name&gt;.framework/Resources/                    (A)
  &lt;prefix&gt;/&lt;name&gt;.framework/Resources/CMake/              (A)
  &lt;prefix&gt;/&lt;name&gt;.framework/Versions/*/Resources/         (A)
  &lt;prefix&gt;/&lt;name&gt;.framework/Versions/*/Resources/CMake/   (A)
  &lt;prefix&gt;/&lt;name&gt;.app/Contents/Resources/                 (A)
  &lt;prefix&gt;/&lt;name&gt;.app/Contents/Resources/CMake/           (A)
</programlisting>
</para>
<para>In all cases the &lt;name&gt; is treated as case-insensitive and corresponds to any of the names specified (&lt;package&gt; or names given by NAMES).  Paths with lib/&lt;arch&gt; are enabled if CMAKE_LIBRARY_ARCHITECTURE is set.  If PATH_SUFFIXES is specified the suffixes are appended to each (W) or (U) directory entry one-by-one.
</para>
<para>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's 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.
</para>
<para>The set of installation prefixes is constructed using the following steps.  If NO_DEFAULT_PATH is specified all NO_* options are enabled.
</para>
<para>1. Search paths specified in cmake-specific cache variables.  These are intended to be used on the command line with a -DVAR=value.  This can be skipped if NO_CMAKE_PATH is passed.
</para>
<para>
<programlisting>   CMAKE_PREFIX_PATH
   CMAKE_FRAMEWORK_PATH
   CMAKE_APPBUNDLE_PATH
</programlisting>
</para>
<para>2. Search paths specified in cmake-specific environment variables.  These are intended to be set in the user's shell configuration.  This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.
</para>
<para>
<programlisting>   &lt;package&gt;_DIR
   CMAKE_PREFIX_PATH
   CMAKE_FRAMEWORK_PATH
   CMAKE_APPBUNDLE_PATH
</programlisting>
</para>
<para>3. Search paths specified by the HINTS option.  These should be paths computed by system introspection, such as a hint provided by the location of another item already found.  Hard-coded guesses should be specified with the PATHS option.
</para>
<para>4. Search the standard system environment variables. This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is passed.  Path entries ending in "/bin" or "/sbin" are automatically converted to their parent directories.
</para>
<para>
<programlisting>   PATH
</programlisting>
</para>
<para>5. Search project build trees recently configured in a CMake GUI.  This can be skipped if NO_CMAKE_BUILDS_PATH is passed.  It is intended for the case when a user is building multiple dependent projects one after another.
</para>
<para>6. Search paths stored in the CMake user package registry.  This can be skipped if NO_CMAKE_PACKAGE_REGISTRY is passed.  On Windows a &lt;package&gt; may appear under registry key
</para>
<para>
<programlisting>  HKEY_CURRENT_USER\Software\Kitware\CMake\Packages\&lt;package&gt;
</programlisting>
</para>
<para>as a REG_SZ value, with arbitrary name, that specifies the directory containing the package configuration file.  On UNIX platforms a &lt;package&gt; may appear under the directory
</para>
<para>
<programlisting>  ~/.cmake/packages/&lt;package&gt;
</programlisting>
</para>
<para>as a file, with arbitrary name, whose content specifies the directory containing the package configuration file.  See the export(PACKAGE) command to create user package registry entries for project build trees.
</para>
<para>7. Search cmake variables defined in the Platform files for the current system.  This can be skipped if NO_CMAKE_SYSTEM_PATH is passed.
</para>
<para>
<programlisting>   CMAKE_SYSTEM_PREFIX_PATH
   CMAKE_SYSTEM_FRAMEWORK_PATH
   CMAKE_SYSTEM_APPBUNDLE_PATH
</programlisting>
</para>
<para>8. Search paths stored in the CMake system package registry.  This can be skipped if NO_CMAKE_SYSTEM_PACKAGE_REGISTRY is passed.  On Windows a &lt;package&gt; may appear under registry key
</para>
<para>
<programlisting>  HKEY_LOCAL_MACHINE\Software\Kitware\CMake\Packages\&lt;package&gt;
</programlisting>
</para>
<para>as a REG_SZ value, with arbitrary name, that specifies the directory containing the package configuration file.  There is no system package registry on non-Windows platforms.
</para>
<para>9. Search paths specified by the PATHS option.  These are typically hard-coded guesses.
</para>
<para>On Darwin or systems supporting OS X Frameworks, the cmake variable    CMAKE_FIND_FRAMEWORK can be set to empty or one of the following:
</para>
<para>
<programlisting>   "FIRST"  - Try to find frameworks before standard
              libraries or headers. This is the default on Darwin.
   "LAST"   - Try to find frameworks after standard
              libraries or headers.
   "ONLY"   - Only try to find frameworks.
   "NEVER" - Never try to find frameworks.
</programlisting>
</para>
<para>On Darwin or systems supporting OS X Application Bundles, the cmake variable CMAKE_FIND_APPBUNDLE can be set to empty or one of the following:
</para>
<para>
<programlisting>   "FIRST"  - Try to find application bundles before standard
              programs. This is the default on Darwin.
   "LAST"   - Try to find application bundles after standard
              programs.
   "ONLY"   - Only try to find application bundles.
   "NEVER" - Never try to find application bundles.
</programlisting>
</para>
<para>The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more directories to be prepended to all other search directories. This effectively "re-roots" the entire search under given locations. By default it is empty. It is especially useful when cross-compiling to point to the root directory of the target environment and CMake will search there too. By default at first the directories listed in CMAKE_FIND_ROOT_PATH and then the non-rooted directories will be searched. The default behavior can be adjusted by setting CMAKE_FIND_ROOT_PATH_MODE_PACKAGE.  This behavior can be manually overridden on a per-call basis. By using CMAKE_FIND_ROOT_PATH_BOTH the search order will be as described above. If NO_CMAKE_FIND_ROOT_PATH is used then CMAKE_FIND_ROOT_PATH will not be used. If ONLY_CMAKE_FIND_ROOT_PATH is used then only the re-rooted directories will be searched.
</para>
<para>The default search order is designed to be most-specific to least-specific for common use cases.  Projects may override the order by simply calling the command multiple times and using the NO_* options:
</para>
<para>
<programlisting>   find_package(&lt;package&gt; PATHS paths... NO_DEFAULT_PATH)
   find_package(&lt;package&gt;)
</programlisting>
</para>
<para>Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.
</para>
<para>Every non-REQUIRED find_package() call can be disabled by setting the variable CMAKE_DISABLE_FIND_PACKAGE_&lt;package&gt; to TRUE. See the documentation for the CMAKE_DISABLE_FIND_PACKAGE_&lt;package&gt; variable for more information.
</para>
<para>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):
</para>
<para>
<programlisting> &lt;package&gt;_FIND_REQUIRED      = true if REQUIRED option was given
 &lt;package&gt;_FIND_QUIETLY       = true if QUIET option was given
 &lt;package&gt;_FIND_VERSION       = full requested version string
 &lt;package&gt;_FIND_VERSION_MAJOR = major version if requested, else 0
 &lt;package&gt;_FIND_VERSION_MINOR = minor version if requested, else 0
 &lt;package&gt;_FIND_VERSION_PATCH = patch version if requested, else 0
 &lt;package&gt;_FIND_VERSION_TWEAK = tweak version if requested, else 0
 &lt;package&gt;_FIND_VERSION_COUNT = number of version components, 0 to 4
 &lt;package&gt;_FIND_VERSION_EXACT = true if EXACT option was given
 &lt;package&gt;_FIND_COMPONENTS    = list of requested components
 &lt;package&gt;_FIND_REQUIRED_&lt;c&gt;  = true if component &lt;c&gt; is required
                                false if component &lt;c&gt; is optional
</programlisting>
</para>
<para>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 &lt;package&gt;_FOUND to false to tell find_package that component requirements are not satisfied.
</para>
<para>See the cmake_policy() command documentation for discussion of the NO_POLICY_SCOPE option.</para>
</sect2>
<sect2 id="ctest.command.find_path">
<title>find_path</title>
<abstract>
<para>Find the directory containing a file.</para>
</abstract>
<para>
<programlisting>   find_path(&lt;VAR&gt; name1 [path1 path2 ...])
</programlisting>
</para>
<para>This is the short-hand signature for the command that is sufficient in many cases.  It is the same as find_path(&lt;VAR&gt; name1 [PATHS path1 path2 ...])
</para>
<para>
<programlisting>   find_path(
             &lt;VAR&gt;
             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]
            )
</programlisting>
</para>
<para>This command is used to find a directory containing the named file. A cache entry named by &lt;VAR&gt; 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 &lt;VAR&gt;-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.
</para>
<para>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:
</para>
<para>1. Search paths specified in cmake-specific cache variables.  These are intended to be used on the command line with a -DVAR=value.  This can be skipped if NO_CMAKE_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/include for each &lt;prefix&gt; in CMAKE_PREFIX_PATH
   CMAKE_INCLUDE_PATH
   CMAKE_FRAMEWORK_PATH
</programlisting>
</para>
<para>2. Search paths specified in cmake-specific environment variables.  These are intended to be set in the user's shell configuration.  This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/include for each &lt;prefix&gt; in CMAKE_PREFIX_PATH
   CMAKE_INCLUDE_PATH
   CMAKE_FRAMEWORK_PATH
</programlisting>
</para>
<para>3. Search the paths specified by the HINTS option.  These should be paths computed by system introspection, such as a hint provided by the location of another item already found.  Hard-coded guesses should be specified with the PATHS option.
</para>
<para>4. Search the standard system environment variables. This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.
</para>
<para>
<programlisting>   PATH
   INCLUDE
</programlisting>
</para>
<para>5. Search cmake variables defined in the Platform files for the current system.  This can be skipped if NO_CMAKE_SYSTEM_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/include for each &lt;prefix&gt; in CMAKE_SYSTEM_PREFIX_PATH
   CMAKE_SYSTEM_INCLUDE_PATH
   CMAKE_SYSTEM_FRAMEWORK_PATH
</programlisting>
</para>
<para>6. Search the paths specified by the PATHS option or in the short-hand version of the command.  These are typically hard-coded guesses.
</para>
<para>On Darwin or systems supporting OS X Frameworks, the cmake variable    CMAKE_FIND_FRAMEWORK can be set to empty or one of the following:
</para>
<para>
<programlisting>   "FIRST"  - Try to find frameworks before standard
              libraries or headers. This is the default on Darwin.
   "LAST"   - Try to find frameworks after standard
              libraries or headers.
   "ONLY"   - Only try to find frameworks.
   "NEVER" - Never try to find frameworks.
</programlisting>
</para>
<para>On Darwin or systems supporting OS X Application Bundles, the cmake variable CMAKE_FIND_APPBUNDLE can be set to empty or one of the following:
</para>
<para>
<programlisting>   "FIRST"  - Try to find application bundles before standard
              programs. This is the default on Darwin.
   "LAST"   - Try to find application bundles after standard
              programs.
   "ONLY"   - Only try to find application bundles.
   "NEVER" - Never try to find application bundles.
</programlisting>
</para>
<para>The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more directories to be prepended to all other search directories. This effectively "re-roots" the entire search under given locations. By default it is empty. It is especially useful when cross-compiling to point to the root directory of the target environment and CMake will search there too. By default at first the directories listed in CMAKE_FIND_ROOT_PATH and then the non-rooted directories will be searched. The default behavior can be adjusted by setting CMAKE_FIND_ROOT_PATH_MODE_INCLUDE.  This behavior can be manually overridden on a per-call basis. By using CMAKE_FIND_ROOT_PATH_BOTH the search order will be as described above. If NO_CMAKE_FIND_ROOT_PATH is used then CMAKE_FIND_ROOT_PATH will not be used. If ONLY_CMAKE_FIND_ROOT_PATH is used then only the re-rooted directories will be searched.
</para>
<para>The default search order is designed to be most-specific to least-specific for common use cases.  Projects may override the order by simply calling the command multiple times and using the NO_* options:
</para>
<para>
<programlisting>   find_path(&lt;VAR&gt; NAMES name PATHS paths... NO_DEFAULT_PATH)
   find_path(&lt;VAR&gt; NAMES name)
</programlisting>
</para>
<para>Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.
</para>
<para>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. </para>
</sect2>
<sect2 id="ctest.command.find_program">
<title>find_program</title>
<abstract>
<para>Find an executable program.</para>
</abstract>
<para>
<programlisting>   find_program(&lt;VAR&gt; name1 [path1 path2 ...])
</programlisting>
</para>
<para>This is the short-hand signature for the command that is sufficient in many cases.  It is the same as find_program(&lt;VAR&gt; name1 [PATHS path1 path2 ...])
</para>
<para>
<programlisting>   find_program(
             &lt;VAR&gt;
             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]
            )
</programlisting>
</para>
<para>This command is used to find a program. A cache entry named by &lt;VAR&gt; 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 &lt;VAR&gt;-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.
</para>
<para>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:
</para>
<para>1. Search paths specified in cmake-specific cache variables.  These are intended to be used on the command line with a -DVAR=value.  This can be skipped if NO_CMAKE_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/[s]bin for each &lt;prefix&gt; in CMAKE_PREFIX_PATH
   CMAKE_PROGRAM_PATH
   CMAKE_APPBUNDLE_PATH
</programlisting>
</para>
<para>2. Search paths specified in cmake-specific environment variables.  These are intended to be set in the user's shell configuration.  This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/[s]bin for each &lt;prefix&gt; in CMAKE_PREFIX_PATH
   CMAKE_PROGRAM_PATH
   CMAKE_APPBUNDLE_PATH
</programlisting>
</para>
<para>3. Search the paths specified by the HINTS option.  These should be paths computed by system introspection, such as a hint provided by the location of another item already found.  Hard-coded guesses should be specified with the PATHS option.
</para>
<para>4. Search the standard system environment variables. This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.
</para>
<para>
<programlisting>   PATH
   
</programlisting>
</para>
<para>5. Search cmake variables defined in the Platform files for the current system.  This can be skipped if NO_CMAKE_SYSTEM_PATH is passed.
</para>
<para>
<programlisting>   &lt;prefix&gt;/[s]bin for each &lt;prefix&gt; in CMAKE_SYSTEM_PREFIX_PATH
   CMAKE_SYSTEM_PROGRAM_PATH
   CMAKE_SYSTEM_APPBUNDLE_PATH
</programlisting>
</para>
<para>6. Search the paths specified by the PATHS option or in the short-hand version of the command.  These are typically hard-coded guesses.
</para>
<para>On Darwin or systems supporting OS X Frameworks, the cmake variable    CMAKE_FIND_FRAMEWORK can be set to empty or one of the following:
</para>
<para>
<programlisting>   "FIRST"  - Try to find frameworks before standard
              libraries or headers. This is the default on Darwin.
   "LAST"   - Try to find frameworks after standard
              libraries or headers.
   "ONLY"   - Only try to find frameworks.
   "NEVER" - Never try to find frameworks.
</programlisting>
</para>
<para>On Darwin or systems supporting OS X Application Bundles, the cmake variable CMAKE_FIND_APPBUNDLE can be set to empty or one of the following:
</para>
<para>
<programlisting>   "FIRST"  - Try to find application bundles before standard
              programs. This is the default on Darwin.
   "LAST"   - Try to find application bundles after standard
              programs.
   "ONLY"   - Only try to find application bundles.
   "NEVER" - Never try to find application bundles.
</programlisting>
</para>
<para>The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more directories to be prepended to all other search directories. This effectively "re-roots" the entire search under given locations. By default it is empty. It is especially useful when cross-compiling to point to the root directory of the target environment and CMake will search there too. By default at first the directories listed in CMAKE_FIND_ROOT_PATH and then the non-rooted directories will be searched. The default behavior can be adjusted by setting CMAKE_FIND_ROOT_PATH_MODE_PROGRAM.  This behavior can be manually overridden on a per-call basis. By using CMAKE_FIND_ROOT_PATH_BOTH the search order will be as described above. If NO_CMAKE_FIND_ROOT_PATH is used then CMAKE_FIND_ROOT_PATH will not be used. If ONLY_CMAKE_FIND_ROOT_PATH is used then only the re-rooted directories will be searched.
</para>
<para>The default search order is designed to be most-specific to least-specific for common use cases.  Projects may override the order by simply calling the command multiple times and using the NO_* options:
</para>
<para>
<programlisting>   find_program(&lt;VAR&gt; NAMES name PATHS paths... NO_DEFAULT_PATH)
   find_program(&lt;VAR&gt; NAMES name)
</programlisting>
</para>
<para>Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.</para>
</sect2>
<sect2 id="ctest.command.foreach">
<title>foreach</title>
<abstract>
<para>Evaluate a group of commands for each value in a list.</para>
</abstract>
<para>
<programlisting>  foreach(loop_var arg1 arg2 ...)
    COMMAND1(ARGS ...)
    COMMAND2(ARGS ...)
    ...
  endforeach(loop_var)
</programlisting>
</para>
<para>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.
</para>
<para>
<programlisting>  foreach(loop_var RANGE total)
  foreach(loop_var RANGE start stop [step])
</programlisting>
</para>
<para>Foreach can also iterate over a generated range of numbers. There are three types of this iteration:
</para>
<para>* When specifying single number, the range will have elements 0 to "total".
</para>
<para>* When specifying two numbers, the range will have elements from the first number to the second number.
</para>
<para>* The third optional number is the increment used to iterate from the first number to the second number.
</para>
<para>
<programlisting>  foreach(loop_var IN [LISTS [list1 [...]]]
                      [ITEMS [item1 [...]]])
</programlisting>
</para>
<para>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).  The ITEMS option ends argument parsing and includes all arguments following it in the iteration.</para>
</sect2>
<sect2 id="ctest.command.function">
<title>function</title>
<abstract>
<para>Start recording a function for later invocation as a command.</para>
</abstract>
<para>
<programlisting>  function(&lt;name&gt; [arg1 [arg2 [arg3 ...]]])
    COMMAND1(ARGS ...)
    COMMAND2(ARGS ...)
    ...
  endfunction(&lt;name&gt;)
</programlisting>
</para>
<para>Define a function named &lt;name&gt; 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 variable 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 functions with optional arguments. Additionally ARGV holds the list of all arguments given to the function and ARGN holds the list of argument past the last expected argument.
</para>
<para>See the cmake_policy() command documentation for the behavior of policies inside functions.</para>
</sect2>
<sect2 id="ctest.command.get_cmake_property">
<title>get_cmake_property</title>
<abstract>
<para>Get a property of the CMake instance.</para>
</abstract>
<para>
<programlisting>  get_cmake_property(VAR property)
</programlisting>
</para>
<para>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.
</para>
<para>See also the more general get_property() command.</para>
</sect2>
<sect2 id="ctest.command.get_directory_property">
<title>get_directory_property</title>
<abstract>
<para>Get a property of DIRECTORY scope.</para>
</abstract>
<para>
<programlisting>  get_directory_property(&lt;variable&gt; [DIRECTORY &lt;dir&gt;] &lt;prop-name&gt;)
</programlisting>
</para>
<para>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.
</para>
<para>
<programlisting>  get_directory_property(&lt;variable&gt; [DIRECTORY &lt;dir&gt;]
                         DEFINITION &lt;var-name&gt;)
</programlisting>
</para>
<para>Get a variable definition from a directory.  This form is useful to get a variable definition from another directory.
</para>
<para>See also the more general get_property() command.</para>
</sect2>
<sect2 id="ctest.command.get_filename_component">
<title>get_filename_component</title>
<abstract>
<para>Get a specific component of a full filename.</para>
</abstract>
<para>
<programlisting>  get_filename_component(&lt;VAR&gt; FileName
                         PATH|ABSOLUTE|NAME|EXT|NAME_WE|REALPATH
                         [CACHE])
</programlisting>
</para>
<para>Set &lt;VAR&gt; to be the path (PATH), file name (NAME), file extension (EXT), file name without extension (NAME_WE) of FileName, the full path (ABSOLUTE), or the full path with all symlinks resolved (REALPATH).  Note that the path is converted to Unix slashes format and has no trailing slashes. The longest file extension is always considered. If the optional CACHE argument is specified, the result variable is added to the cache.
</para>
<para>
<programlisting>  get_filename_component(&lt;VAR&gt; FileName
                         PROGRAM [PROGRAM_ARGS &lt;ARG_VAR&gt;]
                         [CACHE])
</programlisting>
</para>
<para>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 &lt;ARG_VAR&gt;.  This is used to separate a program name from its arguments in a command line string.</para>
</sect2>
<sect2 id="ctest.command.get_property">
<title>get_property</title>
<abstract>
<para>Get a property.</para>
</abstract>
<para>
<programlisting>  get_property(&lt;variable&gt;
               &lt;GLOBAL             |
                DIRECTORY [dir]    |
                TARGET    &lt;target&gt; |
                SOURCE    &lt;source&gt; |
                TEST      &lt;test&gt;   |
                CACHE     &lt;entry&gt;  |
                VARIABLE&gt;
               PROPERTY &lt;name&gt;
               [SET | DEFINED | BRIEF_DOCS | FULL_DOCS])
</programlisting>
</para>
<para>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:
</para>
<para>GLOBAL scope is unique and does not accept a name.
</para>
<para>DIRECTORY scope defaults to the current directory but another directory (already processed by CMake) may be named by full or relative path.
</para>
<para>TARGET scope must name one existing target.
</para>
<para>SOURCE scope must name one source file.
</para>
<para>TEST scope must name one existing test.
</para>
<para>CACHE scope must name one cache entry.
</para>
<para>VARIABLE scope is unique and does not accept a name.
</para>
<para>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 define_property. 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.</para>
</sect2>
<sect2 id="ctest.command.if">
<title>if</title>
<abstract>
<para>Conditionally execute a group of commands.</para>
</abstract>
<para>
<programlisting>  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)
</programlisting>
</para>
<para>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 operators such as EXISTS, COMMAND, and DEFINED. Then any EQUAL, LESS, GREATER, STRLESS, STRGREATER, STREQUAL, MATCHES will be evaluated. Then NOT operators and finally AND, OR operators will be evaluated. Possible expressions are:
</para>
<para>
<programlisting>  if(&lt;constant&gt;)
</programlisting>
</para>
<para>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, '', or ends in the suffix '-NOTFOUND'.  Named boolean constants are case-insensitive.  If the argument is not one of these constants, it is treated as a variable:
</para>
<para>
<programlisting>  if(&lt;variable&gt;)
</programlisting>
</para>
<para>True if the variable is defined to a value that is not a false constant.  False otherwise.  (Note macro arguments are not variables.)
</para>
<para>
<programlisting>  if(NOT &lt;expression&gt;)
</programlisting>
</para>
<para>True if the expression is not true.
</para>
<para>
<programlisting>  if(&lt;expr1&gt; AND &lt;expr2&gt;)
</programlisting>
</para>
<para>True if both expressions would be considered true individually.
</para>
<para>
<programlisting>  if(&lt;expr1&gt; OR &lt;expr2&gt;)
</programlisting>
</para>
<para>True if either expression would be considered true individually.
</para>
<para>
<programlisting>  if(COMMAND command-name)
</programlisting>
</para>
<para>True if the given name is a command, macro or function that can be invoked.
</para>
<para>
<programlisting>  if(POLICY policy-id)
</programlisting>
</para>
<para>True if the given name is an existing policy (of the form CMP&lt;NNNN&gt;).
</para>
<para>
<programlisting>  if(TARGET target-name)
</programlisting>
</para>
<para>True if the given name is an existing target, built or imported.
</para>
<para>
<programlisting>  if(EXISTS file-name)
  if(EXISTS directory-name)
</programlisting>
</para>
<para>True if the named file or directory exists.  Behavior is well-defined only for full paths.
</para>
<para>
<programlisting>  if(file1 IS_NEWER_THAN file2)
</programlisting>
</para>
<para>True if file1 is newer than file2 or if one of the two files doesn't 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.
</para>
<para>
<programlisting>  if(IS_DIRECTORY directory-name)
</programlisting>
</para>
<para>True if the given name is a directory.  Behavior is well-defined only for full paths.
</para>
<para>
<programlisting>  if(IS_SYMLINK file-name)
</programlisting>
</para>
<para>True if the given name is a symbolic link.  Behavior is well-defined only for full paths.
</para>
<para>
<programlisting>  if(IS_ABSOLUTE path)
</programlisting>
</para>
<para>True if the given path is an absolute path.
</para>
<para>
<programlisting>  if(&lt;variable|string&gt; MATCHES regex)
</programlisting>
</para>
<para>True if the given string or variable's value matches the given regular expression.
</para>
<para>
<programlisting>  if(&lt;variable|string&gt; LESS &lt;variable|string&gt;)
  if(&lt;variable|string&gt; GREATER &lt;variable|string&gt;)
  if(&lt;variable|string&gt; EQUAL &lt;variable|string&gt;)
</programlisting>
</para>
<para>True if the given string or variable's value is a valid number and the inequality or equality is true.
</para>
<para>
<programlisting>  if(&lt;variable|string&gt; STRLESS &lt;variable|string&gt;)
  if(&lt;variable|string&gt; STRGREATER &lt;variable|string&gt;)
  if(&lt;variable|string&gt; STREQUAL &lt;variable|string&gt;)
</programlisting>
</para>
<para>True if the given string or variable's value is lexicographically less (or greater, or equal) than the string or variable on the right.
</para>
<para>
<programlisting>  if(&lt;variable|string&gt; VERSION_LESS &lt;variable|string&gt;)
  if(&lt;variable|string&gt; VERSION_EQUAL &lt;variable|string&gt;)
  if(&lt;variable|string&gt; VERSION_GREATER &lt;variable|string&gt;)
</programlisting>
</para>
<para>Component-wise integer version number comparison (version format is major[.minor[.patch[.tweak]]]).
</para>
<para>
<programlisting>  if(DEFINED &lt;variable&gt;)
</programlisting>
</para>
<para>True if the given variable is defined. It does not matter if the variable is true or false just if it has been set.
</para>
<para>
<programlisting>  if((expression) AND (expression OR (expression)))
</programlisting>
</para>
<para>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.
</para>
<para>The if command was written very early in CMake's 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
</para>
<para>
<programlisting>  set(var1 OFF)
  set(var2 "var1")
  if(${var2})
</programlisting>
</para>
<para>appears to the if command as
</para>
<para>
<programlisting>  if(var1)
</programlisting>
</para>
<para>and is evaluated according to the if(&lt;variable&gt;) case documented above.  The result is OFF which is false.  However, if we remove the ${} from the example then the command sees
</para>
<para>
<programlisting>  if(var2)
</programlisting>
</para>
<para>which is true because var2 is defined to "var1" which is not a false constant.
</para>
<para>Automatic evaluation applies in the other cases whenever the above-documented signature accepts &lt;variable|string&gt;:
</para>
<para>1) The left hand argument to MATCHES is first checked to see if it is a defined variable, if so the variable's value is used, otherwise the original value is used. 
</para>
<para>2) If the left hand argument to MATCHES is missing it returns false without error 
</para>
<para>3) Both left and right hand arguments to LESS GREATER EQUAL are independently tested to see if they are defined variables, if so their defined values are used otherwise the original value is used. 
</para>
<para>4) Both left and right hand arguments to STRLESS STREQUAL STRGREATER are independently tested to see if they are defined variables, if so their defined values are used otherwise the original value is used. 
</para>
<para>5) Both left and right hand argumemnts to VERSION_LESS VERSION_EQUAL VERSION_GREATER are independently tested to see if they are defined variables, if so their defined values are used otherwise the original value is used. 
</para>
<para>6) The right hand argument to NOT is tested to see if it is a boolean constant, if so the value is used, otherwise it is assumed to be a variable and it is dereferenced. 
</para>
<para>7) The left and right hand arguments to AND OR are independently tested to see if they are boolean constants, if so they are used as such, otherwise they are assumed to be variables and are dereferenced. 
</para>
</sect2>
<sect2 id="ctest.command.include">
<title>include</title>
<abstract>
<para>Read CMake listfile code from the given file.</para>
</abstract>
<para>
<programlisting>  include(&lt;file|module&gt; [OPTIONAL] [RESULT_VARIABLE &lt;VAR&gt;]
                        [NO_POLICY_SCOPE])
</programlisting>
</para>
<para>Reads CMake listfile code from the given file.  Commands in the file are processed immediately as if they were written in place of the include command.  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.
</para>
<para>If a module is specified instead of a file, the file with name &lt;modulename&gt;.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.
</para>
<para>See the cmake_policy() command documentation for discussion of the NO_POLICY_SCOPE option.</para>
</sect2>
<sect2 id="ctest.command.list">
<title>list</title>
<abstract>
<para>List operations.</para>
</abstract>
<para>
<programlisting>  list(LENGTH &lt;list&gt; &lt;output variable&gt;)
  list(GET &lt;list&gt; &lt;element index&gt; [&lt;element index&gt; ...]
       &lt;output variable&gt;)
  list(APPEND &lt;list&gt; &lt;element&gt; [&lt;element&gt; ...])
  list(FIND &lt;list&gt; &lt;value&gt; &lt;output variable&gt;)
  list(INSERT &lt;list&gt; &lt;element_index&gt; &lt;element&gt; [&lt;element&gt; ...])
  list(REMOVE_ITEM &lt;list&gt; &lt;value&gt; [&lt;value&gt; ...])
  list(REMOVE_AT &lt;list&gt; &lt;index&gt; [&lt;index&gt; ...])
  list(REMOVE_DUPLICATES &lt;list&gt;)
  list(REVERSE &lt;list&gt;)
  list(SORT &lt;list&gt;)
</programlisting>
</para>
<para>LENGTH will return a given list's length.
</para>
<para>GET will return list of elements specified by indices from the list.
</para>
<para>APPEND will append elements to the list.
</para>
<para>FIND will return the index of the element specified in the list or -1 if it wasn't found.
</para>
<para>INSERT will insert elements to the list to the specified location.
</para>
<para>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.
</para>
<para>REMOVE_DUPLICATES will remove duplicated items in the list.
</para>
<para>REVERSE reverses the contents of the list in-place.
</para>
<para>SORT sorts the list in-place alphabetically.
</para>
<para>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.
</para>
<para>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.
</para>
<para>When specifying index values, if &lt;element index&gt; is 0 or greater, it is indexed from the beginning of the list, with 0 representing the first list element. If &lt;element index&gt; 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.
</para>
</sect2>
<sect2 id="ctest.command.macro">
<title>macro</title>
<abstract>
<para>Start recording a macro for later invocation as a command.</para>
</abstract>
<para>
<programlisting>  macro(&lt;name&gt; [arg1 [arg2 [arg3 ...]]])
    COMMAND1(ARGS ...)
    COMMAND2(ARGS ...)
    ...
  endmacro(&lt;name&gt;)
</programlisting>
</para>
<para>Define a macro named &lt;name&gt; 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 argument past the last expected argument. Note that the parameters to a macro and values such as ARGN are not variables in the usual CMake sense. They are string replacements much like the c preprocessor would do with a macro. If you want true CMake variables you should look at the function command.
</para>
<para>See the cmake_policy() command documentation for the behavior of policies inside macros.</para>
</sect2>
<sect2 id="ctest.command.make_directory">
<title>make_directory</title>
<abstract>
<para>Deprecated. Use the file(MAKE_DIRECTORY ) command instead.</para>
</abstract>
<para>
<programlisting>  make_directory(directory)
</programlisting>
</para>
<para>Creates the specified directory.  Full paths should be given.  Any parent directories that do not exist will also be created.  Use with care.</para>
</sect2>
<sect2 id="ctest.command.mark_as_advanced">
<title>mark_as_advanced</title>
<abstract>
<para>Mark cmake cached variables as advanced.</para>
</abstract>
<para>
<programlisting>  mark_as_advanced([CLEAR|FORCE] VAR VAR2 VAR...)
</programlisting>
</para>
<para>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.
</para>
<para>It does nothing in script mode.</para>
</sect2>
<sect2 id="ctest.command.math">
<title>math</title>
<abstract>
<para>Mathematical expressions.</para>
</abstract>
<para>
<programlisting>  math(EXPR &lt;output variable&gt; &lt;math expression&gt;)
</programlisting>
</para>
<para>EXPR evaluates mathematical expression and return result in the output variable. Example mathematical expression is '5 * ( 10 + 13 )'.  Supported operators are + - * / % | &amp; ^ ~ &lt;&lt; &gt;&gt; * / %.  They have the same meaning  as they do in c code.</para>
</sect2>
<sect2 id="ctest.command.message">
<title>message</title>
<abstract>
<para>Display a message to the user.</para>
</abstract>
<para>
<programlisting>  message([STATUS|WARNING|AUTHOR_WARNING|FATAL_ERROR|SEND_ERROR]
          "message to display" ...)
</programlisting>
</para>
<para>The optional keyword determines the type of message:
</para>
<para>
<programlisting>  (none)         = Important information
  STATUS         = Incidental information
  WARNING        = CMake Warning, continue processing
  AUTHOR_WARNING = CMake Warning (dev), continue processing
  SEND_ERROR     = CMake Error, continue but skip generation
  FATAL_ERROR    = CMake Error, stop all processing
</programlisting>
</para>
<para>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.
</para>
<para>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.</para>
</sect2>
<sect2 id="ctest.command.option">
<title>option</title>
<abstract>
<para>Provides an option that the user can optionally select.</para>
</abstract>
<para>
<programlisting>  option(&lt;option_variable&gt; "help string describing option"
         [initial value])
</programlisting>
</para>
<para>Provide an option for the user to select as ON or OFF.  If no initial value is provided, OFF is used.
</para>
<para>If you have options that depend on the values of other options, see the module help for CMakeDependentOption.</para>
</sect2>
<sect2 id="ctest.command.remove">
<title>remove</title>
<abstract>
<para>Deprecated. Use the list(REMOVE_ITEM ) command instead.</para>
</abstract>
<para>
<programlisting>  remove(VAR VALUE VALUE ...)
</programlisting>
</para>
<para>Removes VALUE from the variable VAR.  This is typically used to remove entries from a vector (e.g. semicolon separated list).  VALUE is expanded.</para>
</sect2>
<sect2 id="ctest.command.return">
<title>return</title>
<abstract>
<para>Return from a file, directory or function.</para>
</abstract>
<para>
<programlisting>  return()
</programlisting>
</para>
<para>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.</para>
</sect2>
<sect2 id="ctest.command.separate_arguments">
<title>separate_arguments</title>
<abstract>
<para>Parse space-separated arguments into a semicolon-separated list.</para>
</abstract>
<para>
<programlisting>  separate_arguments(&lt;var&gt; &lt;UNIX|WINDOWS&gt;_COMMAND "&lt;args&gt;")
</programlisting>
</para>
<para>Parses a unix- or windows-style command-line string "&lt;args&gt;" and stores a semicolon-separated list of the arguments in &lt;var&gt;.  The entire command line must be given in one "&lt;args&gt;" argument.
</para>
<para>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).
</para>
<para>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.
</para>
<para>
<programlisting>  separate_arguments(VARIABLE)
</programlisting>
</para>
<para>Convert the value of VARIABLE to a semi-colon separated list.  All spaces are replaced with ';'.  This helps with generating command lines.</para>
</sect2>
<sect2 id="ctest.command.set">
<title>set</title>
<abstract>
<para>Set a CMake, cache or environment variable to a given value.</para>
</abstract>
<para>
<programlisting>  set(&lt;variable&gt; &lt;value&gt;
      [[CACHE &lt;type&gt; &lt;docstring&gt; [FORCE]] | PARENT_SCOPE])
</programlisting>
</para>
<para>Within CMake sets &lt;variable&gt; to the value &lt;value&gt;.  &lt;value&gt; is expanded before &lt;variable&gt; is set to it.  Normally, set will set a regular CMake variable. If CACHE is present, then the &lt;variable&gt; is put in the cache instead, unless it is already in the cache. See section 'Variable types in CMake' below for details of regular and cache variables and their interactions. If CACHE is used, &lt;type&gt; and &lt;docstring&gt; are required. &lt;type&gt; is used by the CMake GUI to choose a widget with which the user sets a value. The value for &lt;type&gt; may be one of
</para>
<para>
<programlisting>  FILEPATH = File chooser dialog.
  PATH     = Directory chooser dialog.
  STRING   = Arbitrary string.
  BOOL     = Boolean ON/OFF checkbox.
  INTERNAL = No GUI entry (used for persistent variables).
</programlisting>
</para>
<para>If &lt;type&gt; is INTERNAL, the cache variable is marked as internal, and will not be shown to the user in tools like cmake-gui. This is intended for values that should be persisted in the cache, but which users should not normally change. INTERNAL implies FORCE.
</para>
<para>Normally, set(...CACHE...) creates cache variables, but does not modify them. If FORCE is specified, the value of the cache variable is set, even if the variable is already in the cache. This should normally be avoided, as it will remove any changes to the cache variable's value by the user.
</para>
<para>If PARENT_SCOPE is present, 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). PARENT_SCOPE cannot be combined with CACHE.
</para>
<para>If &lt;value&gt; is not specified then the variable is removed instead of set.  See also: the unset() command.
</para>
<para>
<programlisting>  set(&lt;variable&gt; &lt;value1&gt; ... &lt;valueN&gt;)
</programlisting>
</para>
<para>In this case &lt;variable&gt; is set to a semicolon separated list of values.
</para>
<para>&lt;variable&gt; can be an environment variable such as:
</para>
<para>
<programlisting>  set( ENV{PATH} /home/martink )
</programlisting>
</para>
<para>in which case the environment variable will be set.
</para>
<para>*** Variable types in CMake ***
</para>
<para>In CMake there are two types of variables: normal variables and cache variables. Normal variables are meant for the internal use of the script (just like variables in most programming languages); they are not persisted across CMake runs. Cache variables (unless set with INTERNAL) are mostly intended for configuration settings where the first CMake run determines a suitable default value, which the user can then override, by editing the cache with tools such as ccmake or cmake-gui. Cache variables are stored in the CMake cache file, and are persisted across CMake runs. 
</para>
<para>Both types can exist at the same time with the same name but different values. When ${FOO} is evaluated, CMake first looks for a normal variable 'FOO' in scope and uses it if set. If and only if no normal variable exists then it falls back to the cache variable 'FOO'.
</para>
<para>Some examples:
</para>
<para>The code 'set(FOO "x")' sets the normal variable 'FOO'. It does not touch the cache, but it will hide any existing cache value 'FOO'.
</para>
<para>The code 'set(FOO "x" CACHE ...)' checks for 'FOO' in the cache, ignoring any normal variable of the same name. If 'FOO' is in the cache then nothing happens to either the normal variable or the cache variable. If 'FOO' is not in the cache, then it is added to the cache.
</para>
<para>Finally, whenever a cache variable is added or modified by a command, CMake also *removes* the normal variable of the same name from the current scope so that an immediately following evaluation of it will expose the newly cached value.
</para>
<para>Normally projects should avoid using normal and cache variables of the same name, as this interaction can be hard to follow. However, in some situations it can be useful. One example (used by some projects):
</para>
<para>A project has a subproject in its source tree. The child project has its own CMakeLists.txt, which is included from the parent CMakeLists.txt using add_subdirectory(). Now, if the parent and the child project provide the same option (for example a compiler option), the parent gets the first chance to add a user-editable option to the cache. Normally, the child would then use the same value that the parent uses. However, it may be necessary to hard-code the value for the child project's option while still allowing the user to edit the value used by the parent project. The parent project can achieve this simply by setting a normal variable with the same name as the option in a scope sufficient to hide the option's cache variable from the child completely. The parent has already set the cache variable,  so the child's set(...CACHE...) will do nothing, and evaluating the option variable will use the value from the normal variable, which hides the cache variable.</para>
</sect2>
<sect2 id="ctest.command.set_directory_properties">
<title>set_directory_properties</title>
<abstract>
<para>Set a property of the directory.</para>
</abstract>
<para>
<programlisting>  set_directory_properties(PROPERTIES prop1 value1 prop2 value2)
</programlisting>
</para>
<para>Set a property for the current directory and subdirectories. If the property is not found, CMake will report an error. The properties include: INCLUDE_DIRECTORIES, LINK_DIRECTORIES, INCLUDE_REGULAR_EXPRESSION, and ADDITIONAL_MAKE_CLEAN_FILES. ADDITIONAL_MAKE_CLEAN_FILES is a list of files that will be cleaned as a part of "make clean" stage.</para>
</sect2>
<sect2 id="ctest.command.set_property">
<title>set_property</title>
<abstract>
<para>Set a named property in a given scope.</para>
</abstract>
<para>
<programlisting>  set_property(&lt;GLOBAL                            |
                DIRECTORY [dir]                   |
                TARGET    [target1 [target2 ...]] |
                SOURCE    [src1 [src2 ...]]       |
                TEST      [test1 [test2 ...]]     |
                CACHE     [entry1 [entry2 ...]]&gt;
               [APPEND] [APPEND_STRING]
               PROPERTY &lt;name&gt; [value1 [value2 ...]])
</programlisting>
</para>
<para>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:
</para>
<para>GLOBAL scope is unique and does not accept a name.
</para>
<para>DIRECTORY scope defaults to the current directory but another directory (already processed by CMake) may be named by full or relative path.
</para>
<para>TARGET scope may name zero or more existing targets.
</para>
<para>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).
</para>
<para>TEST scope may name zero or more existing tests.
</para>
<para>CACHE scope must name zero or more cache existing entries.
</para>
<para>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.</para>
</sect2>
<sect2 id="ctest.command.site_name">
<title>site_name</title>
<abstract>
<para>Set the given variable to the name of the computer.</para>
</abstract>
<para>
<programlisting>  site_name(variable)
</programlisting>
</para>
</sect2>
<sect2 id="ctest.command.string">
<title>string</title>
<abstract>
<para>String operations.</para>
</abstract>
<para>
<programlisting>  string(REGEX MATCH &lt;regular_expression&gt;
         &lt;output variable&gt; &lt;input&gt; [&lt;input&gt;...])
  string(REGEX MATCHALL &lt;regular_expression&gt;
         &lt;output variable&gt; &lt;input&gt; [&lt;input&gt;...])
  string(REGEX REPLACE &lt;regular_expression&gt;
         &lt;replace_expression&gt; &lt;output variable&gt;
         &lt;input&gt; [&lt;input&gt;...])
  string(REPLACE &lt;match_string&gt;
         &lt;replace_string&gt; &lt;output variable&gt;
         &lt;input&gt; [&lt;input&gt;...])
  string(&lt;MD5|SHA1|SHA224|SHA256|SHA384|SHA512&gt;
         &lt;output variable&gt; &lt;input&gt;)
  string(COMPARE EQUAL &lt;string1&gt; &lt;string2&gt; &lt;output variable&gt;)
  string(COMPARE NOTEQUAL &lt;string1&gt; &lt;string2&gt; &lt;output variable&gt;)
  string(COMPARE LESS &lt;string1&gt; &lt;string2&gt; &lt;output variable&gt;)
  string(COMPARE GREATER &lt;string1&gt; &lt;string2&gt; &lt;output variable&gt;)
  string(ASCII &lt;number&gt; [&lt;number&gt; ...] &lt;output variable&gt;)
  string(CONFIGURE &lt;string1&gt; &lt;output variable&gt;
         [@ONLY] [ESCAPE_QUOTES])
  string(TOUPPER &lt;string1&gt; &lt;output variable&gt;)
  string(TOLOWER &lt;string1&gt; &lt;output variable&gt;)
  string(LENGTH &lt;string&gt; &lt;output variable&gt;)
  string(SUBSTRING &lt;string&gt; &lt;begin&gt; &lt;length&gt; &lt;output variable&gt;)
  string(STRIP &lt;string&gt; &lt;output variable&gt;)
  string(RANDOM [LENGTH &lt;length&gt;] [ALPHABET &lt;alphabet&gt;]
         [RANDOM_SEED &lt;seed&gt;] &lt;output variable&gt;)
  string(FIND &lt;string&gt; &lt;substring&gt; &lt;output variable&gt; [REVERSE])
</programlisting>
</para>
<para>REGEX MATCH will match the regular expression once and store the match in the output variable.
</para>
<para>REGEX MATCHALL will match the regular expression as many times as possible and store the matches in the output variable as a list.
</para>
<para>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 (\\1) are required in CMake code to get a backslash through argument parsing.
</para>
<para>REPLACE will replace all occurrences of match_string in the input with replace_string and store the result in the output.
</para>
<para>MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 will compute a cryptographic hash of the input string.
</para>
<para>COMPARE EQUAL/NOTEQUAL/LESS/GREATER will compare the strings and store true or false in the output variable.
</para>
<para>ASCII will convert all numbers into corresponding ASCII characters.
</para>
<para>CONFIGURE will transform a string like CONFIGURE_FILE transforms a file.
</para>
<para>TOUPPER/TOLOWER will convert string to upper/lower characters.
</para>
<para>LENGTH will return a given string's length.
</para>
<para>SUBSTRING will return a substring of a given string. If length is -1 the remainder of the string starting at begin will be returned.
</para>
<para>STRIP will return a substring of a given string with leading and trailing spaces removed.
</para>
<para>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.
</para>
<para>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.
</para>
<para>The following characters have special meaning in regular expressions:
</para>
<para>
<programlisting>   ^         Matches at beginning of a line
   $         Matches at end of a line
   .         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]
   *         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).</programlisting>
</para>
</sect2>
<sect2 id="ctest.command.unset">
<title>unset</title>
<abstract>
<para>Unset a variable, cache variable, or environment variable.</para>
</abstract>
<para>
<programlisting>  unset(&lt;variable&gt; [CACHE])
</programlisting>
</para>
<para>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.
</para>
<para>&lt;variable&gt; can be an environment variable such as:
</para>
<para>
<programlisting>  unset(ENV{LD_LIBRARY_PATH})
</programlisting>
</para>
<para>in which case the variable will be removed from the current environment.</para>
</sect2>
<sect2 id="ctest.command.use_mangled_mesa">
<title>use_mangled_mesa</title>
<abstract>
<para>Copy mesa headers for use in combination with system GL.</para>
</abstract>
<para>
<programlisting>  use_mangled_mesa(PATH_TO_MESA OUTPUT_DIRECTORY)
</programlisting>
</para>
<para>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.</para>
</sect2>
<sect2 id="ctest.command.variable_watch">
<title>variable_watch</title>
<abstract>
<para>Watch the CMake variable for change.</para>
</abstract>
<para>
<programlisting>  variable_watch(&lt;variable name&gt; [&lt;command to execute&gt;])
</programlisting>
</para>
<para>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(&lt;variable&gt; &lt;access&gt; &lt;value&gt; &lt;current list file&gt; &lt;stack&gt;)</para>
</sect2>
<sect2 id="ctest.command.while">
<title>while</title>
<abstract>
<para>Evaluate a group of commands while a condition is true</para>
</abstract>
<para>
<programlisting>  while(condition)
    COMMAND1(ARGS ...)
    COMMAND2(ARGS ...)
    ...
  endwhile(condition)
</programlisting>
</para>
<para>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.</para>
</sect2>
<sect2 id="ctest.command.write_file">
<title>write_file</title>
<abstract>
<para>Deprecated. Use the file(WRITE ) command instead.</para>
</abstract>
<para>
<programlisting>  write_file(filename "message to write"... [APPEND])
</programlisting>
</para>
<para>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.
</para>
<para>NOTE 1: file(WRITE ... and file(APPEND ... do exactly the same as this one but add some more functionality.
</para>
<para>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.</para>
</sect2>
</sect1>
<sect1 id="ctest.Properties">
<title>Properties</title>
<para>
<programlisting>  CMake Properties - Properties supported by CMake, the Cross-Platform Makefile Generator.</programlisting>
</para>
<para>This is the documentation for the properties supported by CMake. Properties can have different scopes. They can either be assigned to a source file, a directory, a target or globally to CMake. By modifying the values of properties the behaviour of the build system can be customized.</para>
</sect1>
<sect1 id="ctest.Compatibility_Commands">
<title>Compatibility Commands</title>
<para>
<programlisting>  CMake Compatibility Listfile Commands - Obsolete commands supported by CMake for compatibility.</programlisting>
</para>
<para>This is the documentation for now obsolete listfile commands from previous CMake versions, which are still supported for compatibility reasons. You should instead use the newer, faster and shinier new commands. ;-)</para>
</sect1>
<sect1 id="ctest.Standard_CMake_Modules">
<title>Standard CMake Modules</title>
<para/>
</sect1>
<sect1 id="ctest.Copyright">
<title>Copyright</title>
<para>Copyright 2000-2012 Kitware, Inc., Insight Software Consortium.  All rights reserved.</para>
<para>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</para>
<para>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</para>
<para>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</para>
<para>Neither the names of Kitware, Inc., the Insight Software Consortium, nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.</para>
<para>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</para>
</sect1>
<sect1 id="ctest.See_Also">
<title>See Also</title>
<abstract>
<para>The following resources are available to get help using CMake:</para>
</abstract>
<sect2 id="ctest.see.Home_Page">
<title>Home Page</title>
<abstract>
<para><ulink url="http://www.cmake.org" /></para>
</abstract>
<para>The primary starting point for learning about CMake.</para>
</sect2>
<sect2 id="ctest.see.Frequently_Asked_Questions">
<title>Frequently Asked Questions</title>
<abstract>
<para><ulink url="http://www.cmake.org/Wiki/CMake_FAQ" /></para>
</abstract>
<para>A Wiki is provided containing answers to frequently asked questions. </para>
</sect2>
<sect2 id="ctest.see.Online_Documentation">
<title>Online Documentation</title>
<abstract>
<para><ulink url="http://www.cmake.org/HTML/Documentation.html" /></para>
</abstract>
<para>Links to available documentation may be found on this web page.</para>
</sect2>
<sect2 id="ctest.see.Mailing_List">
<title>Mailing List</title>
<abstract>
<para><ulink url="http://www.cmake.org/HTML/MailingLists.html" /></para>
</abstract>
<para>For help and discussion about using cmake, a mailing list is provided at cmake@cmake.org. The list is member-post-only but one may sign up on the CMake web page. Please first read the full documentation at <ulink url="http://www.cmake.org" /> before posting questions to the list.</para>
</sect2>
</sect1>
</article>
