# <cl>

Compiles C/C++ programs using `cl.exe`, Microsoft's C/C++ compiler.

This task is intended for version 13.00.9466 of `cl.exe`.

### Parameters

Attribute | Type | Description | Required
--- | --- | --- | ---
outputdir | directory | Directory where all output files are placed. | True
characterset | CharacterSet | Tells the compiler to use the specified character set. | False
managedextensions | bool | Specifies whether Managed Extensions for C++ should be enabled. The default is false. | False
objectfile | string | A name to override the default object file name; can be either a file or directory name. The default is the output directory. | False
options | string | Options to pass to the compiler. | False
pchfile | string | Specifies the path and/or name of the generated precompiled header file - given either relative to `outputdir` or as an absolute path. | False
pchmode | PrecompiledHeaderMode | The mode in which the specified `pchfile` (if any) is used. The default is `Use`. | False
pchthroughfile | string | The path of the boundary file when generating/using the specified `pchfile`. If a precompiled header file is not specified then this attribute is ignored. | False
pdbfile | string | A name for the compiler-generated PDB file; can be either a file or directory name. The default is the output directory. | False
failonerror | bool | Determines if task failure stops the build, or is just reported. The default is true. | False
if | bool | If true then the task will be executed; otherwise, skipped. The default is true. | False
timeout | int | The maximum amount of time the application is allowed to execute, expressed in milliseconds. Defaults to no time-out. | False
unless | bool | Opposite of `if`. If false then the task will be executed; otherwise, skipped. The default is false. | False
verbose | bool | Determines whether the task should report detailed build log messages. The default is false. | False

### Framework-configurable parameters

Attribute | Type | Description | Required
--- | --- | --- | ---
exename | string | The name of the executable that should be used to launch the external program. | False
managed | ManagedExecution | Specifies whether the external program should be treated as a managed application, possibly forcing it to be executed under the currently targeted version of the CLR. | False
useruntimeengine | bool | Deprecated. Specifies whether the external program is a managed application which should be executed using a runtime engine, if configured. The default is false. | False

### Nested Elements:

#### <sources>

The list of files to compile.

#### </sources>

#### <includedirs>

The list of directories in which to search for include files.

#### </includedirs>

#### <metadataincludedirs>

Directories that the compiler will search to resolve file references passed to the `#using` directive.

#### </metadataincludedirs>

#### <forcedusingfiles>

Specifies metadata files to reference in this compilation as an alternative to passing a file name to `#using` in source code.

#### </forcedusingfiles>

#### <defines>

Macro definitions to pass to cl.exe. Each entry will generate a /D

##### <define>

Represents an option.

### Parameters

Attribute | Type | Description | Required
--- | --- | --- | ---
name | string | Name of the option. | True
if | bool | Indicates if the option should be passed to the task. If true then the option will be passed; otherwise, skipped. The default is true. | False
unless | bool | Indicates if the option should not be passed to the task. If false then the option will be passed; otherwise, skipped. The default is false. | False
value | string | Value of the option. The default is a null reference (Nothing in Visual Basic). | False

##### </define>

#### </defines>

#### <undefines>

Macro undefines (/U) to pass to cl.exe.

##### <undefine>

Represents an option.

### Parameters

Attribute | Type | Description | Required
--- | --- | --- | ---
name | string | Name of the option. | True
if | bool | Indicates if the option should be passed to the task. If true then the option will be passed; otherwise, skipped. The default is true. | False
unless | bool | Indicates if the option should not be passed to the task. If false then the option will be passed; otherwise, skipped. The default is false. | False
value | string | Value of the option. The default is a null reference (Nothing in Visual Basic). | False

##### </undefine>

#### </undefines>

#### <arg>

The command-line arguments for the external program.

Represents a command-line argument.

When passed to an external application, the argument will be quoted when appropriate. This does not apply to the `line` parameter, which is always passed as is.

### Parameters

Attribute | Type | Description | Required
--- | --- | --- | ---
dir | directory | The value for a directory-based command-line argument; will be replaced with the absolute path of the directory. | False
file | file | The name of a file as a single command-line argument; will be replaced with the absolute filename of the file. | False
if | bool | Indicates if the argument should be passed to the external program. If true then the argument will be passed; otherwise, skipped. The default is true. | False
line | string | List of command-line arguments; will be passed to the executable as is. | False
path | <path> | The value for a PATH-like command-line argument; you can use `:` or `;` as path separators and NAnt will convert it to the platform's local conventions, while resolving references to environment variables. | False
unless | bool | Indicates if the argument should not be passed to the external program. If false then the argument will be passed; otherwise, skipped. The default is false. | False
value | string | A single command-line argument; can contain space characters. | False

### Nested Elements:

#### <path>

Sets a single command-line argument and treats it like a PATH - ensures the right separator for the local platform is used.

#### </path>

### Examples

- A single command-line argument containing a space character.

      <arg value="-l -a" />

- Two separate command-line arguments.

      <arg line="-l -a" />

- A single command-line argument with the value `\dir;\dir2;\dir3` on DOS-based systems and `/dir:/dir2:/dir3` on Unix-like systems.

      <arg path="/dir;/dir2:\dir3" />

#### </arg>

### Examples

- Compiles `helloworld.cpp` for the Common Language Runtime.

                  <cl outputdir="build" options="/clr">
                      <sources>
                          <include name="helloworld.cpp" />
                      </sources>
                  </cl>

### Requirements

Assembly: NAnt.VisualCppTasks (0.91.4312.0)