summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorMichal Gorny <mgorny@gentoo.org>2018-03-06 21:26:28 +0000
committerMichal Gorny <mgorny@gentoo.org>2018-03-06 21:26:28 +0000
commitb67f62b3d506113c2e3da1af67bd0c60497fc97e (patch)
treeecaa7ec388d5bf7930e201e0d91a8fda4c0ac784 /CMakeLists.txt
parent860fc25e85a105ef1fa9de717bb974231fab80ba (diff)
downloadclang-b67f62b3d506113c2e3da1af67bd0c60497fc97e.tar.gz
[FrontEnd] Allow overriding the default C/C++ -std via CMake vars
Provide two new CMake cache variables -- CLANG_DEFAULT_STD_C and CLANG_DEFAULT_STD_CXX -- that can be used to override the default C/ObjC and C++/ObjC++ standards appropriately. They can be set to one of the identifiers from LangStandards.def, or left unset (the default) to respect the current platform default. This option is mostly intended for compiler vendors that may wish to adjust the defaults their compilers are using. For example, Gentoo planned to use it to set clang and gcc to matching standards, so that we could maintain as much compatibility between different compilers as possible. The code relies on explicit identifiers rather than the string aliases for simplicity. This saves us from the necessity of parsing aliases at build-time or adding additional processing at runtime. For the latter case, it also adds trivial value check -- if incorrect value is passed, the code simply fails to compile through referencing an undefined constant. If the variable is used to redefine the default standard, the explicit value overrides the special case for PS4. It is done this way mostly following other kinds of variables where 'platform defaults' are redefined. Differential Revision: https://reviews.llvm.org/D34365 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326836 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt6
1 files changed, 6 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a2fcaec9c3..3bf3cfdf33 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -212,6 +212,12 @@ set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
"enable x86 relax relocations by default")
+# TODO: verify the values against LangStandards.def?
+set(CLANG_DEFAULT_STD_C "" CACHE STRING
+ "Default standard to use for C/ObjC code (IDENT from LangStandards.def, empty for platform default)")
+set(CLANG_DEFAULT_STD_CXX "" CACHE STRING
+ "Default standard to use for C++/ObjC++ code (IDENT from LangStandards.def, empty for platform default)")
+
set(CLANG_DEFAULT_LINKER "" CACHE STRING
"Default linker to use (linker name or absolute path, empty for platform default)")