diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dffa371faa..2dc43b8d47 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -143,6 +143,12 @@ if(GSOAP_FOUND) endif() +# GCC 12+ only vectorizes with its very-cheap cost model at -O2, which leaves the +# per-pixel motion detection loop in zm_zone.cpp scalar in Release builds. +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set_source_files_properties(zm_zone.cpp PROPERTIES COMPILE_OPTIONS "-fvect-cost-model=dynamic") +endif() + # A fix for cmake recompiling the source files for every target. add_library(zm STATIC ${ZM_BIN_SRC_FILES})