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.
This commit is contained in:
Ryan Foster 2024-10-11 20:56:53 -04:00
parent c2b4823075
commit e471d3109b
10 changed files with 9 additions and 12 deletions

View File

@ -78,6 +78,7 @@ add_compile_options(
) )
add_compile_definitions( add_compile_definitions(
NOMINMAX
UNICODE UNICODE
_UNICODE _UNICODE
_CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS

View File

@ -40,4 +40,4 @@ target_include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/src/external/capture-device-support/Library") "${CMAKE_CURRENT_SOURCE_DIR}/src/external/capture-device-support/Library")
target_compile_definitions(libdshowcapture INTERFACE _UP_WINDOWS=1) target_compile_definitions(libdshowcapture INTERFACE _UP_WINDOWS=1)
target_compile_options(libdshowcapture INTERFACE /wd4018) target_compile_options(libdshowcapture INTERFACE /wd4005 /wd4018)

@ -1 +1 @@
Subproject commit ef8c1d2e19c93e664100dd41e1a0df4f8ad45430 Subproject commit 8878638324393815512f802640b0d5ce940161f1

View File

@ -22,7 +22,7 @@ target_sources(
updater.rc 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") target_include_directories(updater PRIVATE "${CMAKE_SOURCE_DIR}/libobs" "${CMAKE_SOURCE_DIR}/frontend/utility")

View File

@ -9,8 +9,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#define NOMINMAX
class QString; class QString;
class QWidget; class QWidget;

View File

@ -15,6 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/ ******************************************************************************/
#include <algorithm>
#include <cassert> #include <cassert>
#include <cinttypes> #include <cinttypes>
#include <optional> #include <optional>
@ -229,7 +230,7 @@ gs_swap_chain::gs_swap_chain(gs_device *device, const gs_init_data *data)
ComQIPtr<IDXGIFactory5> factory5 = device->factory; ComQIPtr<IDXGIFactory5> factory5 = device->factory;
if (factory5) { 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; effect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;

View File

@ -56,12 +56,12 @@ static bool get_client_box(HWND window, uint32_t width, uint32_t height, D3D11_B
uint32_t texture_width = 1; uint32_t texture_width = 1;
if (width > left) { 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; uint32_t texture_height = 1;
if (height > top) { 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; client_box->right = left + texture_width;

View File

@ -72,8 +72,6 @@ target_sources(
util.hpp util.hpp
) )
target_compile_definitions(decklink PRIVATE $<$<PLATFORM_ID:Windows>:NOMINMAX>)
target_link_libraries( target_link_libraries(
decklink decklink
PRIVATE PRIVATE

View File

@ -22,7 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QWidget> #include <QWidget>
#if defined(_WIN32) #if defined(_WIN32)
#define NOMINMAX
#include <QWindow> #include <QWindow>
#include <Windows.h> #include <Windows.h>
#elif defined(__linux__) #elif defined(__linux__)

View File

@ -45,7 +45,7 @@ target_include_directories(
) )
target_compile_definitions(libdshowcapture INTERFACE _UP_WINDOWS=1) 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) get_target_property(target_sources libdshowcapture INTERFACE_SOURCES)
set(target_headers ${target_sources}) set(target_headers ${target_sources})