From 3b7b6beca56b32be5d88bd2c93de081e7242806a Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 3 Dec 2024 20:18:24 +0200 Subject: [PATCH] ports: Allow using banan-os cmake toolchain file for ports --- ports/install.sh | 4 +++- toolchain/Toolchain.txt | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ports/install.sh b/ports/install.sh index 14699f9c..9a9694e6 100755 --- a/ports/install.sh +++ b/ports/install.sh @@ -6,7 +6,7 @@ if (( $# != 1 )); then fi if [[ -z $BANAN_ROOT_DIR ]]; then - BANAN_ROOT_DIR="$(realpath $(dirname $(realpath $0))/..)" + export BANAN_ROOT_DIR="$(realpath $(dirname $(realpath $0))/..)" fi source "$BANAN_ROOT_DIR/script/config.sh" @@ -29,6 +29,8 @@ export OBJDUMP="$BANAN_TOOLCHAIN_TRIPLE-objdump" export STRIP="$BANAN_TOOLCHAIN_TRIPLE-strip" export CXXFILT="$BANAN_TOOLCHAIN_TRIPLE-c++filt" +export CMAKE_TOOLCHAIN_FILE="$BANAN_TOOLCHAIN_DIR/Toolchain.txt" + pushd "$BANAN_ROOT_DIR" >/dev/null ./bos all && ./bos install || exit 1 popd >/dev/null diff --git a/toolchain/Toolchain.txt b/toolchain/Toolchain.txt index 8acce806..5b12ce4f 100644 --- a/toolchain/Toolchain.txt +++ b/toolchain/Toolchain.txt @@ -13,12 +13,21 @@ if (NOT DEFINED ENV{BANAN_SYSROOT_TAR}) endif () set(BANAN_SYSROOT_TAR $ENV{BANAN_SYSROOT_TAR}) - -set(TOOLCHAIN_PREFIX ${CMAKE_SOURCE_DIR}/toolchain/local) +if (NOT DEFINED ENV{BANAN_ROOT_DIR}) + message(FATAL_ERROR "environment variable BANAN_ROOT_DIR not defined") +endif () +set(TOOLCHAIN_PREFIX $ENV{BANAN_ROOT_DIR}/toolchain/local) set(CMAKE_SYSTEM_NAME banan-os) set(CMAKE_SYSTEM_PROCESSOR AMD64) +set(CMAKE_SYSROOT ${BANAN_SYSROOT}) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) + set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}/bin/${BANAN_ARCH}-banan_os-g++)