From 1597d2f886f75c1b9b90872d7fc7a9dbfb93701c Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 12 Oct 2021 03:30:08 +0300 Subject: [PATCH] Hermetic builds --- PreLoad.cmake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/PreLoad.cmake b/PreLoad.cmake index 0a25a55e7bf..be911bd9267 100644 --- a/PreLoad.cmake +++ b/PreLoad.cmake @@ -18,3 +18,20 @@ if (NOT DEFINED ENV{CLION_IDE} AND NOT DEFINED ENV{XCODE_IDE}) set(CMAKE_GENERATOR "Ninja" CACHE INTERNAL "" FORCE) endif () endif() + + +# Default toolchain - this is needed to avoid dependency on OS files. +execute_process(COMMAND uname -s OUTPUT_VARIABLE OS) +execute_process(COMMAND uname -m OUTPUT_VARIABLE ARCH) + +if (OS MATCHES "Linux" AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) + if (ARCH MATCHES "amd64|x86_64") + set (CMAKE_TOOLCHAIN_FILE "cmake/linux/toolchain-x86_64.cmake" CACHE INTERNAL "" FORCE) + elseif (ARCH MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)") + set (CMAKE_TOOLCHAIN_FILE "cmake/linux/toolchain-aarch64.cmake" CACHE INTERNAL "" FORCE) + elseif (ARCH MATCHES "^(ppc64le.*|PPC64LE.*)") + set (CMAKE_TOOLCHAIN_FILE "cmake/linux/toolchain-ppc64le.cmake" CACHE INTERNAL "" FORCE) + else () + message (FATAL_ERROR "Unsupported architecture: ${ARCH}") + endif () +endif()