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