Skip to content

Commit

Permalink
FindSlint: Avoid re-downloading and re-extracting the archive
Browse files Browse the repository at this point in the history
  • Loading branch information
tronical committed Sep 12, 2024
1 parent fb1c34c commit 105ab0c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
24 changes: 15 additions & 9 deletions stm32h735g-dk/cmake/FindSlint.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,26 @@ if (SLINT_USE_NIGHTLY_VERSION)
set(SLINT_GITHUB_RELEASE "nightly" CACHE STRING "")
endif()

set(prebuilt_archive_filename "Slint-cpp-${slint_version}-${SLINT_TARGET_ARCHITECTURE}.tar.gz")
set(prebuilt_archive_name "Slint-cpp-${slint_version}-${SLINT_TARGET_ARCHITECTURE}")
set(prebuilt_archive_filename "${prebuilt_archive_name}.tar.gz")
set(download_target_path "${CMAKE_BINARY_DIR}/slint-prebuilt/")
set(download_url "https://github.com/slint-ui/slint/releases/download/${github_release}/${prebuilt_archive_filename}")

file(MAKE_DIRECTORY "${download_target_path}")
message(STATUS "Downloading pre-built Slint binary ${download_url}")
file(DOWNLOAD "${download_url}" "${download_target_path}/${prebuilt_archive_filename}" STATUS download_status)
list(GET download_status 0 download_code)
if (NOT download_code EQUAL 0)
list(GET download_status 1 download_message)
message(STATUS "Download of Slint binary package failed: ${download_message}")
return()
if (NOT EXISTS "${download_target_path}/${prebuilt_archive_filename}")
file(DOWNLOAD "${download_url}" "${download_target_path}/${prebuilt_archive_filename}" STATUS download_status)
list(GET download_status 0 download_code)
if (NOT download_code EQUAL 0)
list(GET download_status 1 download_message)
message(STATUS "Download of Slint binary package failed: ${download_message}")
return()
endif()
endif()

if (NOT EXISTS "${download_target_path}/${prebuilt_archive_name}")
file(ARCHIVE_EXTRACT INPUT "${download_target_path}/${prebuilt_archive_filename}" DESTINATION "${download_target_path}")
endif()

file(ARCHIVE_EXTRACT INPUT "${download_target_path}/${prebuilt_archive_filename}" DESTINATION "${download_target_path}")
list(PREPEND CMAKE_PREFIX_PATH "${download_target_path}")
list(PREPEND CMAKE_PREFIX_PATH "${download_target_path}/${prebuilt_archive_name}")
find_package(Slint CONFIG)
24 changes: 15 additions & 9 deletions stm32h747i-disco/cmake/FindSlint.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,26 @@ if (SLINT_USE_NIGHTLY_VERSION)
set(SLINT_GITHUB_RELEASE "nightly" CACHE STRING "")
endif()

set(prebuilt_archive_filename "Slint-cpp-${slint_version}-${SLINT_TARGET_ARCHITECTURE}.tar.gz")
set(prebuilt_archive_name "Slint-cpp-${slint_version}-${SLINT_TARGET_ARCHITECTURE}")
set(prebuilt_archive_filename "${prebuilt_archive_name}.tar.gz")
set(download_target_path "${CMAKE_BINARY_DIR}/slint-prebuilt/")
set(download_url "https://github.com/slint-ui/slint/releases/download/${github_release}/${prebuilt_archive_filename}")

file(MAKE_DIRECTORY "${download_target_path}")
message(STATUS "Downloading pre-built Slint binary ${download_url}")
file(DOWNLOAD "${download_url}" "${download_target_path}/${prebuilt_archive_filename}" STATUS download_status)
list(GET download_status 0 download_code)
if (NOT download_code EQUAL 0)
list(GET download_status 1 download_message)
message(STATUS "Download of Slint binary package failed: ${download_message}")
return()
if (NOT EXISTS "${download_target_path}/${prebuilt_archive_filename}")
file(DOWNLOAD "${download_url}" "${download_target_path}/${prebuilt_archive_filename}" STATUS download_status)
list(GET download_status 0 download_code)
if (NOT download_code EQUAL 0)
list(GET download_status 1 download_message)
message(STATUS "Download of Slint binary package failed: ${download_message}")
return()
endif()
endif()

if (NOT EXISTS "${download_target_path}/${prebuilt_archive_name}")
file(ARCHIVE_EXTRACT INPUT "${download_target_path}/${prebuilt_archive_filename}" DESTINATION "${download_target_path}")
endif()

file(ARCHIVE_EXTRACT INPUT "${download_target_path}/${prebuilt_archive_filename}" DESTINATION "${download_target_path}")
list(PREPEND CMAKE_PREFIX_PATH "${download_target_path}")
list(PREPEND CMAKE_PREFIX_PATH "${download_target_path}/${prebuilt_archive_name}")
find_package(Slint CONFIG)

0 comments on commit 105ab0c

Please sign in to comment.