Skip to content

Commit

Permalink
Change default PLATFORM from native to default
Browse files Browse the repository at this point in the history
`default` does not use any special optimizations and therefore
produces a more portable binary. Additionally it allows building
on platforms where `-march=native` or `-mtune=native` option
is not available (notably clang on Apple M1)

Fixes #303
  • Loading branch information
szpajder committed Dec 20, 2021
1 parent 5827b89 commit 085d62a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})

option(NFM "Enable support for narrow FM channels" OFF)

set(PLATFORM "native" CACHE STRING "Optimize the build for the given hardware platform")
set(PLATFORM "default" CACHE STRING "Optimize the build for the given hardware platform")

option(RTLSDR "Enable RTL-SDR support" ON)
set(WITH_RTLSDR FALSE)
Expand Down Expand Up @@ -190,10 +190,23 @@ elseif(PLATFORM STREQUAL "armv7-generic")
elseif(PLATFORM STREQUAL "armv8-generic")
add_definitions(-march=armv8-a+crc -mtune=cortex-a53)
elseif(PLATFORM STREQUAL "native")
add_definitions(-march=native -mtune=native)
CHECK_CXX_COMPILER_FLAG(-march=native CXX_HAS_MARCH_NATIVE)
if(CXX_HAS_MARCH_NATIVE)
add_definitions(-march=native)
else()
message(FATAL_ERROR "Cannot build with PLATFORM=native: the compiler does not support -march=native option")
endif()
CHECK_CXX_COMPILER_FLAG(-mtune=native CXX_HAS_MTUNE_NATIVE)
if(CXX_HAS_MTUNE_NATIVE)
add_definitions(-mtune=native)
else()
message(FATAL_ERROR "Cannot build with PLATFORM=native: the compiler does not support -mtune=native option")
endif()
elseif(PLATFORM STREQUAL "default")
# NOOP
else()
message(FATAL_ERROR "Unknown platform '${PLATFORM}'. Valid options are:
rpiv1, rpiv2, armv7-generic, armv8-generic, native")
rpiv1, rpiv2, armv7-generic, armv8-generic, native, default")
endif()

# Try using VC GPU if enabled. Fallback to fftw3f if disabled or if VC lib not found
Expand Down

0 comments on commit 085d62a

Please sign in to comment.