diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2019-10-17 10:49:44 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-10-17 16:57:25 +0000 |
commit | 2fa23e46c0b79a065d92a95033bfc3ae10b707cf (patch) | |
tree | ab13778363b9719fbf6bb055608ae88fcd614642 /util | |
parent | 4df389eb4f1ae10284c03023e923ce2164d46753 (diff) |
Fix C++ standard detection
We cannot use a generator expression in an if statement, it does not
work. Instead, we could inspect the CMAKE_C/CXX_COMPILE_FEATURES list,
but unfortunately that's not reliable. For example it detects that ICPC
supports C++17 when in fact that depends on the installed libstdc++.
Therefore this patch revives our own configure tests.
Change-Id: Ic3bc5762fbe81837722523e3881ac16e84628519
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-x | util/cmake/configurejson2cmake.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py index 11918f1a32..ba6c85af28 100755 --- a/util/cmake/configurejson2cmake.py +++ b/util/cmake/configurejson2cmake.py @@ -54,13 +54,8 @@ class LibraryMapping: def map_tests(test: str) -> Optional[str]: testmap = { - "c++11": "$<COMPILE_FEATURES:cxx_std_11>", - "c++14": "$<COMPILE_FEATURES:cxx_std_14>", - "c++1z": "$<COMPILE_FEATURES:cxx_std_17>", - "c++17": "$<COMPILE_FEATURES:cxx_std_17>", - "c++20": "$<COMPILE_FEATURES:cxx_std_20>", - "c99": "$<COMPILE_FEATURES:c_std_99>", - "c11": "$<COMPILE_FEATURES:c_std_11>", + "c99": "c_std_99 IN_LIST CMAKE_C_COMPILE_FEATURES", + "c11": "c_std_11 IN_LIST CMAKE_C_COMPILE_FEATURES", "x86SimdAlways": "ON", # FIXME: Make this actually do a compile test. "aesni": "TEST_subarch_aes", "avx": "TEST_subarch_avx", @@ -489,12 +484,6 @@ def parseInput(ctx, sinput, data, cm_fh): # }, def parseTest(ctx, test, data, cm_fh): skip_tests = { - "c++11", - "c++14", - "c++17", - "c++20", - "c++1y", - "c++1z", "c11", "c99", "gc_binaries", @@ -572,6 +561,7 @@ endif() sourceCode = sourceCode.replace('"', '\\"') librariesCmakeName = "" + languageStandard = "" qmakeFixme = "" cm_fh.write(f"# {test}\n") @@ -594,6 +584,12 @@ endif() elif details["qmake"] == "CONFIG += c++11": # do nothing we're always in c++11 mode pass + elif details["qmake"] == "CONFIG += c++11 c++14": + languageStandard = "CXX_STANDARD 14" + elif details["qmake"] == "CONFIG += c++11 c++14 c++17": + languageStandard = "CXX_STANDARD 17" + elif details["qmake"] == "CONFIG += c++11 c++14 c++17 c++2a": + languageStandard = "CXX_STANDARD 20" else: qmakeFixme = f"# FIXME: qmake: {details['qmake']}\n" @@ -614,6 +610,8 @@ endif() cm_fh.write('"' + sourceCode + '"') if qmakeFixme != "": cm_fh.write(qmakeFixme) + if languageStandard != "": + cm_fh.write(f"\n {languageStandard}\n") cm_fh.write(")\n\n") elif data["type"] == "libclang": |