CMAKE_MAKE_PROGRAM 3.19 issue?

In my cmake toolchain I set the CMAKE_MAKE_PROGRAM.

To clarify I was setting my ninja executable like this:

if (CMAKE_GENERATOR MATCHES "Ninja")
        # Force update the program to allow updating the ninja version
        # Don't worry about bad builds
        # Ninja handles this update by starting over. Here is the error message ninja gave from
        # upgrading from version 1.7 -> 1.10
        # "ninja: warning: bad deps log signature or version; starting over"
        # This is why ninja is fantastic
        set(CMAKE_MAKE_PROGRAM "D:/foobar/ninja/1.10.0/ninja.exe" CACHE FILEPATH "" FORCE)
endif()

This seemed to work until cmake 3.19. And then I upgraded and this logic broke. Now I have to specify the CMAKE_MAKE_PROGRAM outside the toolchain.

Is there any reason why? Was I not supposed to be doing this?

1 Like

This is the error message I was getting:

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_CXX_COMPILER not set, after EnableLanguage
– Configuring incomplete, errors occurred!

It is now ‘fixed’ by setting the CMAKE_MAKE_PROGRAM before the first project file outside of the toolchain.

To clarify more cmake wouldn’t even process my toolchain at all unless this was defined.

Where/when are you setting CMAKE_MAKE_PROGRAM? It would have to be set before the project() line in your CMakeFile.txt, I’m thinking, because the project() command is what triggers CMake to probe for compilers and etc. for all of the LANGUAGEs specified for the project.

So, if you’re setting it from the script, make sure it’s right at the top before the project() line. (You might even try setting it as a regular variable instead of a cache variable, or even explicitly setting it both ways.)

Since I see Windows paths in your command line, what environment are you running CMake in? MSYS2? Windows / Visual Studio?

I’m setting CMAKE_MAKE_PROGRAM in my toolchain file.

The toolchain is called before the project command:
https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html

Environment:
Windows
Ninja
MSVC

I have been able to replicate this problem where CMAKE_MAKE_PROGRAM is evaluated before parsing of the contents of the CMAKE_TOOLCHAIN_FILE file in 3.19 compared to 3.18.

@brad.king Do you know what would have caused this regression in 3.19?

1 Like

Cc: @kyle.edwards

This is due to commit d5b5c19278. I opened CMake Issue 21486 for this.

1 Like

I would actually appreciate the new behavior! I use FetchContent in my toolchain file to download the toolchain binaries (and yes, that works great). And with e.g. CMake 3.18, it complains that this variable wasn’t set, yet. Very unfortunate, actually.

Maybe you can try a combination of both and make the early try non-fatal.