Add ATOMICS_LIBRARY_FLAGS.

This commit is contained in:
levlam 2024-02-19 16:54:29 +03:00
parent 1202a4d957
commit 6c5441c8ff
2 changed files with 7 additions and 4 deletions

View File

@ -7,8 +7,9 @@
# riscv64 specific: # riscv64 specific:
# * https://lists.debian.org/debian-riscv/2022/01/msg00009.html # * https://lists.debian.org/debian-riscv/2022/01/msg00009.html
# #
# ATOMICS_FOUND - system has c++ atomics # ATOMICS_FOUND - system has c++ atomics
# ATOMICS_LIBRARIES - libraries needed to use c++ atomics # ATOMICS_LIBRARIES - libraries needed to use c++ atomics
# ATOMICS_LIBRARY_FLAGS - flags required to link with c++ atomics library
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
@ -34,6 +35,7 @@ check_cxx_source_compiles("${atomic_code}" ATOMICS_LOCK_FREE_INSTRUCTIONS)
if (ATOMICS_LOCK_FREE_INSTRUCTIONS) if (ATOMICS_LOCK_FREE_INSTRUCTIONS)
set(ATOMICS_FOUND TRUE) set(ATOMICS_FOUND TRUE)
set(ATOMICS_LIBRARIES) set(ATOMICS_LIBRARIES)
set(ATOMICS_LIBRARY_FLAGS)
else() else()
set(CMAKE_REQUIRED_LIBRARIES "-latomic") set(CMAKE_REQUIRED_LIBRARIES "-latomic")
check_cxx_source_compiles("${atomic_code}" ATOMICS_IN_LIBRARY) check_cxx_source_compiles("${atomic_code}" ATOMICS_IN_LIBRARY)
@ -43,6 +45,7 @@ else()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Atomics DEFAULT_MSG ATOMICS_LIBRARY) find_package_handle_standard_args(Atomics DEFAULT_MSG ATOMICS_LIBRARY)
set(ATOMICS_LIBRARIES ${ATOMICS_LIBRARY}) set(ATOMICS_LIBRARIES ${ATOMICS_LIBRARY})
set(ATOMICS_LIBRARY_FLAGS "-latomic")
unset(ATOMICS_LIBRARY) unset(ATOMICS_LIBRARY)
else() else()
if (Atomics_FIND_REQUIRED) if (Atomics_FIND_REQUIRED)

View File

@ -130,8 +130,8 @@ if (THREADS_HAVE_PTHREAD_ARG)
endif() endif()
find_package(Atomics REQUIRED) find_package(Atomics REQUIRED)
if (ATOMICS_LIBRARIES) if (ATOMICS_LIBRARY_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ATOMICS_LIBRARIES}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ATOMICS_LIBRARY_FLAGS}")
endif() endif()
include(TdSetUpCompiler) include(TdSetUpCompiler)