I’ve created a GitHub repo to show a minimal reproducible example as requested by @craig.scott in the other thread:
Basically the intent is to have a way to be in control of the version of Ninja my developers on my team use.
And ideally not have them have to download/set Ninja themselves. I want the experience as seemless as possible. Currently this type of workflow works fine since we just have our cmake modules inside our project. The problem arises in separating the cmake code in it’s own GitHub and downloading it using fetchcontent.
The module in question:
# example.cmake
include(GLOBAL)
function(set_ninja_version)
set(CMAKE_MAKE_PROGRAM ${CMAKE_CURRENT_LIST_DIR}/ninja.exe)
endfunction()
Here is how I try and grab it:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.19)
include(FetchContent)
FetchContent_Declare(ninja_issue
GIT_REPOSITORY "https://github.com/personWhoWritesCmakeExamples/ninja_fetch_content_issue"
GIT_TAG "main"
)
FetchContent_MakeAvailable(ninja_issue)
list(APPEND CMAKE_MODULE_PATH "${ninja_issue_SOURCE_DIR}/")
include(example)
set_ninja_version()
project(FOOBAR
LANGUAGES "CXX"
)
However this fails with the following output.
C:\coolguy> cmake -S . -B build_ninja -G "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.
-- Configuring incomplete, errors occurred!
See also "C:/coolguy/build_ninja/_deps/ninja_issue-subbuild/CMakeFiles/CMakeOutput.log".
CMake Error at C:/Program Files/CMake/share/cmake-3.19/Modules/FetchContent.cmake:977 (message):
CMake step for ninja_issue failed: 1
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.19/Modules/FetchContent.cmake:1111:EVAL:2 (__FetchContent_directPopulate)
C:/Program Files/CMake/share/cmake-3.19/Modules/FetchContent.cmake:1111 (cmake_language)
C:/Program Files/CMake/share/cmake-3.19/Modules/FetchContent.cmake:1154 (FetchContent_Populate)
CMakeLists.txt:13 (FetchContent_MakeAvailable)
-- Configuring incomplete, errors occurred!
C:\coolguy>
EDIT:
Link to the github: https://github.com/personWhoWritesCmakeExamples/ninja_fetch_content_issue