1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

Meta: Use CMake functions to extract files

Newer cmake's have internal functions to un-compress files. These
functions will work on pure windows - as well as linux. This
eliminates the need to search for external tools (TAR,GZIP,ZIP) - and
helps fixing #9866.

In order to finally fix #9866 we need to decide to bump the cmake
version requirements and remove the checks. If we demand a newer cmake
version, we will loose Ubuntu 20.04 as a build target - as it ships
with CMake 3.16.

For now - we keep compatibility with CMake 3.16 - and only if CMake
3.18 as been found - we use its new functionality.
This commit is contained in:
Diego Iastrubni 2022-09-02 12:31:20 +03:00 committed by Sam Atkins
parent 5ab3fcf710
commit 8b30b69dac
4 changed files with 45 additions and 22 deletions

View file

@ -40,10 +40,15 @@ set(TZDB_ZONE_1970_PATH "${TZDB_PATH}/${TZDB_ZONE_1970_SOURCE}")
function(extract_tzdb_file source path)
if(EXISTS "${TZDB_ZIP_PATH}" AND NOT EXISTS "${path}")
message(STATUS "Extracting TZDB ${source} from ${TZDB_ZIP_PATH}...")
execute_process(COMMAND "${TAR_TOOL}" -C "${TZDB_PATH}" -xzf "${TZDB_ZIP_PATH}" "${source}" RESULT_VARIABLE tar_result)
if (NOT tar_result EQUAL 0)
message(FATAL_ERROR "Failed to unzip ${source} from ${TZDB_ZIP_PATH} with status ${tar_result}")
if (CMAKE_VERSION VERSION_LESS 3.18.0)
message(STATUS "Extracting using ${TAR_TOOL} file ${source}")
execute_process(COMMAND "${TAR_TOOL}" -C "${TZDB_PATH}" -xzf "${TZDB_ZIP_PATH}" "${source}" RESULT_VARIABLE tar_result)
if (NOT tar_result EQUAL 0)
message(FATAL_ERROR "Failed to unzip ${source} from ${TZDB_ZIP_PATH} with status ${tar_result}")
endif()
else()
message(STATUS "Extracting using cmake ${source}")
file(ARCHIVE_EXTRACT INPUT "${TZDB_ZIP_PATH}" DESTINATION "${TZDB_PATH}" PATTERNS "${source}")
endif()
endif()
endfunction()