tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

AbseilConfigureCopts.cmake (4405B)


      1 # See absl/copts/copts.py and absl/copts/generate_copts.py
      2 include(GENERATED_AbseilCopts)
      3 
      4 set(ABSL_DEFAULT_LINKOPTS "")
      5 
      6 if (BUILD_SHARED_LIBS AND (MSVC OR ABSL_BUILD_MONOLITHIC_SHARED_LIBS))
      7  set(ABSL_BUILD_DLL TRUE)
      8  set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
      9 else()
     10  set(ABSL_BUILD_DLL FALSE)
     11 endif()
     12 
     13 if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES [[Clang]])
     14  # Some CMake targets (not known at the moment of processing) could be set to
     15  # compile for multiple architectures as specified by the OSX_ARCHITECTURES
     16  # property, which is target-specific.  We should neither inspect nor rely on
     17  # any CMake property or variable to detect an architecture, in particular:
     18  #
     19  #   - CMAKE_OSX_ARCHITECTURES
     20  #     is just an initial value for OSX_ARCHITECTURES; set too early.
     21  #
     22  #   - OSX_ARCHITECTURES
     23  #     is a per-target property; targets could be defined later, and their
     24  #     properties could be modified any time later.
     25  #
     26  #   - CMAKE_SYSTEM_PROCESSOR
     27  #     does not reflect multiple architectures at all.
     28  #
     29  # When compiling for multiple architectures, a build system can invoke a
     30  # compiler either
     31  #
     32  #   - once: a single command line for multiple architectures (Ninja build)
     33  #   - twice: two command lines per each architecture (Xcode build system)
     34  #
     35  # If case of Xcode, it would be possible to set an Xcode-specific attributes
     36  # like XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=arm64] or similar.
     37  #
     38  # In both cases, the viable strategy is to pass all arguments at once, allowing
     39  # the compiler to dispatch arch-specific arguments to a designated backend.
     40  set(ABSL_RANDOM_RANDEN_COPTS "")
     41  foreach(_arch IN ITEMS "x86_64" "arm64")
     42    string(TOUPPER "${_arch}" _arch_uppercase)
     43    string(REPLACE "X86_64" "X64" _arch_uppercase ${_arch_uppercase})
     44    foreach(_flag IN LISTS ABSL_RANDOM_HWAES_${_arch_uppercase}_FLAGS)
     45      list(APPEND ABSL_RANDOM_RANDEN_COPTS "SHELL:-Xarch_${_arch} ${_flag}")
     46    endforeach()
     47  endforeach()
     48  # If a compiler happens to deal with an argument for a currently unused
     49  # architecture, it will warn about an unused command line argument.
     50  option(ABSL_RANDOM_RANDEN_COPTS_WARNING OFF
     51         "Warn if one of ABSL_RANDOM_RANDEN_COPTS is unused")
     52  if(ABSL_RANDOM_RANDEN_COPTS AND NOT ABSL_RANDOM_RANDEN_COPTS_WARNING)
     53    list(APPEND ABSL_RANDOM_RANDEN_COPTS "-Wno-unused-command-line-argument")
     54  endif()
     55 elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
     56  if (MSVC)
     57    set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_MSVC_X64_FLAGS}")
     58  else()
     59    set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_X64_FLAGS}")
     60  endif()
     61 elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm.*|aarch64")
     62  if (CMAKE_SIZEOF_VOID_P STREQUAL "8")
     63    set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_ARM64_FLAGS}")
     64  elseif(CMAKE_SIZEOF_VOID_P STREQUAL "4")
     65    set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_ARM32_FLAGS}")
     66  else()
     67    message(WARNING "Value of CMAKE_SIZEOF_VOID_P (${CMAKE_SIZEOF_VOID_P}) is not supported.")
     68  endif()
     69 else()
     70  set(ABSL_RANDOM_RANDEN_COPTS "")
     71 endif()
     72 
     73 
     74 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "QCC")
     75  set(ABSL_DEFAULT_COPTS "${ABSL_GCC_FLAGS}")
     76  set(ABSL_TEST_COPTS "${ABSL_GCC_TEST_FLAGS}")
     77 elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")  # MATCHES so we get both Clang and AppleClang
     78  if(MSVC)
     79    # clang-cl is half MSVC, half LLVM
     80    set(ABSL_DEFAULT_COPTS "${ABSL_CLANG_CL_FLAGS}")
     81    set(ABSL_TEST_COPTS "${ABSL_CLANG_CL_TEST_FLAGS}")
     82  else()
     83    set(ABSL_DEFAULT_COPTS "${ABSL_LLVM_FLAGS}")
     84    set(ABSL_TEST_COPTS "${ABSL_LLVM_TEST_FLAGS}")
     85  endif()
     86 elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
     87  # IntelLLVM is similar to Clang, with some additional flags.
     88  if(MSVC)
     89    # clang-cl is half MSVC, half LLVM
     90    set(ABSL_DEFAULT_COPTS "${ABSL_CLANG_CL_FLAGS}")
     91    set(ABSL_TEST_COPTS "${ABSL_CLANG_CL_TEST_FLAGS}")
     92  else()
     93    set(ABSL_DEFAULT_COPTS "${ABSL_LLVM_FLAGS}")
     94    set(ABSL_TEST_COPTS "${ABSL_LLVM_TEST_FLAGS}")
     95  endif()
     96 elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
     97  set(ABSL_DEFAULT_COPTS "${ABSL_MSVC_FLAGS}")
     98  set(ABSL_TEST_COPTS "${ABSL_MSVC_TEST_FLAGS}")
     99  set(ABSL_DEFAULT_LINKOPTS "${ABSL_MSVC_LINKOPTS}")
    100 else()
    101  message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER}.  Building with no default flags")
    102  set(ABSL_DEFAULT_COPTS "")
    103  set(ABSL_TEST_COPTS "")
    104 endif()
    105 
    106 set(ABSL_CXX_STANDARD "${CMAKE_CXX_STANDARD}")