Don't try to clone strings repo if Git isn't available (fix #4357)

This can happen when the source code is downloaded as a .zip and the
Git command is not available to clone the strings repo.
This commit is contained in:
David Capello 2024-03-06 09:59:20 -03:00
parent 4584d67b69
commit 50d4f9d802

View File

@ -157,17 +157,22 @@ set(DATA_OUTPUT_DIR ${CMAKE_BINARY_DIR}/bin/data)
include(FetchContent) include(FetchContent)
FetchContent_Declare( find_package(Git)
clone_strings if(GIT_FOUND)
GIT_REPOSITORY https://github.com/aseprite/strings.git FetchContent_Declare(
GIT_TAG origin/main clone_strings
SOURCE_DIR ${DATA_OUTPUT_DIR}/strings.git GIT_REPOSITORY https://github.com/aseprite/strings.git
CONFIGURE_COMMAND "" GIT_TAG origin/main
BUILD_COMMAND "" SOURCE_DIR ${DATA_OUTPUT_DIR}/strings.git
INSTALL_COMMAND "" CONFIGURE_COMMAND ""
TEST_COMMAND "") BUILD_COMMAND ""
FetchContent_MakeAvailable(clone_strings) INSTALL_COMMAND ""
add_custom_target(clone_strings DEPENDS clone_strings) TEST_COMMAND "")
FetchContent_MakeAvailable(clone_strings)
add_custom_target(clone_strings DEPENDS clone_strings)
else()
add_custom_target(clone_strings)
endif()
###################################################################### ######################################################################
# Copy data/ directory target into bin/data/ # Copy data/ directory target into bin/data/
@ -182,14 +187,16 @@ foreach(fn ${src_data_files})
list(APPEND out_data_files ${DATA_OUTPUT_DIR}/${fn}) list(APPEND out_data_files ${DATA_OUTPUT_DIR}/${fn})
endforeach() endforeach()
# Copy original en.ini to strings.git/en.ini to keep it updated. We if(GIT_FOUND)
# have to manually sync the "en.ini" file in the "strings" repo from # Copy original en.ini to strings.git/en.ini to keep it updated. We
# the "aseprite" repo. # have to manually sync the "en.ini" file in the "strings" repo from
add_custom_command( # the "aseprite" repo.
OUTPUT ${DATA_OUTPUT_DIR}/strings.git/en.ini add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SOURCE_DATA_DIR}/strings/en.ini ${DATA_OUTPUT_DIR}/strings.git/en.ini OUTPUT ${DATA_OUTPUT_DIR}/strings.git/en.ini
MAIN_DEPENDENCY ${SOURCE_DATA_DIR}/strings/en.ini) COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SOURCE_DATA_DIR}/strings/en.ini ${DATA_OUTPUT_DIR}/strings.git/en.ini
list(APPEND out_data_files ${DATA_OUTPUT_DIR}/strings.git/en.ini) MAIN_DEPENDENCY ${SOURCE_DATA_DIR}/strings/en.ini)
list(APPEND out_data_files ${DATA_OUTPUT_DIR}/strings.git/en.ini)
endif()
add_custom_command( add_custom_command(
OUTPUT ${DATA_OUTPUT_DIR}/README.md OUTPUT ${DATA_OUTPUT_DIR}/README.md