• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# See absl/copts/copts.py and absl/copts/generate_copts.py
2include(GENERATED_AbseilCopts)
3
4set(ABSL_LSAN_LINKOPTS "")
5set(ABSL_HAVE_LSAN OFF)
6set(ABSL_DEFAULT_LINKOPTS "")
7
8if (BUILD_SHARED_LIBS AND MSVC)
9  set(ABSL_BUILD_DLL TRUE)
10  set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
11else()
12  set(ABSL_BUILD_DLL FALSE)
13endif()
14
15if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64|amd64|AMD64")
16  if (MSVC)
17    set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_MSVC_X64_FLAGS}")
18  else()
19    set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_X64_FLAGS}")
20  endif()
21elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm.*|aarch64")
22  if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
23    set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_ARM64_FLAGS}")
24  elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
25    set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_ARM32_FLAGS}")
26  else()
27    message(WARNING "Value of CMAKE_SIZEOF_VOID_P (${CMAKE_SIZEOF_VOID_P}) is not supported.")
28  endif()
29else()
30  message(WARNING "Value of CMAKE_SYSTEM_PROCESSOR (${CMAKE_SYSTEM_PROCESSOR}) is unknown and cannot be used to set ABSL_RANDOM_RANDEN_COPTS")
31  set(ABSL_RANDOM_RANDEN_COPTS "")
32endif()
33
34
35if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
36  set(ABSL_DEFAULT_COPTS "${ABSL_GCC_FLAGS}")
37  set(ABSL_TEST_COPTS "${ABSL_GCC_FLAGS};${ABSL_GCC_TEST_FLAGS}")
38elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
39  # MATCHES so we get both Clang and AppleClang
40  if(MSVC)
41    # clang-cl is half MSVC, half LLVM
42    set(ABSL_DEFAULT_COPTS "${ABSL_CLANG_CL_FLAGS}")
43    set(ABSL_TEST_COPTS "${ABSL_CLANG_CL_FLAGS};${ABSL_CLANG_CL_TEST_FLAGS}")
44    set(ABSL_DEFAULT_LINKOPTS "${ABSL_MSVC_LINKOPTS}")
45  else()
46    set(ABSL_DEFAULT_COPTS "${ABSL_LLVM_FLAGS}")
47    set(ABSL_TEST_COPTS "${ABSL_LLVM_FLAGS};${ABSL_LLVM_TEST_FLAGS}")
48    if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
49      # AppleClang doesn't have lsan
50      # https://developer.apple.com/documentation/code_diagnostics
51      if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
52        set(ABSL_LSAN_LINKOPTS "-fsanitize=leak")
53        set(ABSL_HAVE_LSAN ON)
54      endif()
55    endif()
56  endif()
57elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
58  set(ABSL_DEFAULT_COPTS "${ABSL_MSVC_FLAGS}")
59  set(ABSL_TEST_COPTS "${ABSL_MSVC_FLAGS};${ABSL_MSVC_TEST_FLAGS}")
60  set(ABSL_DEFAULT_LINKOPTS "${ABSL_MSVC_LINKOPTS}")
61else()
62  message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER}.  Building with no default flags")
63  set(ABSL_DEFAULT_COPTS "")
64  set(ABSL_TEST_COPTS "")
65endif()
66
67set(ABSL_CXX_STANDARD "${CMAKE_CXX_STANDARD}")
68