mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-01-15 09:38:00 +08:00
Merge branch 'dev' of https://github.com/microsoft/mimalloc into dev
This commit is contained in:
commit
66ce1d54e4
@ -15,6 +15,9 @@ option(MI_LOCAL_DYNAMIC_TLS "Use slightly slower, dlopen-compatible TLS mechanis
|
|||||||
option(MI_BUILD_TESTS "Build test executables" ON)
|
option(MI_BUILD_TESTS "Build test executables" ON)
|
||||||
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
|
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
|
||||||
option(MI_PADDING "Enable padding to detect heap block overflow (only in debug mode)" ON)
|
option(MI_PADDING "Enable padding to detect heap block overflow (only in debug mode)" ON)
|
||||||
|
option(MI_BUILD_SHARED "Build shared library" ON)
|
||||||
|
option(MI_BUILD_STATIC "Build static library" ON)
|
||||||
|
option(MI_BUILD_OBJECT "Build object" ON)
|
||||||
option(MI_XMALLOC "Enable abort() call on memory allocation failure by default" OFF)
|
option(MI_XMALLOC "Enable abort() call on memory allocation failure by default" OFF)
|
||||||
option(MI_SHOW_ERRORS "Show error and warning messages by default" OFF)
|
option(MI_SHOW_ERRORS "Show error and warning messages by default" OFF)
|
||||||
|
|
||||||
@ -193,6 +196,9 @@ message(STATUS "")
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
# shared library
|
# shared library
|
||||||
|
if(MI_BUILD_SHARED)
|
||||||
|
message(STATUS "Shared library will be built")
|
||||||
|
|
||||||
add_library(mimalloc SHARED ${mi_sources})
|
add_library(mimalloc SHARED ${mi_sources})
|
||||||
set_target_properties(mimalloc PROPERTIES VERSION ${mi_version} OUTPUT_NAME ${mi_basename} )
|
set_target_properties(mimalloc PROPERTIES VERSION ${mi_version} OUTPUT_NAME ${mi_basename} )
|
||||||
target_compile_definitions(mimalloc PRIVATE ${mi_defines} MI_SHARED_LIB MI_SHARED_LIB_EXPORT)
|
target_compile_definitions(mimalloc PRIVATE ${mi_defines} MI_SHARED_LIB MI_SHARED_LIB_EXPORT)
|
||||||
@ -210,7 +216,14 @@ if(WIN32)
|
|||||||
COMMENT "Copy mimalloc-redirect.dll to output directory")
|
COMMENT "Copy mimalloc-redirect.dll to output directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_dir} LIBRARY)
|
||||||
|
install(EXPORT mimalloc DESTINATION ${mi_install_dir}/cmake)
|
||||||
|
endif()
|
||||||
|
|
||||||
# static library
|
# static library
|
||||||
|
if (MI_BUILD_STATIC)
|
||||||
|
message(STATUS "Static library will be built")
|
||||||
|
|
||||||
add_library(mimalloc-static STATIC ${mi_sources})
|
add_library(mimalloc-static STATIC ${mi_sources})
|
||||||
set_property(TARGET mimalloc-static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET mimalloc-static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
target_compile_definitions(mimalloc-static PRIVATE ${mi_defines} MI_STATIC_LIB)
|
target_compile_definitions(mimalloc-static PRIVATE ${mi_defines} MI_STATIC_LIB)
|
||||||
@ -229,17 +242,17 @@ else()
|
|||||||
set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename})
|
set_target_properties(mimalloc-static PROPERTIES OUTPUT_NAME ${mi_basename})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# install static and shared library, and the include files
|
|
||||||
install(TARGETS mimalloc EXPORT mimalloc DESTINATION ${mi_install_dir} LIBRARY)
|
|
||||||
install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_dir})
|
install(TARGETS mimalloc-static EXPORT mimalloc DESTINATION ${mi_install_dir})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# install include files
|
||||||
install(FILES include/mimalloc.h DESTINATION ${mi_install_dir}/include)
|
install(FILES include/mimalloc.h DESTINATION ${mi_install_dir}/include)
|
||||||
install(FILES include/mimalloc-override.h DESTINATION ${mi_install_dir}/include)
|
install(FILES include/mimalloc-override.h DESTINATION ${mi_install_dir}/include)
|
||||||
install(FILES include/mimalloc-new-delete.h DESTINATION ${mi_install_dir}/include)
|
install(FILES include/mimalloc-new-delete.h DESTINATION ${mi_install_dir}/include)
|
||||||
install(FILES cmake/mimalloc-config.cmake DESTINATION ${mi_install_dir}/cmake)
|
install(FILES cmake/mimalloc-config.cmake DESTINATION ${mi_install_dir}/cmake)
|
||||||
install(FILES cmake/mimalloc-config-version.cmake DESTINATION ${mi_install_dir}/cmake)
|
install(FILES cmake/mimalloc-config-version.cmake DESTINATION ${mi_install_dir}/cmake)
|
||||||
install(EXPORT mimalloc DESTINATION ${mi_install_dir}/cmake)
|
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32 AND MI_BUILD_SHARED)
|
||||||
# install a symlink in the /usr/local/lib to the versioned library
|
# install a symlink in the /usr/local/lib to the versioned library
|
||||||
set(mi_symlink "${CMAKE_SHARED_MODULE_PREFIX}${mi_basename}${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
set(mi_symlink "${CMAKE_SHARED_MODULE_PREFIX}${mi_basename}${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||||
set(mi_soname "mimalloc-${mi_version}/${mi_symlink}.${mi_version}")
|
set(mi_soname "mimalloc-${mi_version}/${mi_symlink}.${mi_version}")
|
||||||
@ -248,6 +261,9 @@ if(NOT WIN32)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# single object file for more predictable static overriding
|
# single object file for more predictable static overriding
|
||||||
|
if (MI_BUILD_OBJECT)
|
||||||
|
message(STATUS "Library object will be built")
|
||||||
|
|
||||||
add_library(mimalloc-obj OBJECT src/static.c)
|
add_library(mimalloc-obj OBJECT src/static.c)
|
||||||
set_property(TARGET mimalloc-obj PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET mimalloc-obj PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
target_compile_definitions(mimalloc-obj PRIVATE ${mi_defines})
|
target_compile_definitions(mimalloc-obj PRIVATE ${mi_defines})
|
||||||
@ -265,6 +281,7 @@ target_include_directories(mimalloc-obj PUBLIC
|
|||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/mimalloc-obj.dir/src/static.c${CMAKE_C_OUTPUT_EXTENSION}
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/mimalloc-obj.dir/src/static.c${CMAKE_C_OUTPUT_EXTENSION}
|
||||||
DESTINATION ${mi_install_dir}
|
DESTINATION ${mi_install_dir}
|
||||||
RENAME ${mi_basename}${CMAKE_C_OUTPUT_EXTENSION} )
|
RENAME ${mi_basename}${CMAKE_C_OUTPUT_EXTENSION} )
|
||||||
|
endif()
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# API surface testing
|
# API surface testing
|
||||||
@ -292,10 +309,16 @@ endif()
|
|||||||
# Set override properties
|
# Set override properties
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
if (MI_OVERRIDE MATCHES "ON")
|
if (MI_OVERRIDE MATCHES "ON")
|
||||||
|
if (MI_BUILD_SHARED)
|
||||||
target_compile_definitions(mimalloc PRIVATE MI_MALLOC_OVERRIDE)
|
target_compile_definitions(mimalloc PRIVATE MI_MALLOC_OVERRIDE)
|
||||||
|
endif()
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
# It is only possible to override malloc on Windows when building as a DLL.
|
# It is only possible to override malloc on Windows when building as a DLL.
|
||||||
|
if (MI_BUILD_STATIC)
|
||||||
target_compile_definitions(mimalloc-static PRIVATE MI_MALLOC_OVERRIDE)
|
target_compile_definitions(mimalloc-static PRIVATE MI_MALLOC_OVERRIDE)
|
||||||
|
endif()
|
||||||
|
if (MI_BUILD_OBJECT)
|
||||||
target_compile_definitions(mimalloc-obj PRIVATE MI_MALLOC_OVERRIDE)
|
target_compile_definitions(mimalloc-obj PRIVATE MI_MALLOC_OVERRIDE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user