CMake/Tests/RunCMake/Configure/RerunCMakeNinja.cmake
Ben Boeckel 5a36d0c9e7 Ninja: Fix regression with a large number of subdirectories
Since commit f50fb77a4f (Ninja: Regenerate when test or install scripts
are missing, 2024-10-29, v4.0.0-rc1~516^2) the list of paths we pass to
`ninja -t restat` scales with the number of project subdirectories.
Run it in blocks to avoid "command line too long" errors, particularly
on Windows.

Fixes: #26738
2025-03-04 13:37:01 -05:00

17 lines
616 B
CMake

set(input ${CMAKE_CURRENT_BINARY_DIR}/input.txt)
set(stamp ${CMAKE_CURRENT_BINARY_DIR}/stamp.txt)
file(READ ${input} content)
file(WRITE ${stamp} "${content}")
# Add enough subdirectories to make the total list of paths to 'cmake_install.cmake'
# files exceed the Windows command-line length limit.
set(length 0)
foreach(i RANGE 1 1000)
if(length GREATER_EQUAL 32678)
break()
endif()
add_subdirectory(RerunCMakeNinja RerunCMakeNinja${i})
string(LENGTH "${CMAKE_CURRENT_BINARY_DIR}/RerunCMakeNinja${i}/cmake_install.cmake" subdir_length)
math(EXPR length "${length} + ${subdir_length}")
endforeach()