I’m having an issue with Ninja and FetchContent.
I’m trying to create a shared cmake code repository at my company.
And I would like to use FetchContent to grab this shared cmake code.
So I have the following
FetchContent_Declare(generic_cmake_modules GIT_REPOSITORY "...." GIT_TAG "main" ) FetchContent_MakeAvailable(generic_cmake_modules)
However this results in this error message:
“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.”
This is because I set CMAKE_MAKE_PROGRAM (IE Ninja) in a toolchain which is inside the generic_cmake_modules repo.
Which results in this workaround where I set CMAKE_MAKE_PROGRAM before the FetchContent_Declare call.
# Explanation of why this is necessary and what is happening. # FetchContent tries to configure the cmake modules and fails as a result of CMAKE_MAKE_PROGRAM not being defined. # Because we define CMAKE_MAKE_PROGRAM in our toolchain, which is inside the content we are fetching. Catch22. # # This works around the issue if ( CMAKE_GENERATOR MATCHES "Ninja" ) # This will get overriden by a later toolchain set(CMAKE_MAKE_PROGRAM "C:/......./ninja/1.10.0/ninja.exe" CACHE FILEPATH "") endif()
However this isn’t optimal since I need to be in control of the version of Ninja the client uses.
The clients shouldn’t care about the Ninja version.
What should I do?