diff --git a/ports/opencv4/portfile.cmake b/ports/opencv4/portfile.cmake index 385dd801f3..52dbf9fcda 100644 --- a/ports/opencv4/portfile.cmake +++ b/ports/opencv4/portfile.cmake @@ -63,6 +63,10 @@ elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") set(TARGET_IS_ARM 1) elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") set(TARGET_IS_X86_64 1) +elseif(VCPKG_TARGET_IS_EMSCRIPTEN) + # wasm32 is not x86: leaving every TARGET_IS_* unset keeps OpenCV off the x86 SSE baseline, + # whose runtime guard aborts on wasm. SIMD comes from the wasm HAL configured below. + set(TARGET_IS_WASM 1) else() set(TARGET_IS_X86 1) endif() @@ -409,6 +413,20 @@ if("qt" IN_LIST FEATURES) list(APPEND ADDITIONAL_BUILD_FLAGS "-DCMAKE_AUTOMOC=ON") endif() +if(VCPKG_TARGET_IS_EMSCRIPTEN) + # OpenCV's CPU-optimization machinery assumes a native (x86/ARM) target. On wasm the baseline + # and dispatch lists must be empty, otherwise it bakes an x86 SSE baseline whose runtime guard + # aborts at startup. Mirrors OpenCV's own platforms/js/build_js.py. + list(APPEND ADDITIONAL_BUILD_FLAGS -DCPU_BASELINE= -DCPU_DISPATCH=) + if("intrinsics" IN_LIST FEATURES) + # SIMD via OpenCV's wasm HAL (intrin_wasm.hpp); -msimd128 makes its builtins available. + # CV_ENABLE_INTRINSICS itself is turned on by the "intrinsics" feature. + list(APPEND ADDITIONAL_BUILD_FLAGS + -DOPENCV_EXTRA_C_FLAGS=-msimd128 + -DOPENCV_EXTRA_CXX_FLAGS=-msimd128) + endif() +endif() + vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS diff --git a/ports/opencv4/vcpkg.json b/ports/opencv4/vcpkg.json index 6ba5b9b0b0..63d28756c1 100644 --- a/ports/opencv4/vcpkg.json +++ b/ports/opencv4/vcpkg.json @@ -1,7 +1,7 @@ { "name": "opencv4", "version": "4.12.0", - "port-version": 4, + "port-version": 5, "description": "Open Source Computer Vision Library", "homepage": "https://opencv.org/", "documentation": "https://docs.opencv.org/4.12.0/", diff --git a/versions/baseline.json b/versions/baseline.json index f68e9d1a10..c27fb23c86 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -7406,7 +7406,7 @@ }, "opencv4": { "baseline": "4.12.0", - "port-version": 4 + "port-version": 5 }, "opendnp3": { "baseline": "3.1.2", diff --git a/versions/o-/opencv4.json b/versions/o-/opencv4.json index a5fffb9814..3bafa01e7f 100644 --- a/versions/o-/opencv4.json +++ b/versions/o-/opencv4.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "0e28cd8713d7b810bef28ed0d7859dd761215854", + "version": "4.12.0", + "port-version": 5 + }, { "git-tree": "7e25a9ac702b9b94264dc469895c06e82b62d283", "version": "4.12.0",