summaryrefslogtreecommitdiffstats
path: root/SetFlags.cmake
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-01-31 16:09:59 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2021-02-11 02:24:50 +0100
commit2f1359a0f91ef216bc34fb5732ad7f9e4bfe3d52 (patch)
tree3f3f2b8c39fda4a67e8bcfca7cf52fb2c142b206 /SetFlags.cmake
parentTurn off SQLITE_ENABLE_JSON1 (diff)
downloadcuberite-2f1359a0f91ef216bc34fb5732ad7f9e4bfe3d52.tar
cuberite-2f1359a0f91ef216bc34fb5732ad7f9e4bfe3d52.tar.gz
cuberite-2f1359a0f91ef216bc34fb5732ad7f9e4bfe3d52.tar.bz2
cuberite-2f1359a0f91ef216bc34fb5732ad7f9e4bfe3d52.tar.lz
cuberite-2f1359a0f91ef216bc34fb5732ad7f9e4bfe3d52.tar.xz
cuberite-2f1359a0f91ef216bc34fb5732ad7f9e4bfe3d52.tar.zst
cuberite-2f1359a0f91ef216bc34fb5732ad7f9e4bfe3d52.zip
Diffstat (limited to 'SetFlags.cmake')
-rw-r--r--SetFlags.cmake13
1 files changed, 11 insertions, 2 deletions
diff --git a/SetFlags.cmake b/SetFlags.cmake
index 4ef8ecd2a..d3a7801ee 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -96,9 +96,18 @@ function(set_global_flags)
add_link_options(-m32)
endif()
+ # https://en.wikipedia.org/wiki/Uname
+ # https://gcc.gnu.org/onlinedocs/gcc/index.html
# Have the compiler generate code specifically targeted at the current machine on Linux:
- if(LINUX AND NOT NO_NATIVE_OPTIMIZATION)
- add_compile_options(-march=native)
+ if(UNIX AND NOT NO_NATIVE_OPTIMIZATION AND NOT CMAKE_CROSSCOMPILING)
+ string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} SYSTEM_PROCESSOR)
+ if (SYSTEM_PROCESSOR MATCHES "^(i386|i686|x86|amd64|mips)")
+ message(STATUS "Optimising for this machine (march=native)")
+ add_compile_options(-march=native)
+ elseif (SYSTEM_PROCESSOR MATCHES "^(arm|aarch|powerpc|ppc|sparc|alpha)")
+ message(STATUS "Optimising for this machine (mcpu=native)")
+ add_compile_options(-mcpu=native)
+ endif()
endif()
endfunction()