0

I was trying to set up an Azure DevOps build pipeline (Hosted VS2017) for a CMake-based project. Since Visual Studio 2017 uses the Ninja generator by default, I assumed that it were available in the Hosted VS2017 pool out of the box. When adding the following command:

CMake -GNinja ..

the build fails with this error diagnostic:

[command]C:\Program Files\CMake\bin\cmake.exe -GNinja ..
CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

It seems that CMake cannot discover the Ninja generator. I'm not sure what's wrong, though. Do I need to install an extension (if so, which one)? Am I missing a configuration step?

The ultimate question is: How do I set up an Azure DevOps build pipeline for a CMake-based project using the Ninja generator?

IInspectable
  • 46,945
  • 8
  • 85
  • 181
  • 1
    You could use the tasks I authored that provision automatically ninja: https://marketplace.visualstudio.com/items?itemName=lucappa.cmake-ninja-vcpkg-tasks – Luca Cappa May 28 '19 at 19:17
  • @luc: That looks promising, thank you. I haven't had a chance to give it a try yet, as I have pretty much moved away from Azure DevOps. The *"any language, any platform"* promise boils down to *"unless you're writing native code for Windows"*. Too many speed bumps in the way of getting up and running, and once you are, there's nothing that keeps Microsoft from deploying a [broken hosted agent image](https://developercommunity.visualstudio.com/content/problem/539158/hosted-windows-2019-with-vs2019-is-failing-builds.html). Breaking your builds, and not fixing it in more than a month's time. – IInspectable May 29 '19 at 09:30

1 Answers1

1

Seems Ninja wasn't found in your $PATH, you may need to install Ninja and set the $PATH system variable...

However there isn't such a Ninja Tool Installer for now, you can try to write you own extension is possible... refer to this thread : No CMake or Ninja Tool Installer for more information.

For the hosted agents, they are managed by Microsoft. Generally we cannot full control them to set the capabilities... So, suggest you try deploying a private (self-hosted) agent, then install Ninja and try it again.

Below threads for your reference:

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55