Skip to content

Commit

Permalink
Add CMake options to enable optimization flags #41
Browse files Browse the repository at this point in the history
  • Loading branch information
jurihock committed Dec 12, 2023
1 parent e7c581e commit 53c9dd8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ option(DEB "Enable deb package build for library and executable" OFF)
option(BREW "Enable homebrew package build for library and executable" OFF)
option(WASM "Enable web assembly build" OFF)

option(FASTMATH "Enable fast math" OFF)
option(FASTATAN "Enable fast atan2" OFF)

if(MSVC)

# optionally treat warnings as errors
Expand Down
23 changes: 23 additions & 0 deletions cpp/StftPitchShift/LibStftPitchShift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,29 @@ target_compile_features(${PROJECT_NAME}
PRIVATE cxx_std_20
)

if(FASTMATH)

message(STATUS "Enabling fast math")

if(MSVC)
target_compile_options(${PROJECT_NAME}
PRIVATE /fp:fast)
else()
target_compile_options(${PROJECT_NAME}
PRIVATE -ffast-math)
endif()

endif()

if(FASTATAN)

message(STATUS "Defining ENABLE_ARCTANGENT_APPROXIMATION")

target_compile_definitions(${PROJECT_NAME}
PRIVATE -DENABLE_ARCTANGENT_APPROXIMATION)

endif()

install(
TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand Down

0 comments on commit 53c9dd8

Please sign in to comment.