]> git.ipfire.org Git - thirdparty/ccache.git/blob - cmake/StdAtomic.cmake
fix: Avoid crash for -arch as last compiler option
[thirdparty/ccache.git] / cmake / StdAtomic.cmake
1 # Check if std::atomic needs -latomic
2
3 include(CheckCXXSourceCompiles)
4
5 set(
6 check_std_atomic_source_code
7 [=[
8 #include <atomic>
9 int main()
10 {
11 std::atomic<long long> x;
12 ++x;
13 (void)x.load();
14 return 0;
15 }
16 ]=])
17
18 check_cxx_source_compiles("${check_std_atomic_source_code}" std_atomic_without_libatomic)
19
20 if(NOT std_atomic_without_libatomic)
21 set(CMAKE_REQUIRED_LIBRARIES atomic)
22 check_cxx_source_compiles("${check_std_atomic_source_code}" std_atomic_with_libatomic)
23 set(CMAKE_REQUIRED_LIBRARIES)
24 if(NOT std_atomic_with_libatomic)
25 message(FATAL_ERROR "Toolchain doesn't support std::atomic with nor without -latomic")
26 else()
27 target_link_libraries(standard_settings INTERFACE atomic)
28 endif()
29 endif()