CereLink icon indicating copy to clipboard operation
CereLink copied to clipboard

cbsdk_static needs to link (PUBLIC) atomic on some platforms

Open cboulay opened this issue 2 months ago • 1 comments


  # Check if we need to link libatomic (required on some platforms for atomic ops)
  include(CheckCXXSourceCompiles)
  check_cxx_source_compiles("
      #include <atomic>
      int main() {
          std::atomic<int> x;
          x.exchange(1);
          return 0;
      }
  " HAVE_CXX_ATOMICS_WITHOUT_LIB)

  if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB)
      # Try with -latomic
      set(CMAKE_REQUIRED_LIBRARIES atomic)
      check_cxx_source_compiles("
          #include <atomic>
          int main() {
              std::atomic<int> x;
              x.exchange(1);
              return 0;
          }
      " HAVE_CXX_ATOMICS_WITH_LIB)
      unset(CMAKE_REQUIRED_LIBRARIES)

      if(HAVE_CXX_ATOMICS_WITH_LIB)
          target_link_libraries(cbsdk_static PUBLIC atomic)
      endif()
  endif()

cboulay avatar Oct 23 '25 05:10 cboulay

This wasn't fixed with that commit... the ubuntu-latest runner was still reporting the atomic-related errors.

cboulay avatar Oct 23 '25 06:10 cboulay