2020-05-15 07:52:37 +00:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2021-09-07 07:50:09 +00:00
|
|
|
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Meta/CMake")
|
|
|
|
|
2020-05-15 07:52:37 +00:00
|
|
|
project(SerenityOS C CXX ASM)
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2020-06-06 01:23:31 +00:00
|
|
|
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
|
2021-05-13 11:15:35 +00:00
|
|
|
message(FATAL_ERROR
|
2020-06-06 01:23:31 +00:00
|
|
|
": Don't use CMAKE_BUILD_TYPE when building serenity.\n"
|
|
|
|
"The default build type is optimized with debug info and asserts enabled,\n"
|
|
|
|
"and that's all there is.")
|
|
|
|
endif()
|
|
|
|
|
2021-09-07 08:21:36 +00:00
|
|
|
if(NOT CMAKE_SYSTEM_NAME STREQUAL "SerenityOS")
|
|
|
|
message(FATAL_ERROR "System name is not SerenityOS, this is unsupported.\n"
|
|
|
|
"Please re-read the BuildInstructions documentation, and use the superbuild configuration\n")
|
2021-05-31 08:18:22 +00:00
|
|
|
endif()
|
|
|
|
|
2022-01-03 08:26:13 +00:00
|
|
|
# Check for toolchain mismatch, user might need to rebuild toolchain
|
2022-08-23 06:51:40 +00:00
|
|
|
set(GCC_VERSION "12.2.0")
|
2022-04-08 21:28:25 +00:00
|
|
|
set(LLVM_VERSION "14.0.1")
|
2022-01-03 08:26:13 +00:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set(EXPECTED_COMPILER_VERSION "${GCC_VERSION}")
|
|
|
|
else()
|
|
|
|
set(EXPECTED_COMPILER_VERSION "${LLVM_VERSION}")
|
|
|
|
endif()
|
|
|
|
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "${EXPECTED_COMPILER_VERSION}")
|
|
|
|
message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} version (${CMAKE_CXX_COMPILER_VERSION}) does not match "
|
|
|
|
"expected compiler version (${EXPECTED_COMPILER_VERSION}).\n"
|
|
|
|
"Please rebuild the ${CMAKE_CXX_COMPILER_ID} Toolchain\n")
|
|
|
|
endif()
|
|
|
|
|
2021-09-07 08:21:36 +00:00
|
|
|
set(CMAKE_INSTALL_MESSAGE NEVER)
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2020-11-11 22:59:06 +00:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2021-09-07 08:08:54 +00:00
|
|
|
if(NOT COMMAND serenity_option)
|
|
|
|
macro(serenity_option)
|
|
|
|
set(${ARGV})
|
|
|
|
endmacro()
|
|
|
|
endif()
|
|
|
|
include(serenity_options)
|
|
|
|
|
2021-09-07 08:21:36 +00:00
|
|
|
find_program(CCACHE_PROGRAM ccache)
|
|
|
|
if(CCACHE_PROGRAM)
|
|
|
|
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE FILEPATH "Path to a compiler launcher program, e.g. ccache")
|
|
|
|
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}" CACHE FILEPATH "Path to a compiler launcher program, e.g. ccache")
|
2021-07-13 14:43:45 +00:00
|
|
|
endif()
|
|
|
|
|
2022-01-07 14:31:48 +00:00
|
|
|
if (NOT HACKSTUDIO_BUILD)
|
2021-09-07 08:21:36 +00:00
|
|
|
|
2022-03-18 11:31:36 +00:00
|
|
|
include(check_for_dependencies)
|
2022-01-07 14:31:48 +00:00
|
|
|
|
|
|
|
# Host tools, required to generate files for the build
|
|
|
|
find_package(Lagom CONFIG REQUIRED)
|
2022-08-28 23:47:03 +00:00
|
|
|
|
|
|
|
if (ENABLE_JAKT)
|
|
|
|
find_package(Jakt CONFIG REQUIRED
|
|
|
|
HINTS "${Lagom_DIR}/.."
|
|
|
|
)
|
2022-05-20 05:46:36 +00:00
|
|
|
endif()
|
2022-01-07 14:31:48 +00:00
|
|
|
|
|
|
|
endif()
|
2021-05-26 18:34:52 +00:00
|
|
|
|
2021-08-30 02:27:50 +00:00
|
|
|
# Meta target to run all code-gen steps in the build.
|
|
|
|
add_custom_target(all_generated)
|
|
|
|
|
2020-05-06 15:40:06 +00:00
|
|
|
add_custom_target(run
|
2021-08-08 00:32:49 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_ARCH=${SERENITY_ARCH}" "${SerenityOS_SOURCE_DIR}/Meta/run.sh"
|
2020-05-06 15:40:06 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2021-02-14 23:59:20 +00:00
|
|
|
# This can currently only be implemented by ordered commands
|
|
|
|
# as cmake doesn't support inter dependency ordering, and we
|
|
|
|
# would like to avoid inject dependencies on the existing
|
|
|
|
# custom commands to allow people to run commands adhoc with
|
|
|
|
# out forcing re-builds when they might not want them.
|
|
|
|
add_custom_target(setup-and-run
|
|
|
|
COMMAND ${CMAKE_MAKE_PROGRAM} install
|
|
|
|
COMMAND ${CMAKE_MAKE_PROGRAM} image
|
|
|
|
COMMAND ${CMAKE_MAKE_PROGRAM} run
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2020-06-20 01:04:42 +00:00
|
|
|
add_custom_target(image
|
|
|
|
DEPENDS qemu-image
|
|
|
|
)
|
2021-07-13 14:43:45 +00:00
|
|
|
|
2020-06-20 01:04:42 +00:00
|
|
|
add_custom_target(qemu-image
|
2021-09-07 08:21:36 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "SERENITY_TOOLCHAIN=${CMAKE_CXX_COMPILER_ID}" "LLVM_VERSION=${CMAKE_CXX_COMPILER_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-qemu.sh"
|
2021-08-08 00:32:49 +00:00
|
|
|
BYPRODUCTS "${CMAKE_BINARY_DIR}/_disk_image"
|
2020-06-20 01:04:42 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2020-05-26 21:51:18 +00:00
|
|
|
add_custom_target(grub-image
|
2022-09-02 18:59:45 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "SERENITY_TOOLCHAIN=${CMAKE_CXX_COMPILER_ID}" "LLVM_VERSION=${CMAKE_CXX_COMPILER_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-grub.sh"
|
2020-05-28 08:08:38 +00:00
|
|
|
BYPRODUCTS ${CMAKE_BINARY_DIR}/grub_disk_image
|
2020-05-26 21:51:18 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2022-01-16 07:15:20 +00:00
|
|
|
add_custom_target(limine-image
|
2022-09-02 18:59:45 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "SERENITY_TOOLCHAIN=${CMAKE_CXX_COMPILER_ID}" "LLVM_VERSION=${CMAKE_CXX_COMPILER_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-limine.sh"
|
2022-01-16 07:15:20 +00:00
|
|
|
BYPRODUCTS ${CMAKE_BINARY_DIR}/limine_disk_image
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2021-05-08 11:02:36 +00:00
|
|
|
add_custom_target(extlinux-image
|
2021-09-07 08:21:36 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "SERENITY_TOOLCHAIN=${CMAKE_CXX_COMPILER_ID}" "LLVM_VERSION=${CMAKE_CXX_COMPILER_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-extlinux.sh"
|
2021-08-08 00:32:49 +00:00
|
|
|
BYPRODUCTS "${CMAKE_BINARY_DIR}/extlinux_disk_image"
|
2021-05-08 11:02:36 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2022-02-04 03:52:45 +00:00
|
|
|
add_custom_target(install-native-partition
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "SERENITY_TOOLCHAIN=${CMAKE_CXX_COMPILER_ID}" "LLVM_VERSION=${CMAKE_CXX_COMPILER_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-native-partition.sh"
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
2020-05-26 21:51:18 +00:00
|
|
|
|
2020-05-28 19:06:44 +00:00
|
|
|
add_custom_target(lint-shell-scripts
|
2021-08-08 00:32:49 +00:00
|
|
|
COMMAND "${SerenityOS_SOURCE_DIR}/Meta/lint-shell-scripts.sh"
|
2020-05-28 19:06:44 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
add_custom_target(check-style
|
2021-08-08 00:32:49 +00:00
|
|
|
COMMAND "${SerenityOS_SOURCE_DIR}/Meta/check-style.sh"
|
2020-05-28 19:06:44 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2021-04-03 03:53:41 +00:00
|
|
|
add_custom_target(install-ports
|
2021-09-07 08:21:36 +00:00
|
|
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "SERENITY_TOOLCHAIN=${CMAKE_CXX_COMPILER_ID}" "${SerenityOS_SOURCE_DIR}/Meta/install-ports-tree.sh"
|
2021-04-03 03:53:41 +00:00
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
|
2022-01-07 14:31:48 +00:00
|
|
|
if (NOT HACKSTUDIO_BUILD)
|
|
|
|
|
|
|
|
add_custom_target(configure-components
|
|
|
|
COMMAND "$<TARGET_FILE:Lagom::ConfigureComponents>"
|
|
|
|
USES_TERMINAL
|
|
|
|
)
|
|
|
|
add_dependencies(configure-components Lagom::ConfigureComponents)
|
|
|
|
|
|
|
|
endif()
|
2021-06-20 12:54:45 +00:00
|
|
|
|
2021-05-23 21:33:52 +00:00
|
|
|
if (ENABLE_ALL_DEBUG_FACILITIES)
|
|
|
|
set(ENABLE_ALL_THE_DEBUG_MACROS ON)
|
|
|
|
set(ENABLE_EXTRA_KERNEL_DEBUG_SYMBOLS ON)
|
2021-05-31 09:38:50 +00:00
|
|
|
|
|
|
|
# Immediately finds violations during boot, shouldn't be discoverable
|
|
|
|
# by people who aren't working on fixing issues. Use this check to make
|
|
|
|
# sure this code continues to build instead of all_debug_macros to avoid
|
|
|
|
# people filing bugs.
|
|
|
|
set(KMALLOC_VERIFY_NO_SPINLOCK_HELD ON)
|
2021-06-06 23:15:07 +00:00
|
|
|
|
|
|
|
# Enables KCOV API and injects kernel coverage instrumentation via
|
|
|
|
# -fsanitize-coverage=trace-pc. Mostly here to ensure that the CI catches
|
|
|
|
# commits breaking this flag.
|
|
|
|
set(ENABLE_KERNEL_COVERAGE_COLLECTION ON)
|
2021-05-23 21:33:52 +00:00
|
|
|
endif()
|
|
|
|
|
2021-01-01 10:26:52 +00:00
|
|
|
if (ENABLE_ALL_THE_DEBUG_MACROS)
|
2021-09-07 07:50:09 +00:00
|
|
|
include(all_the_debug_macros)
|
2021-01-01 10:26:52 +00:00
|
|
|
endif(ENABLE_ALL_THE_DEBUG_MACROS)
|
2020-08-26 22:59:36 +00:00
|
|
|
|
2022-07-04 17:01:05 +00:00
|
|
|
set(CMAKE_STAGING_PREFIX "${CMAKE_BINARY_DIR}/Root")
|
|
|
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/Root")
|
|
|
|
set(CMAKE_INSTALL_DATAROOTDIR res)
|
|
|
|
set(CMAKE_INSTALL_INCLUDEDIR usr/include)
|
|
|
|
set(CMAKE_INSTALL_LIBDIR usr/lib)
|
|
|
|
|
2021-01-23 22:29:11 +00:00
|
|
|
configure_file(AK/Debug.h.in AK/Debug.h @ONLY)
|
2021-01-25 15:07:10 +00:00
|
|
|
configure_file(Kernel/Debug.h.in Kernel/Debug.h @ONLY)
|
2022-07-04 17:01:05 +00:00
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AK/Debug.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/AK")
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2021-01-06 23:55:01 +00:00
|
|
|
# We disable it completely because it makes cmake very spammy.
|
2020-12-27 23:04:29 +00:00
|
|
|
# This will need to be revisited when the Loader supports RPATH/RUN_PATH.
|
2021-01-06 23:55:01 +00:00
|
|
|
set(CMAKE_SKIP_RPATH TRUE)
|
2020-12-27 23:04:29 +00:00
|
|
|
|
2022-05-14 13:07:12 +00:00
|
|
|
include(serenity_compile_options)
|
2021-07-13 14:43:45 +00:00
|
|
|
|
2021-08-18 15:39:04 +00:00
|
|
|
add_link_options(LINKER:-z,text)
|
2022-01-08 19:33:36 +00:00
|
|
|
add_link_options(LINKER:--no-allow-shlib-undefined)
|
2021-08-18 15:39:04 +00:00
|
|
|
|
2021-07-12 07:31:47 +00:00
|
|
|
add_compile_definitions(SANITIZE_PTRS)
|
2020-12-11 13:44:08 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_STATIC "${CMAKE_CXX_FLAGS} -static")
|
2020-12-20 20:32:10 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fpic")
|
2021-01-01 10:20:55 +00:00
|
|
|
|
2021-02-23 17:14:04 +00:00
|
|
|
if (ENABLE_COMPILETIME_FORMAT_CHECK)
|
|
|
|
add_compile_definitions(ENABLE_COMPILETIME_FORMAT_CHECK)
|
2021-02-08 17:26:28 +00:00
|
|
|
endif()
|
|
|
|
|
2021-07-13 14:43:45 +00:00
|
|
|
add_link_options(-Wno-unused-command-line-argument)
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2021-08-08 07:31:23 +00:00
|
|
|
include_directories(.)
|
|
|
|
include_directories(Userland/Libraries)
|
2021-01-12 11:17:30 +00:00
|
|
|
include_directories(Userland/Libraries/LibC)
|
2021-05-01 09:38:19 +00:00
|
|
|
include_directories(Userland/Libraries/LibCrypt)
|
2021-01-12 11:17:30 +00:00
|
|
|
include_directories(Userland/Libraries/LibM)
|
2021-02-05 11:16:30 +00:00
|
|
|
include_directories(Userland/Libraries/LibSystem)
|
2021-01-12 11:23:01 +00:00
|
|
|
include_directories(Userland/Services)
|
2021-01-12 10:53:14 +00:00
|
|
|
include_directories(Userland)
|
2020-09-14 10:51:12 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
2021-01-12 11:23:01 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland/Services)
|
2021-01-12 11:17:30 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland/Libraries)
|
2021-01-12 10:53:14 +00:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Userland)
|
2020-05-06 15:40:06 +00:00
|
|
|
|
2021-05-24 01:40:22 +00:00
|
|
|
# FIXME: vptr sanitizing requires.. intense ABI wrangling of std::type_info
|
|
|
|
# And would be better served by porting ubsan_type_hash_itanium.cpp from compiler-rt
|
|
|
|
if (ENABLE_UNDEFINED_SANITIZER)
|
2021-09-07 08:21:36 +00:00
|
|
|
add_compile_options(-fsanitize=undefined -fno-sanitize=vptr)
|
|
|
|
add_link_options(-fsanitize=undefined -fno-sanitize=vptr)
|
2021-05-24 01:40:22 +00:00
|
|
|
endif()
|
|
|
|
|
2021-06-15 13:07:25 +00:00
|
|
|
add_custom_target(components ALL)
|
|
|
|
option(BUILD_EVERYTHING "Build all optional components" ON)
|
|
|
|
|
2021-09-07 07:50:09 +00:00
|
|
|
include(utils)
|
|
|
|
include(wasm_spec_tests)
|
2022-07-25 11:28:16 +00:00
|
|
|
include(flac_spec_tests)
|
2021-06-15 13:07:25 +00:00
|
|
|
|
|
|
|
serenity_component(
|
|
|
|
Tests
|
|
|
|
RECOMMENDED
|
|
|
|
)
|
|
|
|
|
2022-01-07 14:31:48 +00:00
|
|
|
if (HACKSTUDIO_BUILD)
|
2022-03-19 15:15:08 +00:00
|
|
|
include_directories(/usr/include/Userland/Services)
|
2022-01-07 14:31:48 +00:00
|
|
|
include(${HACKSTUDIO_BUILD_CMAKE_FILE})
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2020-05-26 18:20:24 +00:00
|
|
|
add_subdirectory(AK)
|
2020-05-06 15:40:06 +00:00
|
|
|
add_subdirectory(Kernel)
|
2021-08-28 16:56:51 +00:00
|
|
|
if(NOT "${SERENITY_ARCH}" STREQUAL "aarch64")
|
2022-01-19 19:54:34 +00:00
|
|
|
if (ENABLE_MOLD_LINKER)
|
|
|
|
add_link_options(-fuse-ld=mold)
|
|
|
|
endif()
|
2022-02-05 14:48:32 +00:00
|
|
|
|
2022-02-19 12:01:06 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang$" OR ENABLE_MOLD_LINKER)
|
2022-02-05 14:48:32 +00:00
|
|
|
add_link_options(LINKER:--pack-dyn-relocs=relr)
|
|
|
|
else()
|
|
|
|
add_link_options(LINKER:-z,pack-relative-relocs)
|
|
|
|
endif()
|
|
|
|
|
2021-08-28 16:56:51 +00:00
|
|
|
add_subdirectory(Userland)
|
|
|
|
add_subdirectory(Tests)
|
|
|
|
endif()
|
2021-01-21 20:41:48 +00:00
|
|
|
if (ENABLE_COMPILETIME_HEADER_CHECK)
|
|
|
|
add_subdirectory(Meta/HeaderCheck)
|
|
|
|
endif()
|
2021-02-06 23:52:40 +00:00
|
|
|
|
2021-06-15 13:07:25 +00:00
|
|
|
export_components("${CMAKE_BINARY_DIR}/components.ini")
|
|
|
|
|
2021-12-23 00:32:00 +00:00
|
|
|
set(PCI_IDS_FILE pci.ids)
|
|
|
|
set(PCI_IDS_GZ_URL https://pci-ids.ucw.cz/v2.2/${PCI_IDS_FILE}.gz)
|
|
|
|
set(PCI_IDS_GZ_PATH ${CMAKE_BINARY_DIR}/${PCI_IDS_FILE}.gz)
|
|
|
|
set(PCI_IDS_PATH ${CMAKE_BINARY_DIR}/${PCI_IDS_FILE})
|
|
|
|
set(PCI_IDS_INSTALL_PATH ${CMAKE_INSTALL_DATAROOTDIR}/${PCI_IDS_FILE})
|
2021-03-03 22:50:25 +00:00
|
|
|
|
|
|
|
if(ENABLE_PCI_IDS_DOWNLOAD AND NOT EXISTS ${PCI_IDS_GZ_PATH})
|
2022-01-25 23:44:44 +00:00
|
|
|
download_file("${PCI_IDS_GZ_URL}" "${PCI_IDS_GZ_PATH}")
|
2021-03-03 22:50:25 +00:00
|
|
|
endif()
|
|
|
|
|
2022-07-27 17:20:17 +00:00
|
|
|
if(EXISTS ${PCI_IDS_GZ_PATH} AND NOT EXISTS ${CMAKE_STAGING_PREFIX}/${PCI_IDS_INSTALL_PATH})
|
2021-03-03 22:50:25 +00:00
|
|
|
message(STATUS "Extracting PCI ID database from ${PCI_IDS_GZ_PATH}...")
|
2022-07-10 13:50:02 +00:00
|
|
|
file(MAKE_DIRECTORY "${CMAKE_STAGING_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}")
|
2022-09-02 09:31:20 +00:00
|
|
|
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()
|
2021-02-06 23:52:40 +00:00
|
|
|
endif()
|
2021-06-09 14:24:04 +00:00
|
|
|
|
2021-12-23 00:32:00 +00:00
|
|
|
set(USB_IDS_FILE usb.ids)
|
|
|
|
set(USB_IDS_GZ_URL http://www.linux-usb.org/${USB_IDS_FILE}.gz)
|
|
|
|
set(USB_IDS_GZ_PATH ${CMAKE_BINARY_DIR}/${USB_IDS_FILE}.gz)
|
|
|
|
set(USB_IDS_PATH ${CMAKE_BINARY_DIR}/${USB_IDS_FILE})
|
|
|
|
set(USB_IDS_INSTALL_PATH ${CMAKE_INSTALL_DATAROOTDIR}/${USB_IDS_FILE})
|
2021-06-09 14:24:04 +00:00
|
|
|
|
|
|
|
if(ENABLE_USB_IDS_DOWNLOAD AND NOT EXISTS ${USB_IDS_GZ_PATH})
|
2022-01-25 23:44:44 +00:00
|
|
|
download_file("${USB_IDS_GZ_URL}" "${USB_IDS_GZ_PATH}")
|
2021-06-09 14:24:04 +00:00
|
|
|
endif()
|
|
|
|
|
2022-07-27 17:20:17 +00:00
|
|
|
if(EXISTS ${USB_IDS_GZ_PATH} AND NOT EXISTS ${CMAKE_STAGING_PREFIX}/${USB_IDS_INSTALL_PATH})
|
2021-06-09 14:24:04 +00:00
|
|
|
message(STATUS "Extracting USB ID database from ${USB_IDS_GZ_PATH}...")
|
2022-07-10 13:50:02 +00:00
|
|
|
file(MAKE_DIRECTORY "${CMAKE_STAGING_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}")
|
2022-09-02 09:31:20 +00:00
|
|
|
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()
|
2021-06-09 14:24:04 +00:00
|
|
|
endif()
|