From fb423071c63ff8c060a616be35f8bc530415a02c Mon Sep 17 00:00:00 2001 From: Josiah VanderZee Date: Sat, 20 Apr 2024 09:10:31 -0500 Subject: [PATCH] Only link -atomic on Clang and GCC MSVC does not recognize /latomic. --- src/CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 03e914a5f..b56749cf6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -321,11 +321,13 @@ endif() # Note that find_library does not reliably find it so we have to resort to this. # Also, passing -latomic is not always the same as adding atomic to the library list. include(CheckCSourceCompiles) -set(CMAKE_REQUIRED_LIBRARIES "-latomic") -check_c_source_compiles("int main(){}" HAVE_LINK_ATOMIC) -set(CMAKE_REQUIRED_LIBRARIES "") -if(HAVE_LINK_ATOMIC) - set(PLATFORM_LIBS ${PLATFORM_LIBS} "-latomic") +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GCC") + set(CMAKE_REQUIRED_LIBRARIES "-latomic") + check_c_source_compiles("int main(){}" HAVE_LINK_ATOMIC) + set(CMAKE_REQUIRED_LIBRARIES "") + if(HAVE_LINK_ATOMIC) + set(PLATFORM_LIBS ${PLATFORM_LIBS} "-latomic") + endif() endif() include(CheckSymbolExists)