From 7e9ecf35dd0430c7587ef4af8617f15237a58dd9 Mon Sep 17 00:00:00 2001 From: TheCharlatan Date: Fri, 22 Feb 2019 15:18:32 +0000 Subject: [PATCH] cmake: ARCH_ID fixes for cross compilation --- CMakeLists.txt | 3 +++ contrib/depends/toolchain.cmake.in | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a995539c..f1f894dd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,9 @@ string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER) # to identify the target architecture, to direct logic in this cmake script. # Since ARCH is a cached variable, it will not be set on first cmake invocation. if (NOT ARCH OR ARCH STREQUAL "" OR ARCH STREQUAL "native" OR ARCH STREQUAL "default") + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "") + set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR}) + endif() set(ARCH_ID "${CMAKE_SYSTEM_PROCESSOR}") else() set(ARCH_ID "${ARCH}") diff --git a/contrib/depends/toolchain.cmake.in b/contrib/depends/toolchain.cmake.in index 66168facb..f11e7e922 100644 --- a/contrib/depends/toolchain.cmake.in +++ b/contrib/depends/toolchain.cmake.in @@ -41,6 +41,8 @@ set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # Find programs on host set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) # Find libs in target set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Find includes in target +set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR} CACHE STRING "" FORCE) + # specify the cross compiler to be used. Darwin uses clang provided by the SDK. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") SET(CMAKE_C_COMPILER @prefix@/native/bin/clang) @@ -85,6 +87,11 @@ endif() if(ARCHITECTURE STREQUAL "i686" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") SET(LINUX_32 ON) + SET(ARCH_ID "i386") +endif() + +if(ARCHITECTURE STREQUAL "x86_64" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") + SET(ARCH_ID "x86_64") endif() #Create a new global cmake flag that indicates building with depends