diff options
author | Diego Iastrubni <diegoiast@gmail.com> | 2022-09-02 12:31:20 +0300 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-09-09 10:31:12 +0100 |
commit | 8b30b69dac87ca836cdbc573a1a622130fb37c32 (patch) | |
tree | bcce91f1dd96ec3f5c74fe2f80c0257d6023944a /Meta | |
parent | 5ab3fcf71020ad01d82c765d706cd253429305e8 (diff) | |
download | serenity-8b30b69dac87ca836cdbc573a1a622130fb37c32.zip |
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.
Diffstat (limited to 'Meta')
-rw-r--r-- | Meta/CMake/check_for_dependencies.cmake | 29 | ||||
-rw-r--r-- | Meta/CMake/time_zone_data.cmake | 13 | ||||
-rw-r--r-- | Meta/CMake/utils.cmake | 13 |
3 files changed, 35 insertions, 20 deletions
diff --git a/Meta/CMake/check_for_dependencies.cmake b/Meta/CMake/check_for_dependencies.cmake index 6ab71c9c43..d216220cf3 100644 --- a/Meta/CMake/check_for_dependencies.cmake +++ b/Meta/CMake/check_for_dependencies.cmake @@ -7,17 +7,22 @@ # # Additionally we have to emit an error message for each tool, # as REQUIRED only works with cmake 3.18 and above. -find_program(UNZIP_TOOL unzip REQUIRED) -if (NOT UNZIP_TOOL) - message(FATAL_ERROR "Failed to locate unzip on your machine, please install it and re-read the SerenityOS build documentation.") -endif() +if (CMAKE_VERSION VERSION_LESS 3.18.0) + find_program(UNZIP_TOOL unzip REQUIRED) + message(STATUS "Found cmake ${CMAKE_VERSION} - testing for external tools to uncompress") + if (NOT UNZIP_TOOL) + message(FATAL_ERROR "Failed to locate unzip on your machine, please install it and re-read the SerenityOS build documentation.") + endif() -find_program(TAR_TOOL tar REQUIRED) -if (NOT TAR_TOOL) - message(FATAL_ERROR "Failed to locate tar on your machine, please install it and re-read the SerenityOS build documentation.") -endif() + find_program(TAR_TOOL tar REQUIRED) + if (NOT TAR_TOOL) + message(FATAL_ERROR "Failed to locate tar on your machine, please install it and re-read the SerenityOS build documentation.") + endif() -find_program(GZIP_TOOL gzip REQUIRED) -if (NOT GZIP_TOOL) - message(FATAL_ERROR "Failed to locate gzip on your machine, please install it and re-read the SerenityOS build documentation.") -endif() + find_program(GZIP_TOOL gzip REQUIRED) + if (NOT GZIP_TOOL) + message(FATAL_ERROR "Failed to locate gzip on your machine, please install it and re-read the SerenityOS build documentation.") + endif() +else() + message(STATUS "Found cmake ${CMAKE_VERSION} - using CMake to uncompress") +endif()
\ No newline at end of file diff --git a/Meta/CMake/time_zone_data.cmake b/Meta/CMake/time_zone_data.cmake index 86b3d6b581..0d94066f97 100644 --- a/Meta/CMake/time_zone_data.cmake +++ b/Meta/CMake/time_zone_data.cmake @@ -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() diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake index 23c73122c0..61af57ad88 100644 --- a/Meta/CMake/utils.cmake +++ b/Meta/CMake/utils.cmake @@ -224,10 +224,15 @@ endfunction() function(extract_path dest_dir zip_path source_path dest_path) if (EXISTS "${zip_path}" AND NOT EXISTS "${dest_path}") - message(STATUS "Extracting ${source_path} from ${zip_path}") - execute_process(COMMAND "${UNZIP_TOOL}" -q "${zip_path}" "${source_path}" -d "${dest_dir}" RESULT_VARIABLE unzip_result) - if (NOT unzip_result EQUAL 0) - message(FATAL_ERROR "Failed to unzip ${source_path} from ${zip_path} with status ${unzip_result}") + if (CMAKE_VERSION VERSION_LESS 3.18.0) + message(STATUS "Extracting using ${UNZIP_TOOL} ${source_path} from ${zip_path}") + execute_process(COMMAND "${UNZIP_TOOL}" -q "${zip_path}" "${source_path}" -d "${dest_dir}" RESULT_VARIABLE unzip_result) + if (NOT unzip_result EQUAL 0) + message(FATAL_ERROR "Failed to unzip ${source_path} from ${zip_path} with status ${unzip_result}") + endif() + else() + message(STATUS "Extracting using cmake ${source_path}") + file(ARCHIVE_EXTRACT INPUT "${zip_path}" DESTINATION "${dest_dir}" PATTERNS "${source_path}") endif() endif() endfunction() |