cmake: Don't default to -march=native on OpenBSD

This commit is contained in:
Nathan Dorfman 2021-03-24 15:34:06 -06:00
parent 9ec4ce36c7
commit fd869a7b64
1 changed files with 12 additions and 1 deletions

View File

@ -501,6 +501,17 @@ endif()
# Trezor support check # Trezor support check
include(CheckTrezor) include(CheckTrezor)
# As of OpenBSD 6.8, -march=<anything> breaks the build
function(set_default_arch)
if (OPENBSD)
set(ARCH default)
else()
set(ARCH native)
endif()
set(ARCH ${ARCH} CACHE STRING "CPU to build for: -march value or 'default' to not pass -march at all")
endfunction()
if(MSVC) if(MSVC)
add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__") add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline") # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline")
@ -514,7 +525,7 @@ if(MSVC)
else() else()
include(TestCXXAcceptsFlag) include(TestCXXAcceptsFlag)
if (NOT ARCH) if (NOT ARCH)
set(ARCH native CACHE STRING "CPU to build for: -march value or 'default' to not pass -march at all") set_default_arch()
endif() endif()
message(STATUS "Building on ${CMAKE_SYSTEM_PROCESSOR} for ${ARCH}") message(STATUS "Building on ${CMAKE_SYSTEM_PROCESSOR} for ${ARCH}")
if(ARCH STREQUAL "default") if(ARCH STREQUAL "default")