[Cmake-commits] [cmake-commits] hoffman committed syntax.html NONE 1.1
cmake-commits at cmake.org
cmake-commits at cmake.org
Mon Mar 10 11:56:43 EDT 2008
Update of /cvsroot/CMake/CMakeWeb/HTML
In directory public:/mounts/ram/cvs-serv17596
Added Files:
syntax.html
Log Message:
ENH: add syntax
--- NEW FILE: syntax.html ---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CMake Cross Platform Make</title></title>
<link href="kitware.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 6]>
<link href="styleIE6.css" rel="stylesheet" type="text/css" />
<![endif]-->
<meta name="Description" content="CMake is an open-source,
cross-platfom build environment. It supports native build processes
on Unix and Windows platforms under a variety of compilers." />
<meta name="Keywords" content="Software, compile, make, build, cross-platform" />
<META NAME="rating" CONTENT="General">
<META NAME="ROBOTS" CONTENT="ALL">
<script language="JavaScript">
function SubmitSearch()
{
var searchText = document.getElementById("searchtext").value;
window.location = "http://www.google.com/search?q=site%3Awww.cmake.org+"+searchText;
return false;
}
</script>
</head>
<body>
<div id="bg">
<div id="frame">
<div id="banner">
<div id="search">
<form id="searchform" onSubmit="return SubmitSearch()">
<input name="searchtext" type="text" class="searchfield" id="searchtext" value="Search" onfocus="this.value=''"/>
</form>
</div>
<div id="projectLogo"></div>
<div id="nav">
<ul id="MenuBar1" class="MenuBarHorizontal">
<li><a class="MenuBarItemSubmenu" href="index.html">HOME</a>
<ul>
<li><a href="about.html">About</a></li>
<li><a href="copyright.html">Copyright</a></li>
<li><a href="participants.html">Participants</a></li>
<li><a href="news.html">News</a></li>
<li><a href="http://www.cdash.org">CDash</a></li>
<li><a href="http://www.kitware.com">Kitware</a></li>
</ul>
</li>
<li><a href="#" class="MenuBarItemSubmenu">CMAKE</a>
<ul>
<li><a href="Download.html">Download</a></li>
<li><a href="install.html">Install</a></li>
<li><a href="Documentation.html">Documentation</a></li>
<li><a href="http://www.cmake.org/Wiki/CMake_FAQ">FAQ</a></li>
<li><a href="http://www.kitware.com/products/cmakebook.html">CMake Book</a></li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#">DEVELOPERS</a>
<ul>
<li><a href="http://public.kitware.com/CDash/index.php?project=CMake">Dashboard</a></li>
<li><a href="http://public.kitware.com/Bug">Bug Tracker</a> </li>
<li><a href="MailingLists.html">Mailing list</a></li>
<li><a href="http://www.cmake.org/Wiki/CMake">Wiki</a></li>
<li><a href="testing.html">Testing Setup</a></li>
</ul>
</li>
</ul>
</div>
<div id="logo">
<map name="Map" id="Map">
<area shape="poly" coords="5,82,5,5,94,32,296,32,294,81" href="../index.html" alt="Home" />
</map></div>
</div>
<div id="ContentBg">
<div id="Content">
<div id="ContentTxtProdWide"><div id="documentation_header"></div><br />
</div>
<p><br class="clear" />
</p>
<h2>Syntax Introduction</h2>
<p>CMakeLists.txt files follow a simple syntax consisting of comments, commands, and white
space. A comment is indicated using the # character and runs from that character until the end
of the line. A command consists of the command name, opening parenthesis, white space
separated arguments and a closing parenthesis. A command can be either one of the built in
commands like add_library, or a user defined macro or function. The input to CMake is a CMakeLists.txt file in the source directory. That file in turn can use the include or the add_subdirectory command to add additional input files. </p>
<p> All white space (spaces, line feeds, tabs) are
ignored except to separate arguments. Anything within a set of double quotes is treated as one
argument as is typical for most languages. The backslash can be used to escape characters
preventing the normal interpretation of them. </p>
<p> Each command is evaluated in the order that it appears in the CMakeLists file. The commands
have the form <br />
<code>command (args...)</code></p>
<p> where command is the name of the command, macro or function, and args is a white-space separated list of
arguments. (Arguments with embedded white-space should be double quoted.) CMake is case
insensitive to command names. So where you see command you could use
COMMAND or Command instead. </p>
<h2>Variables</h2>
<p>CMake supports simple variables that can be either strings or lists of strings. Variables are
referenced using a ${VAR} syntax. Multiple arguments can be grouped together into a list
using the set command. All other commands expand the lists as if they had been passed into
the command with white-space separation. For example, set(Foo a b c) will result in
setting the variable Foo to a b c, and if Foo is passed into another command
command(${Foo}) it would be equivalent to command(a b c). If you want to pass a list of
arguments to a command as if it were a single argument simply double quote it. For example
command("${Foo}") would be invoked passing only one argument equivalent to command(
"a b c" ). </p>
<h2>Lists and Strings</h2>
The basic data type in CMake is a string. CMake also supports lists of strings. A list can be created with semi-colons as separators. For example these two statements set the same value in to variable VAR:
<pre>
set(VAR a;b;c)
set(VAR a b c)
</pre>
<p>Lists of strings can be iterated with the foreach command or manipulated with the list command.</p>
<h2>Flow Control</h2>
In many ways writing a CMakeLists file is like a writing a program in a simple language.
Like most languages CMake provides flow control structures to help you along your way.
CMake provides three flow control structures:
<ul>
<li>conditional statements: if</li>
<pre>
# some_command will be called if the variable's value is not:
# empty, 0, N, NO, OFF, FALSE, NOTFOUND, or <variable>-NOTFOUND.
if(var)
some_command(...)
endif(var)
</pre>
<li>looping constructs: foreach and whilie</li>
<pre>
set(VAR a b c)
# loop over a, b,c with the variable f
foreach(f ${VAR})
message(${f})
endforeach(f)
</pre>
<li>procedure definitions: macro and function (function available in 2.6 and greater). functions create a local scope for variables, and macros use the global scope.</li>
<pre>
# define a macro hello
macro(hello MESSAGE)
message(${MESSAGE})
endmacro(hello)
# call the macro with the string "hello world"
hello("hello world")
# define a function hello
function(hello MESSAGE)
message(${MESSAGE})
endfunction(hello)
</pre>
</ul>
For more information on flow control see the documetation for the commands if, while, foreach, macro, and function.
<h2>Regular Expressions</h2>
A few CMake commands, such as if and string, make use of regular expressions or can
take a regular expression as an argument. In its simplest form, a regular-expression is a
sequence of characters used to search for exact character matches. However, many times the
exact sequence to be found is not known, or only a match at the beginning or end of a string is
desired. Since there are a few different conventions for specifying regular expressions,
CMake’s standard is described below. The description is based on the open source regular
expression class from Texas Instruments that is used by CMake for parsing regular
expressions.
<p> Regular expressions can be specified by using combinations of standard alphanumeric
characters and the following regular expression meta-characters: </p>
<ul>
<li>^ Matches at beginning of a line or string</li>
<li>$ Matches at end of a line or string</li>
<li>. Matches any single character other than a newline</li>
<li>[ ] Matches any character(s) inside the brackets</li>
<li>[^ ] Matches any character(s) not inside the brackets</li>
<li>[-] Matches any character in range on either side of a dash</li>
<li>* Matches preceding pattern zero or more times</li>
<li>+ Matches preceding pattern one or more times</li>
<li>? Matches preceding pattern zero or once only</li>
<li>() Saves a matched expression and uses it in a later replacement</li>
</ul>
<p> </p>
</div>
</div>
<div id="footer"><br />©2008 Copyright Kitware, Inc.</div>
</div>
</div>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>
More information about the Cmake-commits
mailing list