Skip to content

Commit

Permalink
add Windows arm64 support in cmame; name the mimalloc dll 'mimalloc-o…
Browse files Browse the repository at this point in the history
…verride.dll' on Windows with cmake (to match the IDE and minject
  • Loading branch information
daanx committed Dec 17, 2024
1 parent de8d73d commit 3feb0d6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,7 @@ if(MI_OVERRIDE)
endif()
endif()

if(WIN32)
if (MI_WIN_REDIRECT)
if (MSVC_C_ARCHITECTURE_ID MATCHES "ARM")
message(STATUS "Cannot use redirection on Windows ARM (MI_WIN_REDIRECT=OFF)")
set(MI_WIN_REDIRECT OFF)
endif()
endif()
if(WIN32)
if (NOT MI_WIN_REDIRECT)
# use a negative define for backward compatibility
list(APPEND mi_defines MI_WIN_NOREDIRECT=1)
Expand Down Expand Up @@ -340,7 +334,7 @@ if(APPLE)
endif()
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
set(MI_ARCH "x64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64" OR CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64")
set(MI_ARCH "arm64")
endif()

Expand Down Expand Up @@ -534,7 +528,9 @@ if(MI_BUILD_SHARED)
)
if(WIN32 AND MI_WIN_REDIRECT)
# On windows, link and copy the mimalloc redirection dll too.
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
if(MI_ARCH STREQUAL "arm64")
set(MIMALLOC_REDIRECT_SUFFIX "-arm64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(MIMALLOC_REDIRECT_SUFFIX "32")
else()
set(MIMALLOC_REDIRECT_SUFFIX "")
Expand Down Expand Up @@ -656,6 +652,11 @@ endif()
if (MI_OVERRIDE)
if (MI_BUILD_SHARED)
target_compile_definitions(mimalloc PRIVATE MI_MALLOC_OVERRIDE)
if (WIN32)
# on windows we should generate mimalloc-override.dll.
string(REPLACE "mimalloc" "mimalloc-override" mi_override_output_name ${mi_basename})
set_target_properties(mimalloc PROPERTIES OUTPUT_NAME ${mi_override_output_name})
endif()
endif()
if(NOT WIN32)
# It is only possible to override malloc on Windows when building as a DLL.
Expand Down

0 comments on commit 3feb0d6

Please sign in to comment.