From d234744c05e6cb20ba7149c73dee4e829dd92205 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Thu, 19 Jun 2025 15:53:44 -0400 Subject: [PATCH] feat: Fail early if Ninja sources are missing Add an explicit check in the top-level `CMakeLists.txt` to verify that the `ninja-upstream` source directory is present. This helps catch configuration issues early, especially in environments where the source was cloned without initializing submodules. If the directory is missing and the project is under Git, the error suggests initializing submodules. Otherwise, it indicates an invalid source distribution. --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a1cd1f..999583c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,16 @@ project(NinjaPythonDistributions) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH}) +# Verify that the Ninja source directory is available +if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ninja-upstream/CMakeLists.txt") + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git") + set(_details "Make sure to initialize submodules: git submodule update --init --recursive.") + else() + set(_details "Source distribution appears to be incomplete or invalid.") + endif() + message(FATAL_ERROR "Missing ninja-upstream sources at [${CMAKE_CURRENT_SOURCE_DIR}/ninja-upstream]. ${_details}") +endif() + # Options option(RUN_NINJA_TEST "Run Ninja test suite" OFF)