From 1b0498c3e01045b95faaf5417cf669ad76de0ef0 Mon Sep 17 00:00:00 2001 From: liufeng Date: Thu, 20 Jul 2023 09:39:04 +0800 Subject: [PATCH] fix: windows build (#73,#67) --- CMakeLists.txt | 52 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bcaaaced..59209d9da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -977,17 +977,59 @@ add_custom_command( -o ${PROJECT_BINARY_DIR}/torque-generated -v8-root ${PROJECT_SOURCE_DIR}/v8 ${torque_files} - COMMAND - ${CMAKE_COMMAND} -E touch ${torque-outputs} ${torque_outputs} DEPENDS torque ${torque_dirs} ${torque_files_abs} - OUTPUT - ${torque-outputs} - ${torque_outputs} + TARGET + v8_torque_generated ) +if(WIN32) + # Windows has a limit on the number of command line arguments. To work around + # Split the files into groups of 200 and touch them in groups. + + set(torque_outputs_per_command 200) + set(torque_outputs_full ${torque_outputs} ${torque-outputs}) + list(LENGTH torque_outputs_full torque_outputs_full_length) + math(EXPR torque_outputs_last_index "${torque_outputs_full_length} - 1") + + foreach (start RANGE 0 ${torque_outputs_last_index} ${torque_outputs_per_command}) + list(SUBLIST torque_outputs_full ${start} ${torque_outputs_per_command} torque_outputs_full_sublist) + + add_custom_command( + COMMAND + ${CMAKE_COMMAND} -E touch ${torque_outputs_full_sublist} + DEPENDS + torque + ${torque_dirs} + ${torque_files_abs} + OUTPUT + ${torque_outputs_full_sublist} + ) + endforeach() + +else() + + add_custom_command( + COMMAND + torque + -o ${PROJECT_BINARY_DIR}/torque-generated + -v8-root ${PROJECT_SOURCE_DIR}/v8 + ${torque_files} + COMMAND + ${CMAKE_COMMAND} -E touch ${torque-outputs} ${torque_outputs} + DEPENDS + torque + ${torque_dirs} + ${torque_files_abs} + OUTPUT + ${torque-outputs} + ${torque_outputs} + ) + +endif () + add_custom_command( COMMAND ${CMAKE_COMMAND} -E make_directory ${torque_dirs}