File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -64,14 +64,33 @@ function(target_utf8_options TARGET_NAME)
64
64
target_msvc_compile_options (${TARGET_NAME} PRIVATE /utf-8 )
65
65
endfunction ()
66
66
67
- # @brief Enable utf-8 for the target
67
+ # @brief Disable minmax for target
68
68
function (target_disable_minmax TARGET_NAME )
69
+ message ("Checking if min exists for ${TARGET_NAME} " )
69
70
if (MSVC )
70
71
# Another hack to check for min in Windows.h
71
72
# http://www.suodenjoki.dk/us/archive/2010/min-max.htm
72
- check_symbol_exists (min "Windows.h" HAVE_WINDOWS_MINMAX )
73
+ include (CheckSymbolExists )
74
+ message ("Looking in WinDef.h" )
75
+ check_symbol_exists (min "WinDef.h" HAVE_WINDOWS_MINMAX )
76
+ if (NOT HAVE_WINDOWS_MINMAX )
77
+ message ("Looking in Windows.h" )
78
+ check_symbol_exists (min "Windows.h" HAVE_WINDOWS_MINMAX )
79
+ endif ()
73
80
if (HAVE_WINDOWS_MINMAX )
74
81
target_compile_definitions (${TARGET_NAME} PUBLIC NOMINMAX )
82
+ else ()
83
+ message ("MINMAX not found" )
75
84
endif ()
85
+ else ()
86
+ message ("Compiler is not MSVC" )
76
87
endif ()
88
+ endfunction ()
89
+
90
+ # @brief Disable minmax for target
91
+ # This forces the NOMINMAX definition without even looking for
92
+ # min in WinDef.h. This is necessary because the solution
93
+ # based on check_symbol_exists hasn't been enough.
94
+ function (target_nominmax_definition TARGET_NAME )
95
+ target_compile_definitions (${TARGET_NAME} PUBLIC NOMINMAX )
77
96
endfunction ()
You can’t perform that action at this time.
0 commit comments