CMake task

Azure Pipelines | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015

Use this task in a build or release pipeline to build with the CMake cross-platform build system.

Demands

cmake

Important

The Microsoft-hosted agents have CMake installed by default so you don't need to include a demand for CMake in your azure-pipelines.yml file. If you do include a demand for CMake you may receive an error. To resolve, remove the demand.

YAML snippet

# CMake
# Build with the CMake cross-platform build system
- task: CMake@1
  inputs:
    #workingDirectory: 'build' # Optional
    #cmakeArgs: # Optional

Arguments

Argument Description
Working Directory

Working directory when CMake is run. The default value is build.

If you specify a relative path, then it is relative to your repo. For example, if you specify build, the result is the same as if you specified $(Build.SourcesDirectory)\build.

You can also specify a full path outside the repo, and you can use variables. For example: $(Build.ArtifactStagingDirectory)\build

If the path you specify does not exist, CMake creates it.

cmakeArgs Arguments that you want to pass to CMake.
Control options

Open source

This task is open source on GitHub. Feedback and contributions are welcome.

Q & A

How do I enable CMake for Microsoft-hosted agents?

The Microsoft-hosted agents have CMake installed already so you don't need to do anything. You do not need to add a demand for CMake in your azure-pipelines.yml file.

How do I enable CMake for my on-premises agent?

  1. Deploy an agent.

  2. Install CMake and make sure to add it to the path of the user that the agent is running as on your agent machine.

  3. In your web browser, navigate to Agent pools:

    1. Choose Azure DevOps, Organization settings.

      Organization settings

    2. Choose Agent pools.

      Choose Manage pools

    1. Choose Azure DevOps, Collection settings.

      Organization settings

    2. Choose Agent pools.

      Choose Manage pools

    1. Navigate to your project and choose Settings (gear icon) > Agent Queues.

      Choose settings, Agent Queues

    2. Choose Manage pools.

      Choose Manage pools

    1. Navigate to your project and choose Settings (gear icon) > Agent Queues.

      Choose settings, Agent Queues

    2. Choose Manage pools.

      Choose Manage pools

    1. Navigate to your project and choose Manage project (gear icon).

      Manage project

    2. Choose Control panel.

      Choose Control panel

    3. Select Agent pools.

      Agent pools tab

  4. Navigate to the capabilities tab:

    1. From the Agent pools tab, select the desired agent pool.

      Choose Manage pools

    2. Select Agents and choose the desired agent.

      Select Agents and choose the desired agent

    3. Choose the Capabilities tab.

      Agent capabilities tab

    1. From the Agent pools tab, select the desired pool.

      Choose Manage pools

    2. Select Agents and choose the desired agent.

      Select Agents and choose the desired agent

    3. Choose the Capabilities tab.

      Agent capabilities tab

    Select the desired agent, and choose the Capabilities tab.

    Agent capabilities tab

    Select the desired agent, and choose the Capabilities tab.

    Agent capabilities tab

    From the Agent pools tab, select the desired agent, and choose the Capabilities tab.

    Agent capabilities tab

  5. Click Add capability and set the fields to cmake and yes.

  6. Click Save changes.

How does CMake work? What arguments can I use?

About CMake

CMake Documentation

Do I need an agent?

You need at least one agent to run your build or release. Get an agent for Linux, macOS, or Windows.

I'm having problems. How can I troubleshoot them?

See Troubleshoot Build and Release.

I can't select a default agent pool and I can't queue my build or release. How do I fix this?

See Agent pools.

I use TFS on-premises and I don't see some of these features. Why not?

Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.