Improve CMake Superbuild

This commit is contained in:
TheBrokenRail 2024-01-16 03:08:34 -05:00
parent 5c607d96b8
commit 40cd1b0a14
5 changed files with 19 additions and 8 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16.0) cmake_minimum_required(VERSION 3.17.0)
# Avoid Warning About DOWNLOAD_EXTRACT_TIMESTAMP # Avoid Warning About DOWNLOAD_EXTRACT_TIMESTAMP
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24.0) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24.0)
@ -43,8 +43,8 @@ if(BUILD_NATIVE_COMPONENTS)
# Arguments # Arguments
set(ARM_OPTIONS "${MCPI_OPTIONS}") set(ARM_OPTIONS "${MCPI_OPTIONS}")
list(APPEND ARM_OPTIONS "-DMCPI_BUILD_MODE:STRING=arm") list(APPEND ARM_OPTIONS "-DMCPI_BUILD_MODE:STRING=arm")
macro(add_arm_option option) list(APPEND ARM_OPTIONS "-DCMAKE_INSTALL_MESSAGE:STRING=NEVER")
endmacro() list(APPEND ARM_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>/install")
if(NOT MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN) if(NOT MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN)
if(DEFINED CMAKE_TOOLCHAIN_FILE) if(DEFINED CMAKE_TOOLCHAIN_FILE)
list(APPEND ARM_OPTIONS "-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE}") list(APPEND ARM_OPTIONS "-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_TOOLCHAIN_FILE}")
@ -57,11 +57,19 @@ if(BUILD_NATIVE_COMPONENTS)
DOWNLOAD_COMMAND "" DOWNLOAD_COMMAND ""
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
CMAKE_CACHE_ARGS ${ARM_OPTIONS} CMAKE_CACHE_ARGS ${ARM_OPTIONS}
INSTALL_COMMAND "${CMAKE_COMMAND}" "-E" "rm" "-rf" "<INSTALL_DIR>/install"
COMMAND
"${CMAKE_COMMAND}" "-E" "env"
"DESTDIR="
"${CMAKE_COMMAND}" "--install" "<BINARY_DIR>"
USES_TERMINAL_CONFIGURE TRUE USES_TERMINAL_CONFIGURE TRUE
USES_TERMINAL_BUILD TRUE USES_TERMINAL_BUILD TRUE
USES_TERMINAL_INSTALL TRUE USES_TERMINAL_INSTALL TRUE
BUILD_ALWAYS TRUE BUILD_ALWAYS TRUE
) )
# Install
ExternalProject_Get_Property(arm-components INSTALL_DIR)
install(DIRECTORY "${INSTALL_DIR}/install/${MCPI_INSTALL_DIR}/" DESTINATION "${MCPI_INSTALL_DIR}")
endif() endif()
# Required Compile Flags # Required Compile Flags

View File

@ -13,11 +13,15 @@ endif()
# Build # Build
include(ExternalProject) 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 ExternalProject_Add(qemu
URL "${CMAKE_CURRENT_SOURCE_DIR}/../../archives/qemu-${QEMU_VERSION}.tar.xz" URL "${CMAKE_CURRENT_SOURCE_DIR}/../../archives/qemu-${QEMU_VERSION}.tar.xz"
CONFIGURE_COMMAND CONFIGURE_COMMAND
"${CMAKE_COMMAND}" "-E" "env" "${CMAKE_COMMAND}" "-E" "env"
"PKG_CONFIG_LIBDIR=$ENV{PKG_CONFIG_LIBDIR}" ${pkgconfig_env}
"CFLAGS=-s" "CFLAGS=-s"
"CXXFLAGS=-s" "CXXFLAGS=-s"
"<SOURCE_DIR>/configure" "<SOURCE_DIR>/configure"

View File

@ -36,13 +36,11 @@ endif()
# Fake LibPNG To Satisy Symbol Versioning Requirement # Fake LibPNG To Satisy Symbol Versioning Requirement
if(BUILD_ARM_COMPONENTS) if(BUILD_ARM_COMPONENTS)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/fake-libpng.c" "") add_library(fake-libpng SHARED src/fake-libpng/empty.c)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/fake-libpng.vers" "PNG12_0 { global: *; };")
add_library(fake-libpng SHARED "${CMAKE_CURRENT_BINARY_DIR}/fake-libpng.c")
set_target_properties(fake-libpng PROPERTIES set_target_properties(fake-libpng PROPERTIES
OUTPUT_NAME "png12" OUTPUT_NAME "png12"
SOVERSION 0 SOVERSION 0
LINK_OPTIONS "LINKER:--version-script=${CMAKE_CURRENT_BINARY_DIR}/fake-libpng.vers" LINK_OPTIONS "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/fake-libpng/empty.vers"
) )
# Install # Install
install(TARGETS fake-libpng DESTINATION "${MCPI_LIB_DIR}") install(TARGETS fake-libpng DESTINATION "${MCPI_LIB_DIR}")

View File

View File

@ -0,0 +1 @@
PNG12_0 { global: *; };