1# Copyright 2022 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15# Constants that represent the different C++ standards. These are set to the 16# value of __cplusplus, which allows for unambiguous numeric comparison of C++ 17# standards. 18pw_toolchain_STANDARD = { 19 CXX98 = 199711 20 CXX11 = 201103 21 CXX14 = 201402 22 CXX17 = 201703 23 CXX20 = 202002 24} 25 26if (defined(is_fuchsia_tree) && is_fuchsia_tree) { 27 # In the Fuchsia build, this must align with how code is actually being 28 # compiled in that build, which is controlled by Fuchsia's build argument. 29 import("//build/config/fuchsia_cxx_version.gni") 30 31 # This is not a GN build argument at all when Pigweed is integrated into the 32 # Fuchsia build, just a reflection of the Fuchsia build's configuration. 33 # **NOTE:** This line will blow up if the value isn't one of the supported 34 # ones listed above. 35 pw_toolchain_CXX_STANDARD = pw_toolchain_STANDARD["CXX$fuchsia_cxx_version"] 36} else { 37 declare_args() { 38 # Specifies the C++ standard this toolchain is compiling for. The value 39 # must be an integer that matches the value of the __cplusplus macro when 40 # compiling with that standard. Use the pw_toolchain_CXX_STANDARD_## 41 # constants to set this value. 42 pw_toolchain_CXX_STANDARD = pw_toolchain_STANDARD.CXX17 43 } 44} 45 46assert( 47 pw_toolchain_CXX_STANDARD == pw_toolchain_STANDARD.CXX98 || 48 pw_toolchain_CXX_STANDARD == pw_toolchain_STANDARD.CXX11 || 49 pw_toolchain_CXX_STANDARD == pw_toolchain_STANDARD.CXX14 || 50 pw_toolchain_CXX_STANDARD == pw_toolchain_STANDARD.CXX17 || 51 pw_toolchain_CXX_STANDARD == pw_toolchain_STANDARD.CXX20, 52 "pw_toolchain_CXX_STANDARD ($pw_toolchain_CXX_STANDARD) is an " + 53 "unsupported value. The toolchain must set it to one of the " + 54 "pw_toolchain_STANDARD constants (e.g. pw_toolchain_STANDARD.CXX17).") 55 56assert(pw_toolchain_CXX_STANDARD >= pw_toolchain_STANDARD.CXX17, 57 "Pigweed requires at least C++17.") 58