mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-25 17:02:26 +00:00
cmake: don't set ARCH from CMAKE_SYSTEM_PROCESSOR
It is not correct to do so, because ARCH should only take values supported by the -march argument, with the exception of 'default' which denotes not passing -march at all. ARCH defines the target architecture for builds that are intended to be portable to other machines.
This commit is contained in:
parent
a569b264bc
commit
c54b9a1a05
1 changed files with 22 additions and 27 deletions
|
@ -45,31 +45,26 @@ function (die msg)
|
||||||
message(FATAL_ERROR "${BoldRed}${msg}${ColourReset}")
|
message(FATAL_ERROR "${BoldRed}${msg}${ColourReset}")
|
||||||
endfunction ()
|
endfunction ()
|
||||||
|
|
||||||
if ("${ARCH}" STREQUAL "" OR "${ARCH}" STREQUAL "native")
|
# ARCH defines the target architecture, either by an explicit identifier or
|
||||||
set(ARCH ${CMAKE_SYSTEM_PROCESSOR})
|
# one of the following two keywords. By default, ARCH a value of 'native':
|
||||||
message(STATUS "Building natively on ${ARCH}")
|
# target arch = host arch, binary is not portable. When ARCH is set to the
|
||||||
|
# string 'default', no -march arg is passed, which creates a binary that is
|
||||||
|
# portable across processors in the same family as host processor. In cases
|
||||||
|
# when ARCH is not set to an explicit identifier, cmake's builtin is used
|
||||||
|
# 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")
|
||||||
|
set(ARCH_ID "${CMAKE_SYSTEM_PROCESSOR}")
|
||||||
|
else()
|
||||||
|
set(ARCH_ID "${ARCH}")
|
||||||
endif()
|
endif()
|
||||||
|
string(SUBSTRING ${ARCH_ID} 0 5 ARM_TEST)
|
||||||
if (NOT "${ARCH}" STREQUAL "")
|
string(TOLOWER ${ARM_TEST} ARM_TEST)
|
||||||
string(SUBSTRING ${ARCH} 0 3 IS_ARM)
|
if (${ARM_TEST} STREQUAL "armv6")
|
||||||
string(TOLOWER ${IS_ARM} IS_ARM)
|
set(ARM6 1)
|
||||||
|
endif()
|
||||||
if (${IS_ARM} STREQUAL "arm")
|
if (${ARM_TEST} STREQUAL "armv7")
|
||||||
string(SUBSTRING ${ARCH} 0 5 ARM_TEST)
|
set(ARM7 1)
|
||||||
string(TOLOWER ${ARM_TEST} ARM_TEST)
|
|
||||||
|
|
||||||
if (${ARM_TEST} STREQUAL "armv6")
|
|
||||||
set(ARM6 1)
|
|
||||||
else()
|
|
||||||
set(ARM6 0)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (${ARM_TEST} STREQUAL "armv7")
|
|
||||||
set(ARM7 1)
|
|
||||||
else()
|
|
||||||
set(ARM7 0)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32 OR ARM7 OR ARM6)
|
if(WIN32 OR ARM7 OR ARM6)
|
||||||
|
@ -312,9 +307,9 @@ if(MSVC)
|
||||||
endif()
|
endif()
|
||||||
include_directories(SYSTEM src/platform/msc)
|
include_directories(SYSTEM src/platform/msc)
|
||||||
else()
|
else()
|
||||||
set(ARCH native CACHE STRING "CPU to build for: -march value or default")
|
set(ARCH native CACHE STRING "CPU to build for: -march value or 'default' to not pass -march at all")
|
||||||
# -march=armv7-a conflicts with -mcpu=cortex-a7
|
message(STATUS "Building on ${CMAKE_SYSTEM_PROCESSOR} for ${ARCH}")
|
||||||
if(ARCH STREQUAL "default" OR ARM7 OR ARM6)
|
if(ARCH STREQUAL "default")
|
||||||
set(ARCH_FLAG "")
|
set(ARCH_FLAG "")
|
||||||
else()
|
else()
|
||||||
if(ARCH STREQUAL "x86_64")
|
if(ARCH STREQUAL "x86_64")
|
||||||
|
|
Loading…
Reference in a new issue