# CppComponent

API Documentation: | `CppComponent`

Known Subtypes: |
`ProductionCppComponent`
`CppTestSuite`

Configuration for a C++ component, such as a library or executable, defining the source files and private header directories that make up the component. Private headers are those that are visible only to the source files of the component.

A C++ component is composed of some C++ source files that are compiled and then linked into some binary.

An instance of this type is added as a project extension by the C++ plugins.

### Properties

Property | Description
`baseName` | Specifies the base name for this component. This name is used to calculate various output file names. The default value is calculated from the project name.
`binaries` | The binaries of this component.
`privateHeaders` | Defines the private header file directories of this library.
`source` | Defines the source files or directories of this component. You can add files or directories to this collection. When a directory is added, all source files are included for compilation.
`targetMachines` | Specifies the target machines this component should be built for. The "machines" extension property (see `TargetMachineFactory`) can be used to construct common operating system and architecture combinations.

### Methods

Method | Description
`privateHeaders(action)` | Configures the private header directories for this component.
`source(action)` | Configures the source files or directories for this component.

### Script blocks

No script blocks

### Property details

#### ``Property`<`String`>` `baseName`

Specifies the base name for this component. This name is used to calculate various output file names. The default value is calculated from the project name.

#### ``BinaryCollection`<? extends `SoftwareComponent`>` `binaries` (read-only)

The binaries of this component.

#### `ConfigurableFileCollection` `privateHeaders` (read-only)

Defines the private header file directories of this library.

When this collection is empty, the directory `src/main/headers` is used by default.

#### `ConfigurableFileCollection` `source` (read-only)

Defines the source files or directories of this component. You can add files or directories to this collection. When a directory is added, all source files are included for compilation.

When this collection is empty, the directory `src/main/cpp` is used by default.

#### ``SetProperty`<`TargetMachine`>` `targetMachines`

Specifies the target machines this component should be built for. The "machines" extension property (see `TargetMachineFactory`) can be used to construct common operating system and architecture combinations.

For example:

    targetMachines = [machines.linux.x86_64, machines.windows.x86_64]

### Method details

#### `void` `privateHeaders`(``Action`<? super `ConfigurableFileCollection`>` action)

Configures the private header directories for this component.

#### `void` `source`(``Action`<? super `ConfigurableFileCollection`>` action)

Configures the source files or directories for this component.