@@ -15,6 +15,7 @@ option(MI_USE_CXX "Use the C++ compiler to compile the library (instea
15
15
option (MI_SEE_ASM "Generate assembly files" OFF )
16
16
option (MI_OSX_INTERPOSE "Use interpose to override standard malloc on macOS" ON )
17
17
option (MI_OSX_ZONE "Use malloc zone to override standard malloc on macOS" ON )
18
+ option (MI_WIN_REDIRECT "Use redirection module ('mimalloc-redirect') on Windows if compiling mimalloc as a DLL" ON )
18
19
option (MI_LOCAL_DYNAMIC_TLS "Use slightly slower, dlopen-compatible TLS mechanism (Unix)" OFF )
19
20
option (MI_BUILD_SHARED "Build shared library" ON )
20
21
option (MI_BUILD_STATIC "Build static library" ON )
@@ -105,6 +106,19 @@ if(MI_OVERRIDE)
105
106
endif ()
106
107
endif ()
107
108
109
+ if (WIN32 )
110
+ if (MI_WIN_REDIRECT)
111
+ if (MSVC_C_ARCHITECTURE_ID MATCHES "ARM" )
112
+ message (STATUS "Cannot use redirection on Windows ARM (MI_WIN_REDIRECT=OFF)" )
113
+ set (MI_WIN_REDIRECT OFF )
114
+ endif ()
115
+ endif ()
116
+ if (NOT MI_WIN_REDIRECT)
117
+ # use a negative define for backward compatibility
118
+ list (APPEND mi_defines MI_WIN_NOREDIRECT=1)
119
+ endif ()
120
+ endif ()
121
+
108
122
if (MI_SECURE)
109
123
message (STATUS "Set full secure build (MI_SECURE=ON)" )
110
124
list (APPEND mi_defines MI_SECURE=4)
@@ -323,8 +337,8 @@ if(MI_BUILD_SHARED)
323
337
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
324
338
$<INSTALL_INTERFACE:${mi_install_incdir} >
325
339
)
326
- if (WIN32 )
327
- # On windows copy the mimalloc redirection dll too.
340
+ if (WIN32 AND MI_WIN_REDIRECT )
341
+ # On windows, link and copy the mimalloc redirection dll too.
328
342
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
329
343
set (MIMALLOC_REDIRECT_SUFFIX "32" )
330
344
else ()
0 commit comments