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} "/configure" "--prefix=" "--cross-prefix=" "--cc=${CMAKE_C_COMPILER}" "--cxx=${CMAKE_CXX_COMPILER}" "--disable-debug-info" "--enable-strip" "--enable-pie" "-Db_staticpic=true" "-Db_lundef=false" "--target-list=arm-linux-user" "--without-default-features" USES_TERMINAL_CONFIGURE TRUE # Build Command BUILD_COMMAND "ninja" COMMAND "ninja" "install" BUILD_BYPRODUCTS "${QEMU_LIBRARY}" USES_TERMINAL_BUILD TRUE # Patch Command PATCH_COMMAND "patch" "-p1" "<" "${CMAKE_CURRENT_SOURCE_DIR}/runtime.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()