File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ include (CheckCXXSourceCompiles)
2+ 
3+ # Some toolchains require explicitly linking against libatomic 
4+ # 
5+ # If such linking is required, then this function sets the 
6+ # value of result to "atomic". Otherwise it remains untouched. 
7+ # This makes it so that the function only needs to be called once 
8+ # per project. 
9+ # 
10+ # It can be used as follows: 
11+ # 
12+ # check_cxx_needs_atomic(LINK_ATOMIC) 
13+ # target_link_libraries(foo PRIVATE ${LINK_ATOMIC}) 
14+ # ... 
15+ # target_link_libraries(bar PRIVATE ${LINK_ATOMIC}) 
16+ # 
17+ function (check_cxx_needs_atomic result)
18+   check_cxx_source_compiles(" 
19+ #include <atomic> 
20+ #include <cstdint> 
21+   int main() { 
22+     return std::atomic<uint64_t>(0).load(); 
23+   } 
24+   "  success)
25+ 
26+   if (NOT  success)
27+     set (${result}  atomic PARENT_SCOPE)
28+   endif ()
29+ endfunction ()
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments