From 5141e4df24c33c04acc1732855ef83547185c777 Mon Sep 17 00:00:00 2001 From: mojyack Date: Thu, 16 May 2024 16:19:24 +0900 Subject: [PATCH] remove MI_USE_LIBATOMIC and properly find libatomic --- CMakeLists.txt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cc2fc46..6e55a221 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,8 @@ option(MI_NO_THP "Disable transparent huge pages support on Linux/And # deprecated options 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) include(CheckIncludeFiles) include(GNUInstallDirs) include("cmake/mimalloc-config-version.cmake") @@ -354,13 +354,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}) - set(pc_libraries "${pc_libraries} -latomic") + check_linker_flag(C "-latomic" MI_NEED_LIBATOMIC) + if (MI_NEED_LIBATOMIC) + list(APPEND mi_libraries -latomic) endif() endif()