Allow Specifying Custom Sysroot
This commit is contained in:
parent
f2a9b274d2
commit
ead7e575f3
83
dependencies/armhf-sysroot/CMakeLists.txt
vendored
83
dependencies/armhf-sysroot/CMakeLists.txt
vendored
@ -1,30 +1,36 @@
|
|||||||
project(armhf-sysroot)
|
project(armhf-sysroot)
|
||||||
|
|
||||||
# Packages
|
# Allow Custom Sysroot
|
||||||
set(APT_PACKAGES "libc6" "libstdc++6")
|
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/*")
|
file(GLOB_RECURSE APT_FILES "apt/*")
|
||||||
foreach(APT_FILE IN LISTS APT_FILES)
|
foreach(APT_FILE IN LISTS APT_FILES)
|
||||||
set_property(
|
set_property(
|
||||||
DIRECTORY
|
DIRECTORY
|
||||||
APPEND
|
APPEND
|
||||||
PROPERTY CMAKE_CONFIGURE_DEPENDS "${APT_FILE}"
|
PROPERTY CMAKE_CONFIGURE_DEPENDS "${APT_FILE}"
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Copy To Binary Directory
|
# Copy To Binary Directory
|
||||||
set(APT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apt-build")
|
set(APT_DIR "${CMAKE_CURRENT_BINARY_DIR}/apt-build")
|
||||||
file(REMOVE_RECURSE "${APT_DIR}")
|
file(REMOVE_RECURSE "${APT_DIR}")
|
||||||
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/apt/." DESTINATION "${APT_DIR}")
|
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/apt/." DESTINATION "${APT_DIR}")
|
||||||
# Make Directories
|
# Make Directories
|
||||||
file(MAKE_DIRECTORY "${APT_DIR}/apt.conf.d")
|
file(MAKE_DIRECTORY "${APT_DIR}/apt.conf.d")
|
||||||
file(MAKE_DIRECTORY "${APT_DIR}/preferences.d")
|
file(MAKE_DIRECTORY "${APT_DIR}/preferences.d")
|
||||||
file(MAKE_DIRECTORY "${APT_DIR}/dpkg")
|
file(MAKE_DIRECTORY "${APT_DIR}/dpkg")
|
||||||
file(TOUCH "${APT_DIR}/dpkg/status")
|
file(TOUCH "${APT_DIR}/dpkg/status")
|
||||||
|
|
||||||
# Create APT Config
|
# Create APT Config
|
||||||
string(CONCAT APT_CONFIG
|
string(CONCAT APT_CONFIG
|
||||||
"Dir \"${APT_DIR}\";\n"
|
"Dir \"${APT_DIR}\";\n"
|
||||||
"Dir::State \"${APT_DIR}\";\n"
|
"Dir::State \"${APT_DIR}\";\n"
|
||||||
"Dir::Cache \"${APT_DIR}\";\n"
|
"Dir::Cache \"${APT_DIR}\";\n"
|
||||||
@ -44,44 +50,45 @@ string(CONCAT APT_CONFIG
|
|||||||
"Acquire::Languages \"none\";\n"
|
"Acquire::Languages \"none\";\n"
|
||||||
"APT::Get::AllowUnauthenticated \"False\";\n"
|
"APT::Get::AllowUnauthenticated \"False\";\n"
|
||||||
"Acquire::AllowInsecureRepositories \"False\";\n"
|
"Acquire::AllowInsecureRepositories \"False\";\n"
|
||||||
)
|
)
|
||||||
file(WRITE "${APT_DIR}/apt.conf" "${APT_CONFIG}")
|
file(WRITE "${APT_DIR}/apt.conf" "${APT_CONFIG}")
|
||||||
|
|
||||||
# Environment
|
# Environment
|
||||||
set(APT_ENV
|
set(APT_ENV
|
||||||
"${CMAKE_COMMAND}"
|
"${CMAKE_COMMAND}"
|
||||||
-E env
|
-E env
|
||||||
DEBIAN_FRONTEND=noninteractive
|
"DEBIAN_FRONTEND=noninteractive"
|
||||||
"APT_CONFIG=${APT_DIR}/apt.conf"
|
"APT_CONFIG=${APT_DIR}/apt.conf"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create Sysroot Directory
|
# Create Sysroot Directory
|
||||||
set(SYSROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/sysroot")
|
set(SYSROOT_DIR "${CMAKE_CURRENT_BINARY_DIR}/sysroot")
|
||||||
file(REMOVE_RECURSE "${SYSROOT_DIR}")
|
file(REMOVE_RECURSE "${SYSROOT_DIR}")
|
||||||
file(MAKE_DIRECTORY "${SYSROOT_DIR}")
|
file(MAKE_DIRECTORY "${SYSROOT_DIR}")
|
||||||
|
|
||||||
# Download
|
# Download
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${APT_DIR}/.update-stamp"
|
OUTPUT "${APT_DIR}/.update-stamp"
|
||||||
COMMAND ${APT_ENV} apt-get update
|
COMMAND ${APT_ENV} apt-get update
|
||||||
COMMAND touch ARGS "${APT_DIR}/.update-stamp"
|
COMMAND "${CMAKE_COMMAND}" -E touch "${APT_DIR}/.update-stamp"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${APT_DIR}/.download-stamp"
|
OUTPUT "${APT_DIR}/.download-stamp"
|
||||||
DEPENDS "${APT_DIR}/.update-stamp"
|
DEPENDS "${APT_DIR}/.update-stamp"
|
||||||
COMMAND ${APT_ENV} apt-get install -y --no-install-recommends --download-only ${APT_PACKAGES}
|
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
|
VERBATIM
|
||||||
)
|
)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${APT_DIR}/.extract-stamp"
|
OUTPUT "${APT_DIR}/.extract-stamp"
|
||||||
DEPENDS "${APT_DIR}/.download-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 ${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
|
VERBATIM
|
||||||
)
|
)
|
||||||
add_custom_target(armhf-sysroot ALL DEPENDS "${APT_DIR}/.extract-stamp")
|
add_custom_target(armhf-sysroot ALL DEPENDS "${APT_DIR}/.extract-stamp")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
install(
|
install(
|
||||||
|
Loading…
Reference in New Issue
Block a user