minecraft-pi-reborn/CMakeLists.txt

124 lines
3.3 KiB
CMake
Raw Normal View History

2021-06-17 21:32:24 +00:00
cmake_minimum_required(VERSION 3.13.0)
# Specify Options
option(MCPI_USE_MEDIA_LAYER_PROXY "Whether To Enable The Media Layer Proxy" FALSE)
option(MCPI_SERVER_MODE "Server Mode" FALSE)
2021-08-27 02:52:18 +00:00
option(MCPI_HEADLESS_MODE "Headless Mode" ${MCPI_SERVER_MODE})
2021-07-01 20:01:17 +00:00
set(MCPI_BUILD_MODE "both" CACHE STRING "\"arm\" = Build Only Code That Must Be ARM; \"native\" = Build Architecture-Independent Code; \"both\" = Build All Code As ARM")
2021-06-17 21:32:24 +00:00
set_property(CACHE MCPI_BUILD_MODE PROPERTY STRINGS "both" "arm" "native")
2021-12-19 21:09:16 +00:00
option(MCPI_OPEN_SOURCE_ONLY "Only Install Open-Source Code (Will Result In Broken Install)" FALSE)
2022-03-09 23:47:31 +00:00
option(MCPI_IS_APPIMAGE_BUILD "AppImage Build" FALSE)
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)
elseif(MCPI_BUILD_MODE STREQUAL "both")
set(USE_ARM32_TOOLCHAIN TRUE)
set(BUILD_ARM_COMPONENTS TRUE)
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)
set(MCPI_VARIANT_NAME "${MCPI_VARIANT_NAME}-server")
else()
set(MCPI_VARIANT_NAME "${MCPI_VARIANT_NAME}-client")
endif()
# Specify Installation Paths
2021-12-18 00:07:58 +00:00
set(MCPI_INSTALL_DIR "lib/${MCPI_VARIANT_NAME}")
2021-06-17 21:32:24 +00:00
set(MCPI_LIB_DIR "${MCPI_INSTALL_DIR}/lib")
set(MCPI_FALLBACK_LIB_DIR "${MCPI_INSTALL_DIR}/fallback-lib")
# Optimizations
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_options(-O3)
else()
add_compile_options(-g)
endif()
# Start Project
project(minecraft-pi-reborn)
2021-12-17 23:19:23 +00:00
# Require ARM Compilation
if(USE_ARM32_TOOLCHAIN AND (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "arm") AND (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l"))
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()
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-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)
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-11-12 22:11:11 +00:00
# Fast Math
add_compile_options(-ffast-math)
2021-06-17 21:32:24 +00:00
# Specify Constants
if(MCPI_SERVER_MODE)
add_definitions(-DMCPI_SERVER_MODE)
endif()
2021-08-27 02:52:18 +00:00
if(MCPI_HEADLESS_MODE)
add_definitions(-DMCPI_HEADLESS_MODE)
endif()
2022-03-09 23:47:31 +00:00
if(MCPI_IS_APPIMAGE_BUILD)
add_definitions(-DMCPI_IS_APPIMAGE_BUILD)
endif()
2021-06-17 21:32:24 +00:00
2021-06-28 20:00:52 +00:00
# Version
file(STRINGS VERSION VERSION)
add_definitions(-DVERSION="${VERSION}")
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()