@ -124,35 +124,33 @@ if(CMAKE_COMPILER_IS_GNUCXX)
# S S E 3 a n d f u r t h e r s h o u l d b e d i s a b l e d u n d e r M i n g W b e c a u s e i t g e n e r a t e s c o m p i l e r e r r o r s
if ( NOT MINGW )
if ( ENABLE_SSE3 )
add_extra_compiler_option ( -msse3 )
if ( ENABLE_AVX )
add_extra_compiler_option ( -mavx )
endif ( )
if ( ${ CMAKE_OPENCV_GCC_VERSION_NUM } GREATER 402 )
set ( HAVE_GCC43_OR_NEWER 1 )
endif ( )
if ( ${ CMAKE_OPENCV_GCC_VERSION_NUM } GREATER 401 )
set ( HAVE_GCC42_OR_NEWER 1 )
endif ( )
# G C C d e p r e s s e s S S E x i n s t r u c t i o n s w h e n - m a v x i s u s e d . I n s t e a d , i t g e n e r a t e s n e w A V X i n s t r u c t i o n s o r A V X e q u i v a l e n c e f o r a l l S S E x i n s t r u c t i o n s w h e n n e e d e d .
if ( NOT OPENCV_EXTRA_CXX_FLAGS MATCHES "-mavx" )
if ( ENABLE_SSE3 )
add_extra_compiler_option ( -msse3 )
endif ( )
if ( HAVE_GCC42_OR_NEWER OR APPLE )
if ( ENABLE_SSSE3 )
add_extra_compiler_option ( -mssse3 )
endif ( )
if ( HAVE_GCC43_OR_NEWER OR APPLE )
if ( ENABLE_SSE41 )
add_extra_compiler_option ( -msse4.1 )
endif ( )
if ( ENABLE_SSE42 )
add_extra_compiler_option ( -msse4. 2 )
endif ( )
if ( ENABLE_SSE41 )
add_extra_compiler_option ( -msse4.1 )
endif ( )
if ( ENABLE_SSE4 2)
add_ extra_compiler_optio n( -msse4.2 )
endif ( )
endif ( )
endif ( NOT MINGW )
if ( X86 OR X86_64 )
if ( NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 4 )
if ( ENABLE_SSE2 )
if ( OPENCV_EXTRA_CXX_FLAGS MATCHES "-m(sse2|avx)" )
add_extra_compiler_option ( -mfpmath=sse ) # ! ! i m p o r t a n t - b e o n t h e s a m e w a v e w i t h x 6 4 c o m p i l e r s
else ( )
add_extra_compiler_option ( -mfpmath=387 )
@ -201,30 +199,35 @@ if(MSVC)
set ( OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi" )
endif ( )
if ( NOT MSVC64 )
# 6 4 - b i t MSVC c o m p i l e r u s e s S S E / S S E 2 b y d e f a u l t
if ( ENABLE_SSE )
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE" )
endif ( )
if ( ENABLE_SSE2 )
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE2" )
endif ( )
if ( ENABLE_AVX AND NOT MSVC_VERSION LESS 1600 )
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:AVX" )
endif ( )
if ( ENABLE_SSE3 )
if ( ENABLE_SSE4_1 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:" )
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE4.1" )
endif ( )
if ( ENABLE_SSE3 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:" )
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE3" )
endif ( )
if ( ENABLE_SSE4_1 )
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE4.1" )
if ( NOT MSVC64 )
# 6 4 - b i t MSVC c o m p i l e r u s e s S S E / S S E 2 b y d e f a u l t
if ( ENABLE_SSE2 AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:" )
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE2" )
endif ( )
if ( ENABLE_SSE AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:" )
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE" )
endif ( )
endif ( )
if ( ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1 )
if ( ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1 OR ENABLE_AVX )
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Oi" )
endif ( )
if ( X86 OR X86_64 )
if ( CMAKE_SIZEOF_VOID_P EQUAL 4 AND ENABLE_SSE2 )
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast" ) # ! ! i m p o r t a n t - b e o n t h e s a m e w a v e w i t h x 6 4 c o m p i l e r s
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast" ) # ! ! i m p o r t a n t - b e o n t h e s a m e w a v e w i t h x 6 4 c o m p i l e r s
endif ( )
endif ( )
endif ( )
@ -238,34 +241,34 @@ endif()
# A d d u s e r s u p p l i e d e x t r a options ( optimization, etc... )
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS}" CACHE INTERNAL "Extra compiler options" )
set ( OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS}" CACHE INTERNAL "Extra compiler options for C sources" )
set ( OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS}" CACHE INTERNAL "Extra compiler options for C++ sources" )
set ( OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS}" CACHE INTERNAL "Extra compiler options" )
set ( OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS}" CACHE INTERNAL "Extra compiler options for C sources" )
set ( OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS}" CACHE INTERNAL "Extra compiler options for C++ sources" )
set ( OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE}" CACHE INTERNAL "Extra compiler options for Release build" )
set ( OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG}" CACHE INTERNAL "Extra compiler options for Debug build" )
set ( OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS}" CACHE INTERNAL "Extra linker flags" )
set ( OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG}" CACHE INTERNAL "Extra compiler options for Debug build" )
set ( OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS}" CACHE INTERNAL "Extra linker flags" )
set ( OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}" CACHE INTERNAL "Extra linker flags for Release build" )
set ( OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Extra linker flags for Debug build" )
set ( OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Extra linker flags for Debug build" )
# c o m b i n e a l l " e x t r a " o p t i o n s
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_C_FLAGS}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_C_FLAGS}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}" )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}" )
set ( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}" )
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}" )
set ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_EXTRA_EXE_LINKER_FLAGS}" )
set ( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}" )
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}" )
set ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_EXTRA_EXE_LINKER_FLAGS}" )
set ( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}" )
set ( CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}" )
set ( CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}" )
if ( MSVC )
# a v o i d w a r n i n g s f r o m MSVC a b o u t o v e r r i d i n g t h e / W * o p t i o n
# w e r e p l a c e / W 3 w i t h / W 4 o n l y f o r C + + f i l e s ,
# s i n c e a l l t h e 3 r d - p a r t y l i b r a r i e s O p e n C V u s e s a r e i n C ,
# a n d w e d o n o t c a r e a b o u t t h e i r w a r n i n g s .
string ( REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
string ( REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
string ( REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" )
string ( REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" )
string ( REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" )
if ( NOT ENABLE_NOISY_WARNINGS AND MSVC_VERSION EQUAL 1400 )
ocv_warnings_disable ( CMAKE_CXX_FLAGS /wd4510 /wd4610 /wd4312 /wd4201 /wd4244 /wd4328 /wd4267 )
@ -274,7 +277,7 @@ if(MSVC)
# a l l o w e x t e r n " C " f u n c t i o n s t h r o w e x c e p t i o n s
foreach ( flags CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG )
string ( REPLACE "/EHsc-" "/EHs" ${ flags } "${${flags}}" )
string ( REPLACE "/EHsc" "/EHs" ${ flags } "${${flags}}" )
string ( REPLACE "/EHsc" "/EHs" ${ flags } "${${flags}}" )
string ( REPLACE "/Zm1000" "" ${ flags } "${${flags}}" )
endforeach ( )