Search code examples
cmakeninjacmake-gui

CMake GUI with Ninja on macOS


I'm trying to create Ninja build files using CMake GUI.

I've tried to install Ninja on macOS using Brew and manually. Both times I made sure that ninja is available on the PATH but CMake GUI was never able to find ninja.

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 on command line is able to find ninja. Just cmake-GUI is not.

Any hints highly appreciated.


Solution

  • When apps are launched from the Finder (e.g. double-clicking on its icon), it is not necessarily the same PATH as launching from a command line. You can see the difference using a trivial CMakeLists.txt with the following contents:

    cmake_minimum_required(VERSION 3.1)
    message("ENV{PATH} = $ENV{PATH}")
    project(foo)
    

    If you launch the CMake GUI app through the Finder and use the above file as the project to build, the output will probably show a path like this:

    ENV{PATH} = /usr/bin:/bin:/usr/sbin:/sbin
    

    If you run CMake GUI from a command line directly (e.g. /Applications/CMake.app/Contents/bin/cmake-gui rather than open /Applications/CMake.app), the PATH should be the same as you are used to seeing from the command line, which for you probably includes /usr/local/bin assuming you've set that in your ~/.bash_profile or similar.