Thanks to visit codestin.com
Credit goes to github.com

Skip to content

error detecting MSVC preview compiler version #25295

@pattakosn

Description

@pattakosn

System Information

OpenCV version: 4.9.0 and latest
OS: W11 pro insiders
Compiler: MSVC 2022 preview
cmake 3.28.3

Detailed description

while configuring the project i see this message

-- Detected processor: AMD64
CMake Warning at cmake/OpenCVDetectCXXCompiler.cmake:182 (message):
  OpenCV does not recognize MSVC_VERSION "1940".  Cannot set OpenCV_RUNTIME
Call Stack (most recent call first):
  CMakeLists.txt:174 (include)

the issue comes from /cmake/OpenCVDetectCXXCompiler.cmake where it tries to detect compilers, the VS2022's MSVC_VERSION is identified as 193 but VS2022 preview identifies itself as 194.Locally I hacked the abovementioned cmake file like this:

diff --git a/cmake/OpenCVDetectCXXCompiler.cmake b/cmake/OpenCVDetectCXXCompiler.cmake
index 1743aca11f..b3ec6fc3bf 100644
--- a/cmake/OpenCVDetectCXXCompiler.cmake
+++ b/cmake/OpenCVDetectCXXCompiler.cmake
@@ -176,7 +176,7 @@ elseif(MSVC)
     set(OpenCV_RUNTIME vc15)
   elseif(MSVC_VERSION MATCHES "^192[0-9]$")
     set(OpenCV_RUNTIME vc16)
-  elseif(MSVC_VERSION MATCHES "^193[0-9]$")
+  elseif(MSVC_VERSION MATCHES "^19[3,4][0-9]$")
     set(OpenCV_RUNTIME vc17)
   else()
     message(WARNING "OpenCV does not recognize MSVC_VERSION \"${MSVC_VERSION}\". Cannot set OpenCV_RUNTIME")

but I am not sure what is the correct way to fix that.

On one system this caused my build to fail on an other it compiles nevertheless.

Steps to reproduce

checkout/download opencv 4.9.0 or latest and run cmake configure while using MSVC 2022 preview

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions