Skip to content

add new supported MSVC version#20831

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
sthalik:fix-msvc-build-3.4
Oct 7, 2021
Merged

add new supported MSVC version#20831
opencv-pushbot merged 1 commit intoopencv:3.4from
sthalik:fix-msvc-build-3.4

Conversation

@sthalik
Copy link
Copy Markdown
Contributor

@sthalik sthalik commented Oct 7, 2021

This is a backport of #20804 to the 3.4 branch.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Commit with touching of linker flags is the most questionable here (need to investigate in which configuration these flags are used).

CMakeLists.txt Outdated

if(POLICY CMP0069)
cmake_policy(SET CMP0069 NEW) # CMake 3.9+: target property INTERPROCEDURAL_OPTIMIZATION
endif()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep sorted order for policies

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

elseif(MSVC_VERSION MATCHES "^192[0-9]$")
set(OpenCV_RUNTIME vc16)
elseif(MSVC_VERSION MATCHES "^193[0-9]$")
set(OpenCV_RUNTIME vc17)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


if(MSVC)
if(MSVC AND NOT BUILD_SHARED_LIBS)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We lost /DEBUG options here too. Is it intended behavior?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could set -DEBUG here unconditionally but it shouldn't be set here at all. Should all of this be moved to ocv_define_module?

Copy link
Copy Markdown
Contributor Author

@sthalik sthalik Oct 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about conditionalizing -NODEFAULTLIB for 3.4 keeping -DEBUG, all the while cleaning it up in the pull request for master? These flags only make sense when building with mismatched CRTs from different compiler versions or mixed -MD/-MT, while -DEBUG should already be passed when BUILD_WITH_DEBUG_INFO is set.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"/DEBUG" for linker-only and "BUILD_WITH_DEBUG_INFO" are different things. The second one provides complete debug information which is heavy.


when building with mismatched CRTs from different compiler versions or mixed -MD/-MT

Right.
I believe, such build configurations are still useful for distribution of prebuilt OpenCV binaries.

@sthalik
Copy link
Copy Markdown
Contributor Author

sthalik commented Oct 7, 2021

Should I be rebasing during review, only after, or not at all? Fixup will lose existing review comments.

@alalek
Copy link
Copy Markdown
Member

alalek commented Oct 7, 2021

Please rebase commits. GitHub keep review comments.

@sthalik sthalik force-pushed the fix-msvc-build-3.4 branch from c3acb69 to 32d9383 Compare October 7, 2021 11:47
@alalek
Copy link
Copy Markdown
Member

alalek commented Oct 7, 2021

I have installed MSVS 2022 Preview (17.0.0 Preview 4.1), but I'm not able to reproduce related warnings without these patches. Compiler version is 19.30.30528.0.

cmake -G "Visual Studio 17 2022" -A x64 ../dev -DBUILD_EXAMPLES=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
cmake --build . --config Release --target example_cpp_digits -- /m:2 /v:n

or

cmake -G "Visual Studio 17 2022" -A x64 ../dev -DBUILD_EXAMPLES=ON -DBUILD_SHARED_LIBS=OFF
cmake --build . --config Release --target example_cpp_digits -- /m:2 /v:n

Please left in this PR the first commit only (with vc17 handling) and extract other commits to dedicated 2 PRs with information how to reproduce observed problem (without extra toolchain).

@sthalik sthalik force-pushed the fix-msvc-build-3.4 branch from 32d9383 to 04b40ff Compare October 7, 2021 13:45
@sthalik
Copy link
Copy Markdown
Contributor Author

sthalik commented Oct 7, 2021

Done.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants