From 6ade591a6e25d6bb5a3f5e8348f6008ddaa0c097 Mon Sep 17 00:00:00 2001 From: Rick V Date: Tue, 27 Aug 2019 07:05:37 -0500 Subject: [PATCH] add native build option --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dde5b7850..4e09a39b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ project(${PROJECT_NAME} C CXX) option(USE_AVX2 "enable avx2 code" ) option(USE_NETNS "enable networking namespace support. Linux only" ) option(AMD_RYZEN_HACK "hack for AMD Ryzen FPU bug (support FMA3 and FMA4 in FPU, but does not show in CPUID)" ) +option(NATIVE_BUILD "optimise for host system and FPU, may not be portable" ) if (NOT MSVC) option(STATIC_LINK_RUNTIME "link statically against compiler runtime, standard library and pthreads") endif() @@ -157,6 +158,11 @@ if(AMD_RYZEN_HACK AND USE_AVX2) message(WARNING "This option may be removed in a future release. Contact your computer manufacturer for updated ROMs or microcode patches.") endif(AMD_RYZEN_HACK AND USE_AVX2) +if(NATIVE_BUILD) + message(WARNING "May fail at runtime if the floating-point unit on the target system does not implement required features, some platforms will check this for you") + set(CRYPTO_FLAGS -march=native -mfpmath=sse -mtune=native) +endif() + add_compile_options(${OPTIMIZE_FLAGS} ${CRYPTO_FLAGS}) set(CMAKE_THREAD_PREFER_PTHREAD TRUE)