Allow Specifying Custom Sysroot

This commit is contained in:
TheBrokenRail 2022-05-03 21:04:22 -04:00
parent f2a9b274d2
commit ead7e575f3

View File

@ -1,9 +1,15 @@
project(armhf-sysroot)
# Packages
# Allow Custom Sysroot
set(MCPI_CUSTOM_BUNDLED_ARMHF_SYSROOT "" CACHE PATH "Custom Bundled ARMHF Sysroot")
if(MCPI_CUSTOM_BUNDLED_ARMHF_SYSROOT)
# Custom Sysroot
set(SYSROOT_DIR "${MCPI_CUSTOM_BUNDLED_ARMHF_SYSROOT}")
else()
# Download From APT
set(APT_PACKAGES "libc6" "libstdc++6")
# Trigger Reconfigure On APT Change
# Reconfigure CMake If APT Data Is Changed
file(GLOB_RECURSE APT_FILES "apt/*")
foreach(APT_FILE IN LISTS APT_FILES)
set_property(
@ -51,7 +57,7 @@ file(WRITE "${APT_DIR}/apt.conf" "${APT_CONFIG}")
set(APT_ENV
"${CMAKE_COMMAND}"
-E env
DEBIAN_FRONTEND=noninteractive
"DEBIAN_FRONTEND=noninteractive"
"APT_CONFIG=${APT_DIR}/apt.conf"
)
@ -64,24 +70,25 @@ file(MAKE_DIRECTORY "${SYSROOT_DIR}")
add_custom_command(
OUTPUT "${APT_DIR}/.update-stamp"
COMMAND ${APT_ENV} apt-get update
COMMAND touch ARGS "${APT_DIR}/.update-stamp"
COMMAND "${CMAKE_COMMAND}" -E touch "${APT_DIR}/.update-stamp"
VERBATIM
)
add_custom_command(
OUTPUT "${APT_DIR}/.download-stamp"
DEPENDS "${APT_DIR}/.update-stamp"
COMMAND ${APT_ENV} apt-get install -y --no-install-recommends --download-only ${APT_PACKAGES}
COMMAND touch ARGS "${APT_DIR}/.download-stamp"
COMMAND "${CMAKE_COMMAND}" -E touch "${APT_DIR}/.download-stamp"
VERBATIM
)
add_custom_command(
OUTPUT "${APT_DIR}/.extract-stamp"
DEPENDS "${APT_DIR}/.download-stamp"
COMMAND ${APT_ENV} find "${APT_DIR}/archives" -maxdepth 1 -type f -name "*.deb" -exec dpkg -x {} "${SYSROOT_DIR}" ";"
COMMAND touch ARGS "${APT_DIR}/.extract-stamp"
COMMAND "${CMAKE_COMMAND}" -E touch "${APT_DIR}/.extract-stamp"
VERBATIM
)
add_custom_target(armhf-sysroot ALL DEPENDS "${APT_DIR}/.extract-stamp")
endif()
# Install
install(