use consistent naming on Windows vs other platforms. Use mimalloc.dll.lib for the dll import library to avoid a clash with the static mimalloc.lib library

This commit is contained in:
daanx 2025-01-09 20:57:08 -08:00
parent 600ca88e87
commit 4fcf56af2e
7 changed files with 61 additions and 53 deletions

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.18)
project(mimalloc-test C CXX)
set(CMAKE_C_STANDARD 11)
@ -16,7 +16,7 @@ if (NOT CMAKE_BUILD_TYPE)
endif()
# Import mimalloc (if installed)
find_package(mimalloc 1.7 REQUIRED NO_SYSTEM_ENVIRONMENT_PATH)
find_package(mimalloc 1.9 CONFIG REQUIRED)
message(STATUS "Found mimalloc installed at: ${MIMALLOC_LIBRARY_DIR} (${MIMALLOC_VERSION_DIR})")
# overriding with a dynamic library
@ -29,9 +29,9 @@ target_link_libraries(dynamic-override-cxx PUBLIC mimalloc)
# overriding with a static object file works reliable as the symbols in the
# object file have priority over those in library files
add_executable(static-override-obj main-override.c ${MIMALLOC_OBJECT_DIR}/mimalloc.o)
add_executable(static-override-obj main-override.c ${MIMALLOC_OBJECT_DIR}/mimalloc${CMAKE_C_OUTPUT_EXTENSION})
target_include_directories(static-override-obj PUBLIC ${MIMALLOC_INCLUDE_DIR})
target_link_libraries(static-override-obj PUBLIC pthread)
target_link_libraries(static-override-obj PUBLIC mimalloc-static)
# overriding with a static library works too if using the `mimalloc-override.h`