obs-studio icon indicating copy to clipboard operation
obs-studio copied to clipboard

cmake: Use NOMINMAX on Windows

Open RytoEX opened this issue 1 year ago • 1 comments

Description

This PR makes a few changes.

  1. Explicitly use std::min
  2. Explicitly use std::max
  3. Set NOMINMAX as a default compile definition on Windows to prevent defining min/max macros

Motivation and Context

Want to just use STL std::min/std::max and avoid shenanigans with min/max macros.

See also:

  • https://github.com/obsproject/obs-studio/pull/10997

Also needs:

  • https://github.com/elgatosf/capture-device-support/pull/6

How Has This Been Tested?

Built locally on Windows 11. Still needs built with VS for/on WoA to make sure it works.

Types of changes

  • Code cleanup (non-breaking change which makes code smaller or more readable)

Checklist:

  • [x] My code has been run through clang-format.
  • [x] I have read the contributing document.
  • [x] My code is not on the master branch.
  • [x] The code has been tested.
  • [x] All commit messages are properly formatted and commits squashed where appropriate.
  • [x] I have included updates to all appropriate documentation.

RytoEX avatar Oct 12 '24 01:10 RytoEX

There's still two more instances of specific NOMINMAX use:

https://github.com/obsproject/obs-studio/blob/ba6a6bfdcb4db6fdee02b0224df4106321c5ef48/UI/win-update/updater/CMakeLists.txt#L25

https://github.com/obsproject/obs-studio/blob/ba6a6bfdcb4db6fdee02b0224df4106321c5ef48/plugins/decklink/CMakeLists.txt#L75

Removed those. Thanks.

The commits may need squashed to avoid the first two commits failing.

RytoEX avatar Oct 15 '24 18:10 RytoEX