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

@ -9,6 +9,7 @@
#
# 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)

View File

@ -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)