Cross compilation for spesific cpu only

I am compiling opencv for windows on ubuntu with mingw. i see that no instruction is detected in the “CPU/HW features” section even though i compiled with “-march=skylake-avx512”. is this usual? i want to use all the optimizations available. i need to make sure i am not missing anything.


env CXX="x86_64-w64-mingw32-g++" cmake -DCMAKE_CXX_FLAGS="-pipe -O3 -march=skylake-avx512" -DCPU_BASELINE="DETECT" -DCPU_DISPATCH="" ..


-- General configuration for OpenCV 4.7.0 =====================================
--   Version control:               7ae9b3d-dirty
--   Platform:
--     Timestamp:                   2023-04-19T11:39:04Z
--     Host:                        Linux 5.15.0-69-generic x86_64
--     Target:                      Windows
--     CMake:                       3.22.1
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/gmake
--     Configuration:               Release
--   CPU/HW features:
--     Baseline:
--       requested:                 DETECT
--   C/C++:
--     Built as dynamic libs?:      NO
--     C++ standard:                11
--     C++ Compiler:                /usr/bin/x86_64-w64-mingw32-g++  (ver 10.0.0)
--     C++ flags (Release):         -pipe -O3 -march=skylake-avx512   -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -fomit-frame-pointer -ffunction-sections -fdata-sections  -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG

correct solution

OPENCV_WORKAROUND_CMAKE_20989 is important

cmake \
	-DCMAKE_C_COMPILER="x86_64-w64-mingw32-gcc" \
	-DCMAKE_C_COMPILER_TARGET=x86_64-w64-mingw32 \
	-DCMAKE_CXX_COMPILER="x86_64-w64-mingw32-g++" \
	-DCMAKE_CXX_COMPILER_TARGET=x86_64-w64-mingw32 \
    -DCMAKE_CXX_FLAGS="-pipe -O3 -march=skylake-avx512 -m64" \