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