Fix building with Qt5 on MSVC by undefining min/max macros
authorHendrik Leppkes <h.leppkes@gmail.com>
Sat, 29 Mar 2014 16:16:13 +0000 (17:16 +0100)
committerHendrik Leppkes <h.leppkes@gmail.com>
Sat, 29 Mar 2014 16:16:13 +0000 (17:16 +0100)
The Windows stdlib.h header defines min/max macros, which interfer with
the Qt5 header files. Luckily, it also provides the define NOMINMAX which
suppresses these macros, and fix building.

CMakeLists.txt

index 26f967f..3033e60 100644 (file)
@@ -447,6 +447,7 @@ endif(STATIC AND CMAKE_COMPILER_IS_GNUCXX)
 if(WIN32)
   link_libraries(imm32 winmm dbghelp Secur32)  # missing by default :/
   if(MSVC)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX")
     set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBUGINFO "/debug /INCREMENTAL:YES /NODEFAULTLIB:libcmt /DEFAULTLIB:msvcrt")
     set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /INCREMENTAL:YES /NODEFAULTLIB:libcmt")
     set(CMAKE_EXE_LINKER_FLAGS_DEBUGFULL "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")