diff options
author | Riccardo Spagni <ric@spagni.net> | 2016-08-28 22:49:09 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2016-08-28 22:49:09 +0200 |
commit | 53a0997a260472d4efb777e8aaa90230cd229421 (patch) | |
tree | e6623e65f1dbc500eeadb6451c6819d2854dcc69 /CMakeLists.txt | |
parent | Merge pull request #995 (diff) | |
parent | cmake: define ARM var for all ARM arch variants (diff) | |
download | monero-53a0997a260472d4efb777e8aaa90230cd229421.tar.xz |
Merge pull request #997
1c7d3b0 cmake: define ARM var for all ARM arch variants (redfish)
6fe543d cmake: ARM: exclude libunwind in static build (redfish)
397b720 make: remove NO_AES from arm targets (redfish)
57ca3f3 make: make the ARM release targets statically linked (redfish)
43c07a1 readme: editted install/build instructions for clarity (redfish)
a0d4058 Revert "makefile: remove unnecessary ARM-specific targets" (redfish)
c2bc34b Revert "Interpret x86_64 as x86-64 for architecture" (redfish)
c54b9a1 cmake: don't set ARCH from CMAKE_SYSTEM_PROCESSOR (redfish)
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bb8a621d7..5b382264b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,34 +45,33 @@ function (die msg) message(FATAL_ERROR "${BoldRed}${msg}${ColourReset}") endfunction () -if ("${ARCH}" STREQUAL "" OR "${ARCH}" STREQUAL "native") - set(ARCH ${CMAKE_SYSTEM_PROCESSOR}) - message(STATUS "Building natively on ${ARCH}") +# ARCH defines the target architecture, either by an explicit identifier or +# one of the following two keywords. By default, ARCH a value of 'native': +# 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() - -if (NOT "${ARCH}" STREQUAL "") - string(SUBSTRING ${ARCH} 0 3 IS_ARM) - string(TOLOWER ${IS_ARM} IS_ARM) - - if (${IS_ARM} STREQUAL "arm") - string(SUBSTRING ${ARCH} 0 5 ARM_TEST) - 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() +string(TOLOWER ${ARCH_ID} ARM_ID) +string(SUBSTRING ${ARCH_ID} 0 3 ARM_TEST) +if (ARM_TEST STREQUAL "arm") + set(ARM 1) + string(SUBSTRING ${ARCH_ID} 0 5 ARM_TEST) + if (ARM_TEST STREQUAL "armv6") + set(ARM6 1) + endif() + if (ARM_TEST STREQUAL "armv7") + set(ARM7 1) endif() endif() -if(WIN32 OR ARM7 OR ARM6) +if(WIN32 OR ARM) set(OPT_FLAGS_RELEASE "-O2") else() set(OPT_FLAGS_RELEASE "-Ofast") @@ -247,7 +246,8 @@ add_definitions("-DBLOCKCHAIN_DB=${BLOCKCHAIN_DB}") find_package(Libunwind) # Can't install hook in static build on OSX, because OSX linker does not support --wrap -if(LIBUNWIND_FOUND AND NOT (STATIC AND APPLE)) +# On ARM, having libunwind package (with .so's only) installed breaks static link. +if(LIBUNWIND_FOUND AND NOT (STATIC AND (APPLE OR ARM))) set(DEFAULT_STACK_TRACE ON) else() set(DEFAULT_STACK_TRACE OFF) @@ -308,16 +308,12 @@ if(MSVC) endif() include_directories(SYSTEM src/platform/msc) else() - set(ARCH native CACHE STRING "CPU to build for: -march value or default") - # -march=armv7-a conflicts with -mcpu=cortex-a7 - if(ARCH STREQUAL "default" OR ARM7 OR ARM6) + set(ARCH native CACHE STRING "CPU to build for: -march value or 'default' to not pass -march at all") + message(STATUS "Building on ${CMAKE_SYSTEM_PROCESSOR} for ${ARCH}") + if(ARCH STREQUAL "default") set(ARCH_FLAG "") else() - if(ARCH STREQUAL "x86_64") - set(ARCH_FLAG "-march=x86-64") - else() - set(ARCH_FLAG "-march=${ARCH}") - endif() + set(ARCH_FLAG "-march=${ARCH}") endif() set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-variable -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized") if(NOT MINGW) @@ -325,7 +321,7 @@ else() endif() if(CMAKE_C_COMPILER_ID STREQUAL "Clang") set(WARNINGS "${WARNINGS} -Wno-deprecated-register -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration") - if(ARM6 OR ARM7) + if(ARM) set(WARNINGS "${WARNINGS} -Wno-error=inline-asm") endif() else() @@ -362,11 +358,11 @@ else() option(NO_AES "Explicitly disable AES support" ${NO_AES}) - if(NOT NO_AES AND NOT (ARM6 OR ARM7)) + if(NOT NO_AES AND NOT ARM) message(STATUS "AES support enabled") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes") - elseif(ARM7 OR ARM6) + elseif(ARM) message(STATUS "AES support disabled (not available on ARM)") else() message(STATUS "AES support disabled") |