diff --git a/CMakeLists.txt b/CMakeLists.txt index fabd973..e0f9e08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/cpp/StftPitchShift/LibStftPitchShift.cmake b/cpp/StftPitchShift/LibStftPitchShift.cmake index 647b146..f206f14 100755 --- a/cpp/StftPitchShift/LibStftPitchShift.cmake +++ b/cpp/StftPitchShift/LibStftPitchShift.cmake @@ -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}"