From e471d3109b84bfdc0da9104933e5c7c05700c64e Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Fri, 11 Oct 2024 20:56:53 -0400 Subject: [PATCH] cmake: Specify NOMINMAX all the time on Windows 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. --- cmake/windows/compilerconfig.cmake | 1 + deps/libdshowcapture/CMakeLists.txt | 2 +- deps/libdshowcapture/src | 2 +- frontend/updater/CMakeLists.txt | 2 +- frontend/utility/MultitrackVideoOutput.hpp | 2 -- libobs-d3d11/d3d11-subsystem.cpp | 3 ++- libobs-winrt/winrt-capture.cpp | 4 ++-- plugins/decklink/CMakeLists.txt | 2 -- plugins/obs-vst/headers/EditorWidget.h | 1 - plugins/win-dshow/cmake/libdshowcapture.cmake | 2 +- 10 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cmake/windows/compilerconfig.cmake b/cmake/windows/compilerconfig.cmake index 5939d1517..f891e9d38 100644 --- a/cmake/windows/compilerconfig.cmake +++ b/cmake/windows/compilerconfig.cmake @@ -78,6 +78,7 @@ add_compile_options( ) add_compile_definitions( + NOMINMAX UNICODE _UNICODE _CRT_SECURE_NO_WARNINGS diff --git a/deps/libdshowcapture/CMakeLists.txt b/deps/libdshowcapture/CMakeLists.txt index 8e7cd93e4..2e0405312 100644 --- a/deps/libdshowcapture/CMakeLists.txt +++ b/deps/libdshowcapture/CMakeLists.txt @@ -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) diff --git a/deps/libdshowcapture/src b/deps/libdshowcapture/src index ef8c1d2e1..887863832 160000 --- a/deps/libdshowcapture/src +++ b/deps/libdshowcapture/src @@ -1 +1 @@ -Subproject commit ef8c1d2e19c93e664100dd41e1a0df4f8ad45430 +Subproject commit 8878638324393815512f802640b0d5ce940161f1 diff --git a/frontend/updater/CMakeLists.txt b/frontend/updater/CMakeLists.txt index abaa84c76..3dd0ee9b2 100644 --- a/frontend/updater/CMakeLists.txt +++ b/frontend/updater/CMakeLists.txt @@ -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") diff --git a/frontend/utility/MultitrackVideoOutput.hpp b/frontend/utility/MultitrackVideoOutput.hpp index 20f34d571..60f98356c 100644 --- a/frontend/utility/MultitrackVideoOutput.hpp +++ b/frontend/utility/MultitrackVideoOutput.hpp @@ -9,8 +9,6 @@ #include #include -#define NOMINMAX - class QString; class QWidget; diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index 29151b738..1ef405763 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -15,6 +15,7 @@ along with this program. If not, see . ******************************************************************************/ +#include #include #include #include @@ -229,7 +230,7 @@ gs_swap_chain::gs_swap_chain(gs_device *device, const gs_init_data *data) ComQIPtr 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; diff --git a/libobs-winrt/winrt-capture.cpp b/libobs-winrt/winrt-capture.cpp index 8cdcf5aa3..a31414f47 100644 --- a/libobs-winrt/winrt-capture.cpp +++ b/libobs-winrt/winrt-capture.cpp @@ -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; diff --git a/plugins/decklink/CMakeLists.txt b/plugins/decklink/CMakeLists.txt index 99fa82725..18b9b6bc5 100644 --- a/plugins/decklink/CMakeLists.txt +++ b/plugins/decklink/CMakeLists.txt @@ -72,8 +72,6 @@ target_sources( util.hpp ) -target_compile_definitions(decklink PRIVATE $<$:NOMINMAX>) - target_link_libraries( decklink PRIVATE diff --git a/plugins/obs-vst/headers/EditorWidget.h b/plugins/obs-vst/headers/EditorWidget.h index e20429acd..ce14b584a 100644 --- a/plugins/obs-vst/headers/EditorWidget.h +++ b/plugins/obs-vst/headers/EditorWidget.h @@ -22,7 +22,6 @@ along with this program. If not, see . #include #if defined(_WIN32) -#define NOMINMAX #include #include #elif defined(__linux__) diff --git a/plugins/win-dshow/cmake/libdshowcapture.cmake b/plugins/win-dshow/cmake/libdshowcapture.cmake index e05c027c6..84c79c971 100644 --- a/plugins/win-dshow/cmake/libdshowcapture.cmake +++ b/plugins/win-dshow/cmake/libdshowcapture.cmake @@ -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})