minecraft-pi-reborn/CMakeLists.txt

173 lines
4.9 KiB
CMake
Raw Normal View History

2022-06-10 01:31:40 +00:00
cmake_minimum_required(VERSION 3.16.0)
2021-06-17 21:32:24 +00:00
# Specify Options
option(MCPI_IS_MIXED_BUILD "Whether The Architecture-Independent And ARM Code Are Different Architecture" FALSE)
2022-07-02 22:14:23 +00:00
set(MCPI_BUILD_MODE "native" CACHE STRING "\"arm\" = Build Only Code That Must Be ARM; \"native\" = Build Architecture-Independent Code")
set_property(CACHE MCPI_BUILD_MODE PROPERTY STRINGS "arm" "native")
2022-06-10 01:31:40 +00:00
option(MCPI_OPEN_SOURCE_ONLY "Only Install Open-Source Code (Will Result In Broken Install)" FALSE)
option(MCPI_IS_APPIMAGE_BUILD "AppImage Build" FALSE)
# Server/Headless Builds
2021-06-17 21:32:24 +00:00
option(MCPI_SERVER_MODE "Server Mode" FALSE)
2021-08-27 02:52:18 +00:00
option(MCPI_HEADLESS_MODE "Headless Mode" ${MCPI_SERVER_MODE})
2022-06-10 01:31:40 +00:00
# ARMHF Sysroot
option(MCPI_BUNDLE_ARMHF_SYSROOT "Whether To Include An ARMHF Sysroot" ${MCPI_IS_MIXED_BUILD})
set(MCPI_CUSTOM_BUNDLED_ARMHF_SYSROOT "" CACHE PATH "Custom Bundled ARMHF Sysroot")
# Media Layer
if(NOT MCPI_HEADLESS_MODE)
option(MCPI_USE_MEDIA_LAYER_PROXY "Whether To Enable The Media Layer Proxy" ${MCPI_IS_MIXED_BUILD})
option(MCPI_USE_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" TRUE)
else()
set(MCPI_USE_MEDIA_LAYER_PROXY FALSE)
set(MCPI_USE_GLES1_COMPATIBILITY_LAYER FALSE)
endif()
2022-06-10 01:31:40 +00:00
# App ID
set(DEFAULT_APP_ID "com.thebrokenrail.MCPIReborn")
if(MCPI_SERVER_MODE)
string(APPEND DEFAULT_APP_ID "Server")
else()
string(APPEND DEFAULT_APP_ID "Client")
endif()
set(MCPI_APP_ID "${DEFAULT_APP_ID}" CACHE STRING "App ID")
# App Title
set(DEFAULT_APP_TITLE "Minecraft: Pi Edition: Reborn")
if(MCPI_SERVER_MODE)
string(APPEND DEFAULT_APP_TITLE " (Server)")
else()
string(APPEND DEFAULT_APP_TITLE " (Client)")
endif()
set(MCPI_APP_TITLE "${DEFAULT_APP_TITLE}" CACHE STRING "App Title")
2021-06-17 21:32:24 +00:00
# Configure Build Mode
if(MCPI_BUILD_MODE STREQUAL "arm")
set(USE_ARM32_TOOLCHAIN TRUE)
set(BUILD_ARM_COMPONENTS TRUE)
set(BUILD_NATIVE_COMPONENTS FALSE)
elseif(MCPI_BUILD_MODE STREQUAL "native")
set(USE_ARM32_TOOLCHAIN FALSE)
set(BUILD_ARM_COMPONENTS FALSE)
set(BUILD_NATIVE_COMPONENTS TRUE)
else()
message(FATAL_ERROR "Invalid Mode")
endif()
# Utility Functions
include(cmake/util.cmake)
# Specify Variant Name
set(MCPI_VARIANT_NAME "minecraft-pi-reborn")
if(MCPI_SERVER_MODE)
2022-06-10 01:31:40 +00:00
string(APPEND MCPI_VARIANT_NAME "-server")
2021-06-17 21:32:24 +00:00
else()
2022-06-10 01:31:40 +00:00
string(APPEND MCPI_VARIANT_NAME "-client")
2021-06-17 21:32:24 +00:00
endif()
# Specify Installation Paths
2021-12-18 00:07:58 +00:00
set(MCPI_INSTALL_DIR "lib/${MCPI_VARIANT_NAME}")
2022-03-12 01:02:38 +00:00
set(MCPI_BIN_DIR "${MCPI_INSTALL_DIR}/bin")
2022-06-25 21:30:08 +00:00
set(MCPI_SDK_DIR "${MCPI_INSTALL_DIR}/sdk")
set(MCPI_SDK_LIB_DIR "${MCPI_SDK_DIR}/lib")
set(MCPI_SDK_INCLUDE_DIR "${MCPI_SDK_DIR}/include")
2021-06-17 21:32:24 +00:00
2022-07-02 22:14:23 +00:00
# Library Directory
set(MCPI_LIB_DIR "${MCPI_INSTALL_DIR}/lib")
if(BUILD_ARM_COMPONENTS)
string(APPEND MCPI_LIB_DIR "/arm")
elseif(BUILD_NATIVE_COMPONENTS)
string(APPEND MCPI_LIB_DIR "/native")
endif()
2022-03-11 05:00:13 +00:00
# Build Mode
2021-06-17 21:32:24 +00:00
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
# Start Project
project(minecraft-pi-reborn)
2022-05-11 22:24:03 +00:00
# Sanity Check
if(BUILD_NATIVE_COMPONENTS AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND NOT MCPI_IS_MIXED_BUILD)
message(FATAL_ERROR "Project is configured as a mixed-buld, but MCPI_IS_MIXED_BUILD is disabled.")
endif()
2021-12-17 23:19:23 +00:00
# Require ARM Compilation
2022-05-03 02:44:10 +00:00
if(USE_ARM32_TOOLCHAIN AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
2021-12-17 23:19:23 +00:00
message(FATAL_ERROR "ARM-Targeting Compiler Required")
endif()
2021-06-17 21:32:24 +00:00
# Specify Default Installation Prefix
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
2021-12-18 00:07:58 +00:00
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "" FORCE)
2021-06-17 21:32:24 +00:00
endif()
2022-03-11 05:00:13 +00:00
# Optimizations
if(CMAKE_BUILD_TYPE STREQUAL "Release")
2022-06-14 02:53:43 +00:00
add_compile_options(-O3 -s)
2022-03-11 05:00:13 +00:00
else()
add_compile_options(-g)
endif()
2021-11-02 21:50:26 +00:00
# Use LLD When Using Clang
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_link_options("-fuse-ld=lld")
endif()
2021-11-11 03:17:04 +00:00
# PIC
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
2022-03-11 05:00:13 +00:00
# Fast Math
add_compile_options(-ffast-math)
2022-03-10 02:23:41 +00:00
# Buld Dependencies
add_subdirectory(dependencies)
2021-06-17 21:32:24 +00:00
# Warnings
2021-07-05 01:23:12 +00:00
add_compile_options(-Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference)
2022-05-11 22:24:03 +00:00
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 10.0)
# Prevents False Positives
add_compile_options(-Wno-stringop-overflow)
endif()
2021-06-17 21:32:24 +00:00
add_link_options(-Wl,--no-undefined)
add_definitions(-D_GNU_SOURCE)
2021-07-05 01:23:12 +00:00
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
2021-06-17 21:32:24 +00:00
2021-06-28 20:00:52 +00:00
# Version
2022-05-03 02:52:52 +00:00
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS VERSION
)
2022-06-10 01:31:40 +00:00
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" MCPI_VERSION)
file(TIMESTAMP "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" MCPI_VERSION_DATE "%Y-%m-%d" UTC)
2021-06-28 20:00:52 +00:00
2021-06-17 21:32:24 +00:00
# Build libreborn
add_subdirectory(libreborn)
# Build Media Layer
add_subdirectory(media-layer)
# Build Launcher
if(BUILD_NATIVE_COMPONENTS)
add_subdirectory(launcher)
endif()
2021-09-12 03:18:12 +00:00
# Include Symbols
if(BUILD_ARM_COMPONENTS)
add_subdirectory(symbols)
endif()
2021-06-17 21:32:24 +00:00
# Build Mods
if(BUILD_ARM_COMPONENTS)
add_subdirectory(mods)
endif()
2022-04-22 23:38:15 +00:00
# Include Images
if(BUILD_NATIVE_COMPONENTS)
add_subdirectory(images)
endif()
2022-06-25 21:30:08 +00:00
# Install SDK
if(BUILD_ARM_COMPONENTS)
install(EXPORT sdk DESTINATION "${MCPI_SDK_DIR}" EXPORT_LINK_INTERFACE_LIBRARIES)
endif()