runtime/qemu/CMakeLists.txt

69 lines
1.9 KiB
CMake
Raw Normal View History

2024-06-04 21:50:17 +00:00
project(qemu)
2024-06-04 22:26:45 +00:00
# Avoid Warning About DOWNLOAD_EXTRACT_TIMESTAMP
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24.0)
cmake_policy(SET CMP0135 NEW)
endif()
2024-06-04 21:50:17 +00:00
# Archive
2024-11-10 10:26:16 +00:00
set(RUNTIME_QEMU_ARCHIVE "" CACHE FILEPATH "QEMU Path")
if(NOT EXISTS "${RUNTIME_QEMU_ARCHIVE}")
message(FATAL_ERROR "Missing QEMU Archive!")
2024-06-04 21:50:17 +00:00
endif()
2024-11-10 10:26:16 +00:00
# Library
set(QEMU_LIBRARY "/lib/libqemu-arm.so")
2024-06-04 21:50:17 +00:00
# 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
2024-06-08 09:28:22 +00:00
URL "${RUNTIME_QEMU_ARCHIVE}"
2024-06-04 21:50:17 +00:00
# Configure Build
CONFIGURE_COMMAND
"${CMAKE_COMMAND}" "-E" "env"
${PKGCONFIG_ENV}
"<SOURCE_DIR>/configure"
2024-11-10 10:26:16 +00:00
"--prefix=<INSTALL_DIR>"
2024-06-04 21:50:17 +00:00
"--cross-prefix="
"--cc=${CMAKE_C_COMPILER}"
"--cxx=${CMAKE_CXX_COMPILER}"
"--disable-debug-info"
2024-11-10 10:26:16 +00:00
"--enable-strip"
"--enable-pie"
"--enable-lto"
"-Db_staticpic=true"
"-Db_lundef=false"
2024-06-04 21:50:17 +00:00
"--target-list=arm-linux-user"
"--without-default-features"
USES_TERMINAL_CONFIGURE TRUE
# Build Command
2024-11-10 10:26:16 +00:00
BUILD_COMMAND "ninja"
2024-11-11 00:05:25 +00:00
COMMAND "ninja" "install"
BUILD_BYPRODUCTS "<INSTALL_DIR>${QEMU_LIBRARY}"
2024-06-04 21:50:17 +00:00
USES_TERMINAL_BUILD TRUE
# Patch Command
2024-11-10 10:26:16 +00:00
PATCH_COMMAND "patch" "-p1" "<" "${CMAKE_CURRENT_SOURCE_DIR}/runtime.patch"
2024-11-11 00:05:25 +00:00
# Disable Other Commands
INSTALL_COMMAND ""
TEST_COMMAND ""
2024-06-04 21:50:17 +00:00
)
2024-11-10 10:26:16 +00:00
# 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)
2024-06-04 21:50:17 +00:00
# Install
2024-11-10 10:26:16 +00:00
if(DEFINED MCPI_LIB_DIR)
install(PROGRAMS "${QEMU_LIBRARY}" DESTINATION "${MCPI_LIB_DIR}")
2024-06-04 21:50:17 +00:00
# License
2024-11-10 10:26:16 +00:00
ExternalProject_Get_Property(qemu SOURCE_DIR)
install(FILES "${SOURCE_DIR}/COPYING" DESTINATION "${MCPI_LEGAL_DIR}/qemu")
endif()