Skip to content

Commit f4f6b0d

Browse files
committed
set_optimization_flags: set NOMINMAX for matplot regardless of check_symbol_exists, which wasn't being enough
1 parent d480a5d commit f4f6b0d

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

cmake/functions/target_options.cmake

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,33 @@ function(target_utf8_options TARGET_NAME)
6464
target_msvc_compile_options(${TARGET_NAME} PRIVATE /utf-8)
6565
endfunction()
6666

67-
# @brief Enable utf-8 for the target
67+
# @brief Disable minmax for target
6868
function(target_disable_minmax TARGET_NAME)
69+
message("Checking if min exists for ${TARGET_NAME}")
6970
if (MSVC)
7071
# Another hack to check for min in Windows.h
7172
# 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()
7380
if (HAVE_WINDOWS_MINMAX)
7481
target_compile_definitions(${TARGET_NAME} PUBLIC NOMINMAX)
82+
else()
83+
message("MINMAX not found")
7584
endif()
85+
else()
86+
message("Compiler is not MSVC")
7687
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)
7796
endfunction()

0 commit comments

Comments
 (0)