2024-06-04 21:22:15 +00:00
|
|
|
cmake_minimum_required(VERSION 3.17.0)
|
|
|
|
|
|
|
|
# Start Project
|
2024-06-08 09:28:22 +00:00
|
|
|
project(runtime)
|
2024-06-04 21:22:15 +00:00
|
|
|
|
2024-06-04 21:50:17 +00:00
|
|
|
# Headers
|
|
|
|
add_library(trampoline-headers INTERFACE)
|
|
|
|
target_include_directories(trampoline-headers INTERFACE include)
|
2024-06-04 21:22:15 +00:00
|
|
|
|
2024-11-10 10:26:16 +00:00
|
|
|
# Check Architecture
|
|
|
|
include(CheckSymbolExists)
|
|
|
|
check_symbol_exists("__arm__" "" NO_RUNTIME_NEEDED)
|
|
|
|
if(NO_RUNTIME_NEEDED)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Only Headers
|
|
|
|
option(TRAMPOLINE_HEADERS_ONLY "Skip Building Runtime" FALSE)
|
|
|
|
if(TRAMPOLINE_HEADERS_ONLY)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
target_compile_definitions(trampoline-headers INTERFACE MCPI_BUILD_RUNTIME)
|
|
|
|
|
2024-06-04 21:50:17 +00:00
|
|
|
# Build
|
2024-11-10 10:26:16 +00:00
|
|
|
add_executable(runtime
|
|
|
|
src/main.cpp
|
|
|
|
src/trampoline.cpp
|
|
|
|
src/pipe/loop.cpp
|
|
|
|
src/pipe/main.cpp
|
|
|
|
src/pipe/memory.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
# QEMU
|
|
|
|
check_symbol_exists("__x86_64__" "" USE_QEMU)
|
|
|
|
if(USE_QEMU)
|
|
|
|
add_subdirectory(qemu)
|
|
|
|
target_sources(runtime PRIVATE
|
|
|
|
src/syscall/main.cpp
|
|
|
|
src/syscall/handler.cpp
|
|
|
|
src/qemu/qemu.cpp
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Warnings
|
|
|
|
target_compile_options(runtime PRIVATE -Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference)
|
|
|
|
|
|
|
|
# Link
|
|
|
|
target_link_libraries(runtime dl rt trampoline-headers)
|
|
|
|
|
|
|
|
# RPath
|
|
|
|
set_target_properties(runtime PROPERTIES INSTALL_RPATH "$ORIGIN/../lib/native")
|
|
|
|
target_link_options(runtime PRIVATE "LINKER:--disable-new-dtags")
|
|
|
|
|
|
|
|
# Install
|
|
|
|
if(DEFINED MCPI_BIN_DIR)
|
|
|
|
install(TARGETS runtime DESTINATION "${MCPI_BIN_DIR}")
|
2024-06-04 21:50:17 +00:00
|
|
|
endif()
|