70 lines
2.0 KiB
CMake
70 lines
2.0 KiB
CMake
project(qemu)
|
|
|
|
# Avoid Warning About DOWNLOAD_EXTRACT_TIMESTAMP
|
|
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24.0)
|
|
cmake_policy(SET CMP0135 NEW)
|
|
endif()
|
|
|
|
# Archive
|
|
set(RUNTIME_QEMU_ARCHIVE "" CACHE FILEPATH "QEMU Path")
|
|
if(NOT EXISTS "${RUNTIME_QEMU_ARCHIVE}")
|
|
message(FATAL_ERROR "Missing QEMU Archive!")
|
|
endif()
|
|
|
|
# Library
|
|
set(QEMU_LIBRARY "/lib/libqemu-arm.so")
|
|
|
|
# Build
|
|
include(ExternalProject)
|
|
set(PKGCONFIG_ENV "")
|
|
if(DEFINED ENV{PKG_CONFIG_LIBDIR})
|
|
set(PKGCONFIG_ENV "PKG_CONFIG_LIBDIR=$ENV{PKG_CONFIG_LIBDIR}")
|
|
endif()
|
|
ExternalProject_Add(qemu
|
|
URL "${RUNTIME_QEMU_ARCHIVE}"
|
|
# Configure Build
|
|
CONFIGURE_COMMAND
|
|
"${CMAKE_COMMAND}" "-E" "env"
|
|
${PKGCONFIG_ENV}
|
|
"<SOURCE_DIR>/configure"
|
|
"--prefix=<INSTALL_DIR>"
|
|
"--cross-prefix="
|
|
"--cc=${CMAKE_C_COMPILER}"
|
|
"--cxx=${CMAKE_CXX_COMPILER}"
|
|
"--disable-debug-info"
|
|
"--enable-strip"
|
|
"--enable-pie"
|
|
"--enable-lto"
|
|
"-Db_staticpic=true"
|
|
"-Db_lundef=false"
|
|
"--target-list=arm-linux-user"
|
|
"--without-default-features"
|
|
USES_TERMINAL_CONFIGURE TRUE
|
|
# Build Command
|
|
BUILD_COMMAND "ninja"
|
|
USES_TERMINAL_BUILD TRUE
|
|
# Install
|
|
INSTALL_DIR "${QEMU_INSTALL_DIR}"
|
|
INSTALL_COMMAND "ninja" "install"
|
|
INSTALL_BYPRODUCTS "<INSTALL_DIR>${QEMU_LIBRARY}"
|
|
# Disable Test Command
|
|
TEST_COMMAND ""
|
|
# Patch Command
|
|
PATCH_COMMAND "patch" "-p1" "<" "${CMAKE_CURRENT_SOURCE_DIR}/runtime.patch"
|
|
)
|
|
|
|
# Get Full Library Path
|
|
ExternalProject_Get_Property(qemu INSTALL_DIR)
|
|
string(PREPEND QEMU_LIBRARY "${INSTALL_DIR}")
|
|
|
|
# Link
|
|
target_link_libraries(runtime "${QEMU_LIBRARY}")
|
|
target_compile_definitions(trampoline-headers INTERFACE MCPI_HAS_QEMU)
|
|
|
|
# Install
|
|
if(DEFINED MCPI_LIB_DIR)
|
|
install(PROGRAMS "${QEMU_LIBRARY}" DESTINATION "${MCPI_LIB_DIR}")
|
|
# License
|
|
ExternalProject_Get_Property(qemu SOURCE_DIR)
|
|
install(FILES "${SOURCE_DIR}/COPYING" DESTINATION "${MCPI_LEGAL_DIR}/qemu")
|
|
endif() |