Skip to content

Commit c30e248

Browse files
committed
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.
1 parent 5e008b6 commit c30e248

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ project(NinjaPythonDistributions)
44

55
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH})
66

7+
# Verify that the Ninja source directory is available
8+
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ninja-upstream/CMakeLists.txt")
9+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
10+
set(_details "Make sure to initialize submodules: git submodule update --init --recursive.")
11+
else()
12+
set(_details "Source distribution appears to be incomplete or invalid.")
13+
endif()
14+
message(FATAL_ERROR "Missing ninja-upstream sources at [${CMAKE_CURRENT_SOURCE_DIR}/ninja-upstream]. ${_details}")
15+
endif()
16+
717
# Options
818
option(RUN_NINJA_TEST "Run Ninja test suite" OFF)
919

0 commit comments

Comments
 (0)