From 5a5fe4c7310a0a494b00cfa88be1354f75227ced Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 17 Dec 2021 18:19:23 -0500 Subject: [PATCH] Fix CMake --- CMakeLists.txt | 10 +++++----- docs/BUILDING.md | 2 +- scripts/build.sh | 7 +++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9b272a20..850571019 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,11 +32,6 @@ if(NOT DEFINED CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER "clang++") endif() -# Setup ARM Cross Compilation -if(USE_ARM32_TOOLCHAIN) - include(cmake/armhf-toolchain.cmake) -endif() - # Utility Functions include(cmake/util.cmake) @@ -67,6 +62,11 @@ endif() # Start Project project(minecraft-pi-reborn) +# 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() + # Specify Default Installation Prefix if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "/" CACHE PATH "" FORCE) diff --git a/docs/BUILDING.md b/docs/BUILDING.md index da1fb4f4f..614b6aca7 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -46,7 +46,7 @@ mkdir build && cd build # Build ARM Components mkdir arm && cd arm -cmake -DMCPI_BUILD_MODE=arm ../.. +cmake -DCMAKE_TOOLCHAIN_FILE=../../cmake/armhf-toolchain.cmake -DMCPI_BUILD_MODE=arm ../.. make -j$(nproc) && sudo make install cd ../ diff --git a/scripts/build.sh b/scripts/build.sh index d74155b5a..ea6a6ff27 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -2,6 +2,9 @@ set -e +# ARM Toolchain File +ARM_TOOLCHAIN_FILE="$(pwd)/cmake/armhf-toolchain.cmake" + # Build build() { # Find Toolchain @@ -30,7 +33,7 @@ build() { # Build ARM Components mkdir arm cd arm - cmake -DMCPI_BUILD_MODE=arm "${extra_arg}" ../../.. + cmake -DCMAKE_TOOLCHAIN_FILE="${ARM_TOOLCHAIN_FILE}" -DMCPI_BUILD_MODE=arm "${extra_arg}" ../../.. make -j$(nproc) make install DESTDIR="${prefix}" cd ../ @@ -66,7 +69,7 @@ armhf_build() { fi # Build All Components - cmake -DMCPI_BUILD_MODE=both -DMCPI_SERVER_MODE="${server_mode}" ../.. + cmake -DCMAKE_TOOLCHAIN_FILE="${ARM_TOOLCHAIN_FILE}" -DMCPI_BUILD_MODE=both -DMCPI_SERVER_MODE="${server_mode}" ../.. make -j$(nproc) make install DESTDIR="${prefix}"