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,7 +157,9 @@ set(DATA_OUTPUT_DIR ${CMAKE_BINARY_DIR}/bin/data)
include(FetchContent) include(FetchContent)
FetchContent_Declare( find_package(Git)
if(GIT_FOUND)
FetchContent_Declare(
clone_strings clone_strings
GIT_REPOSITORY https://github.com/aseprite/strings.git GIT_REPOSITORY https://github.com/aseprite/strings.git
GIT_TAG origin/main GIT_TAG origin/main
@ -166,8 +168,11 @@ FetchContent_Declare(
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
TEST_COMMAND "") TEST_COMMAND "")
FetchContent_MakeAvailable(clone_strings) FetchContent_MakeAvailable(clone_strings)
add_custom_target(clone_strings DEPENDS 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.
add_custom_command(
OUTPUT ${DATA_OUTPUT_DIR}/strings.git/en.ini OUTPUT ${DATA_OUTPUT_DIR}/strings.git/en.ini
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SOURCE_DATA_DIR}/strings/en.ini ${DATA_OUTPUT_DIR}/strings.git/en.ini COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SOURCE_DATA_DIR}/strings/en.ini ${DATA_OUTPUT_DIR}/strings.git/en.ini
MAIN_DEPENDENCY ${SOURCE_DATA_DIR}/strings/en.ini) MAIN_DEPENDENCY ${SOURCE_DATA_DIR}/strings/en.ini)
list(APPEND out_data_files ${DATA_OUTPUT_DIR}/strings.git/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