From 0026419fa73b9c69d7e2786756c2f10fb24b3fa8 Mon Sep 17 00:00:00 2001 From: bjornpiltz Date: Wed, 11 Oct 2023 22:33:06 +0200 Subject: [PATCH] Added NOMINMAX to MSVC builds. Fix MSVC error due to WinDef.h redefining min/max. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 034e560c..14472cc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,11 @@ add_library(QGLViewer SHARED ${QGLViewer_SRC}) target_include_directories(QGLViewer INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(QGLViewer PRIVATE ${QtLibs} OpenGL::GL OpenGL::GLU) +if(MSVC) + # Avoid a compiler error when using std::min/std::max. + target_compile_definitions(QGLViewer PRIVATE NOMINMAX) +endif() + # Example: animation. set(animation_SRC "${PROJECT_SOURCE_DIR}/examples/animation/animation.cpp"