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(QEMU_ARCHIVE "qemu-9.2.0.tar.xz") set(QEMU_HASH "f859f0bc65e1f533d040bbe8c92bcfecee5af2c921a6687c652fb44d089bd894") # Library set(QEMU_LIBRARY "/lib/libqemu-arm.so") # Patches set(PATCHES "${CMAKE_CURRENT_SOURCE_DIR}/patches") set(PATCH_CMD "patch" "-p1" "<") # PkgConfig set(PKGCONFIG_ENV "") if(DEFINED ENV{PKG_CONFIG_LIBDIR}) set(PKGCONFIG_ENV "PKG_CONFIG_LIBDIR=$ENV{PKG_CONFIG_LIBDIR}") endif() # Build include(ExternalProject) ExternalProject_Add(qemu URL "${CMAKE_CURRENT_SOURCE_DIR}/${QEMU_ARCHIVE}" URL_HASH "SHA256=${QEMU_HASH}" # Configure Build CONFIGURE_COMMAND "${CMAKE_COMMAND}" "-E" "env" ${PKGCONFIG_ENV} "/configure" "--prefix=" # Cross-Compile "--cross-prefix=" "--cc=${CMAKE_C_COMPILER}" "--cxx=${CMAKE_CXX_COMPILER}" # Optimize "--disable-debug-info" "--enable-strip" "--enable-pie" # Minimal Build "--target-list=arm-linux-user" "--without-default-features" USES_TERMINAL_CONFIGURE TRUE # Build Command BUILD_COMMAND "ninja" "install" BUILD_BYPRODUCTS "${QEMU_LIBRARY}" USES_TERMINAL_BUILD TRUE # Patch Command PATCH_COMMAND ${PATCH_CMD} "${PATCHES}/build-as-shared-library.patch" COMMAND ${PATCH_CMD} "${PATCHES}/flatpak-support.patch" COMMAND ${PATCH_CMD} "${PATCHES}/trampoline-syscall.patch" # Disable Install Command INSTALL_COMMAND "" ) # 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()