From 6c5441c8ff53ba68bfa5ba97d392db5514e02233 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 19 Feb 2024 16:54:29 +0300 Subject: [PATCH] Add ATOMICS_LIBRARY_FLAGS. --- CMake/FindAtomics.cmake | 7 +++++-- CMakeLists.txt | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMake/FindAtomics.cmake b/CMake/FindAtomics.cmake index d0916321d..6cafdcde6 100644 --- a/CMake/FindAtomics.cmake +++ b/CMake/FindAtomics.cmake @@ -7,8 +7,9 @@ # riscv64 specific: # * https://lists.debian.org/debian-riscv/2022/01/msg00009.html # -# ATOMICS_FOUND - system has c++ atomics -# ATOMICS_LIBRARIES - libraries needed to use c++ atomics +# ATOMICS_FOUND - system has c++ atomics +# ATOMICS_LIBRARIES - libraries needed to use c++ atomics +# ATOMICS_LIBRARY_FLAGS - flags required to link with c++ atomics library include(CheckCXXSourceCompiles) @@ -34,6 +35,7 @@ check_cxx_source_compiles("${atomic_code}" ATOMICS_LOCK_FREE_INSTRUCTIONS) if (ATOMICS_LOCK_FREE_INSTRUCTIONS) set(ATOMICS_FOUND TRUE) set(ATOMICS_LIBRARIES) + set(ATOMICS_LIBRARY_FLAGS) else() set(CMAKE_REQUIRED_LIBRARIES "-latomic") check_cxx_source_compiles("${atomic_code}" ATOMICS_IN_LIBRARY) @@ -43,6 +45,7 @@ else() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Atomics DEFAULT_MSG ATOMICS_LIBRARY) set(ATOMICS_LIBRARIES ${ATOMICS_LIBRARY}) + set(ATOMICS_LIBRARY_FLAGS "-latomic") unset(ATOMICS_LIBRARY) else() if (Atomics_FIND_REQUIRED) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4c5ccc31..51cd1c7ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,8 +130,8 @@ if (THREADS_HAVE_PTHREAD_ARG) endif() find_package(Atomics REQUIRED) -if (ATOMICS_LIBRARIES) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ATOMICS_LIBRARIES}") +if (ATOMICS_LIBRARY_FLAGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ATOMICS_LIBRARY_FLAGS}") endif() include(TdSetUpCompiler)