@@ -60,7 +60,7 @@ def main():
6060 )
6161
6262 # https://stackoverflow.com/questions/1405913/python-32bit-or-64bit-mode
63- x64 = sys .maxsize > 2 ** 32
63+ is64 = sys .maxsize > 2 ** 32
6464
6565 package_name = "opencv-python"
6666
@@ -88,7 +88,7 @@ def main():
8888 # Path regexes with forward slashes relative to CMake install dir.
8989 rearrange_cmake_output_data = {
9090 "cv2" : (
91- [r"bin/opencv_ffmpeg\d{3,4}%s\.dll" % ("_64" if x64 else "" )]
91+ [r"bin/opencv_ffmpeg\d{3,4}%s\.dll" % ("_64" if is64 else "" )]
9292 if os .name == "nt"
9393 else []
9494 )
@@ -118,7 +118,7 @@ def main():
118118 files_outside_package_dir = {"cv2" : ["LICENSE.txt" , "LICENSE-3RD-PARTY.txt" ]}
119119
120120 ci_cmake_generator = (
121- ["-G" , "Visual Studio 14" + (" Win64" if x64 else "" )]
121+ ["-G" , "Visual Studio 14" + (" Win64" if is64 else "" )]
122122 if os .name == "nt"
123123 else ["-G" , "Unix Makefiles" ]
124124 )
@@ -152,9 +152,15 @@ def main():
152152 "-DBUILD_PNG=ON" ,
153153 ]
154154 + (
155+ # CMake flags for windows/arm64 build
156+ ["-DCMAKE_GENERATOR_PLATFORM=ARM64" ,
157+ # Emulated cmake requires following flags to correctly detect
158+ # target architecture for windows/arm64 build
159+ "-DOPENCV_WORKAROUND_CMAKE_20989=ON" ,
160+ "-DCMAKE_SYSTEM_PROCESSOR=ARM64" ]
161+ if platform .machine () == "ARM64" and sys .platform == "win32"
155162 # If it is not defined 'linker flags: /machine:X86' on Windows x64
156- ["-DCMAKE_GENERATOR_PLATFORM=x64" ]
157- if x64 and sys .platform == "win32"
163+ else ["-DCMAKE_GENERATOR_PLATFORM=x64" ] if is64 and sys .platform == "win32"
158164 else []
159165 )
160166 + (
@@ -174,7 +180,7 @@ def main():
174180 "-DWITH_MSMF=OFF"
175181 ) # see: https://github.com/skvark/opencv-python/issues/263
176182
177- if sys .platform .startswith ("linux" ) and not x64 and "bdist_wheel" in sys .argv :
183+ if sys .platform .startswith ("linux" ) and not is64 and "bdist_wheel" in sys .argv :
178184 subprocess .check_call ("patch -p0 < patches/patchOpenEXR" , shell = True )
179185
180186 # OS-specific components during CI builds
0 commit comments