Skip to content

Commit

Permalink
cmake: Specify NOMINMAX all the time on Windows
Browse files Browse the repository at this point in the history
This prevents the Windows headers from defining min/max macros.

Use std::min and std::max.

Modifies deps, frontend, libobs-d3d11, libobs-winrt, decklink, obs-vst,
and win-dshow.
  • Loading branch information
RytoEX committed Feb 7, 2025
1 parent c2b4823 commit e471d31
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions cmake/windows/compilerconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ add_compile_options(
)

add_compile_definitions(
NOMINMAX
UNICODE
_UNICODE
_CRT_SECURE_NO_WARNINGS
Expand Down
2 changes: 1 addition & 1 deletion deps/libdshowcapture/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ target_include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/src/external/capture-device-support/Library")

target_compile_definitions(libdshowcapture INTERFACE _UP_WINDOWS=1)
target_compile_options(libdshowcapture INTERFACE /wd4018)
target_compile_options(libdshowcapture INTERFACE /wd4005 /wd4018)
2 changes: 1 addition & 1 deletion deps/libdshowcapture/src
2 changes: 1 addition & 1 deletion frontend/updater/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ target_sources(
updater.rc
)

target_compile_definitions(updater PRIVATE NOMINMAX "PSAPI_VERSION=2")
target_compile_definitions(updater PRIVATE "PSAPI_VERSION=2")

target_include_directories(updater PRIVATE "${CMAKE_SOURCE_DIR}/libobs" "${CMAKE_SOURCE_DIR}/frontend/utility")

Expand Down
2 changes: 0 additions & 2 deletions frontend/utility/MultitrackVideoOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include <string>
#include <vector>

#define NOMINMAX

class QString;
class QWidget;

Expand Down
3 changes: 2 additions & 1 deletion libobs-d3d11/d3d11-subsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/

#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <optional>
Expand Down Expand Up @@ -229,7 +230,7 @@ gs_swap_chain::gs_swap_chain(gs_device *device, const gs_init_data *data)

ComQIPtr<IDXGIFactory5> factory5 = device->factory;
if (factory5) {
initData.num_backbuffers = max(data->num_backbuffers, 2);
initData.num_backbuffers = std::max(data->num_backbuffers, (uint32_t)2);

effect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
Expand Down
4 changes: 2 additions & 2 deletions libobs-winrt/winrt-capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ static bool get_client_box(HWND window, uint32_t width, uint32_t height, D3D11_B

uint32_t texture_width = 1;
if (width > left) {
texture_width = min(width - left, (uint32_t)client_rect.right);
texture_width = std::min(width - left, (uint32_t)client_rect.right);
}

uint32_t texture_height = 1;
if (height > top) {
texture_height = min(height - top, (uint32_t)client_rect.bottom);
texture_height = std::min(height - top, (uint32_t)client_rect.bottom);
}

client_box->right = left + texture_width;
Expand Down
2 changes: 0 additions & 2 deletions plugins/decklink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ target_sources(
util.hpp
)

target_compile_definitions(decklink PRIVATE $<$<PLATFORM_ID:Windows>:NOMINMAX>)

target_link_libraries(
decklink
PRIVATE
Expand Down
1 change: 0 additions & 1 deletion plugins/obs-vst/headers/EditorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QWidget>

#if defined(_WIN32)
#define NOMINMAX
#include <QWindow>
#include <Windows.h>
#elif defined(__linux__)
Expand Down
2 changes: 1 addition & 1 deletion plugins/win-dshow/cmake/libdshowcapture.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ target_include_directories(
)

target_compile_definitions(libdshowcapture INTERFACE _UP_WINDOWS=1)
target_compile_options(libdshowcapture INTERFACE /wd4018)
target_compile_options(libdshowcapture INTERFACE /wd4005 /wd4018)

get_target_property(target_sources libdshowcapture INTERFACE_SOURCES)
set(target_headers ${target_sources})
Expand Down

0 comments on commit e471d31

Please sign in to comment.