bump cmake required version to 3.18 and detect libatomic more reliably, see pr #898

This commit is contained in:
Daan 2024-05-19 13:25:31 -07:00
parent 7ea7296d3e
commit 03224e17a0
2 changed files with 6 additions and 8 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.18)
project(libmimalloc C CXX)
set(CMAKE_C_STANDARD 11)
@ -35,6 +35,7 @@ option(MI_NO_THP "Disable transparent huge pages support on Linux/And
option(MI_CHECK_FULL "Use full internal invariant checking in DEBUG mode (deprecated, use MI_DEBUG_FULL instead)" OFF)
option(MI_USE_LIBATOMIC "Explicitly link with -latomic (on older systems) (deprecated and detected automatically)" OFF)
include(CheckLinkerFlag) # requires cmake 3.18
include(CheckIncludeFiles)
include(GNUInstallDirs)
include("cmake/mimalloc-config-version.cmake")
@ -354,12 +355,9 @@ else()
list(APPEND mi_libraries ${MI_LIBRT})
set(pc_libraries "${pc_libraries} -lrt")
endif()
find_library(MI_LIBATOMIC atomic)
if (NOT MI_LIBATOMIC AND MI_USE_LIBATOMIC)
set(MI_LIBATOMIC atomic)
endif()
if (MI_LIBATOMIC)
list(APPEND mi_libraries ${MI_LIBATOMIC})
check_linker_flag(C "-latomic" MI_HAS_LIBATOMIC) # do not use `find_library` as libatomic is not always in the system path (issue #898)
if (MI_HAS_LIBATOMIC OR MI_USE_LIBATOMIC)
list(APPEND mi_libraries "atomic")
set(pc_libraries "${pc_libraries} -latomic")
endif()
endif()

View File

@ -24,7 +24,7 @@ not accidentally mix pointers from different allocators).
#define free(p) mi_free(p)
#define strdup(s) mi_strdup(s)
#define strndup(s,n) mi_strndup(s,n)
#define strndup(s,n) mi_strndup(s,n)
#define realpath(f,n) mi_realpath(f,n)
// Microsoft extensions