Skip to content

Commit 106c557

Browse files
committed
adds cmake option to allow -march=native builds (performance
optimization)
1 parent 56e6934 commit 106c557

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
77
project(dbt-rise-riscv VERSION 2.1.0 LANGUAGES C CXX)
88

99
option(UPDATE_EXTERNAL_PROJECT "Whether to pull changes in external projects" ON)
10+
option(OPTIMIZE_FOR_NATIVE "Build with -march=native" OFF)
1011

1112
include(GNUInstallDirs)
1213
include(flink)
1314

1415
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1516
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1617

18+
include(CheckCXXCompilerFlag)
19+
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
20+
if(OPTIMIZE_FOR_NATIVE AND COMPILER_SUPPORTS_MARCH_NATIVE)
21+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
22+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
23+
endif()
24+
1725
include(FetchContent)
1826
if(NOT TARGET dbt-rise-core)
1927
FetchContent_Declare(

0 commit comments

Comments
 (0)