diff options
-rw-r--r-- | CMakeLists.txt | 12 | ||||
-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 |
4 files changed, 45 insertions, 22 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3979b027f8..6f20d10500 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,7 +257,11 @@ endif() if(EXISTS ${PCI_IDS_GZ_PATH} AND NOT EXISTS ${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH}) message(STATUS "Extracting PCI ID database from ${PCI_IDS_GZ_PATH}...") file(MAKE_DIRECTORY "${CMAKE_STAGING_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}") - execute_process(COMMAND "${GZIP_TOOL}" -d -c "${PCI_IDS_GZ_PATH}" OUTPUT_FILE "${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH}") + if (CMAKE_VERSION VERSION_LESS 3.18.0) + execute_process(COMMAND "${GZIP_TOOL}" -d -c "${PCI_IDS_GZ_PATH}" OUTPUT_FILE "${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH}") + else() + file(ARCHIVE_EXTRACT INPUT "${PCI_IDS_GZ_PATH}" DESTINATION "${PCI_IDS_GZ_PATH}" PATTERNS "${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH}") + endif() endif() set(USB_IDS_FILE usb.ids) @@ -273,5 +277,9 @@ endif() if(EXISTS ${USB_IDS_GZ_PATH} AND NOT EXISTS ${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH}) message(STATUS "Extracting USB ID database from ${USB_IDS_GZ_PATH}...") file(MAKE_DIRECTORY "${CMAKE_STAGING_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}") - execute_process(COMMAND "${GZIP_TOOL}" -d -c "${USB_IDS_GZ_PATH}" OUTPUT_FILE "${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH}") + if (CMAKE_VERSION VERSION_LESS 3.18.0) + execute_process(COMMAND "${GZIP_TOOL}" -d -c "${USB_IDS_GZ_PATH}" OUTPUT_FILE "${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH}") + else() + file(ARCHIVE_EXTRACT INPUT "${PCI_IDS_GZ_PATH}" DESTINATION "${USB_IDS_GZ_PATH}" PATTERNS "${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH}") + endif() endif() 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() |