Skip to content

cbsdk_static needs to link (PUBLIC) atomic on some platforms #155

Description

@cboulay
  # 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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions