Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong cppstd detection for newer apple-clang compilers #14837

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion conan/internal/api/detect_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,12 @@ def _visual_cppstd_default(version):
def _mcst_lcc_cppstd_default(version):
return "gnu14" if version >= "1.24" else "gnu98"

def _apple_clang_cppstd_default(version):
return "gnu17" if version >= "11" else "gnu98"

default = {"gcc": _gcc_cppstd_default(compiler_version),
"clang": _clang_cppstd_default(compiler_version),
"apple-clang": "gnu98",
"apple-clang": _apple_clang_cppstd_default(compiler_version),
"msvc": _visual_cppstd_default(compiler_version),
"mcst-lcc": _mcst_lcc_cppstd_default(compiler_version)}.get(str(compiler), None)
return default
Expand Down
10 changes: 5 additions & 5 deletions conans/test/unittests/client/build/cpp_std_flags_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ def test_apple_clang_cppstd_defaults(self):
self.assertEqual(_make_cppstd_default("apple-clang", "8"), "gnu98")
self.assertEqual(_make_cppstd_default("apple-clang", "9"), "gnu98")
self.assertEqual(_make_cppstd_default("apple-clang", "10"), "gnu98")
self.assertEqual(_make_cppstd_default("apple-clang", "11"), "gnu98")
self.assertEqual(_make_cppstd_default("apple-clang", "12"), "gnu98")
self.assertEqual(_make_cppstd_default("apple-clang", "13"), "gnu98")
self.assertEqual(_make_cppstd_default("apple-clang", "14"), "gnu98")
self.assertEqual(_make_cppstd_default("apple-clang", "15"), "gnu98")
self.assertEqual(_make_cppstd_default("apple-clang", "11"), "gnu17")
self.assertEqual(_make_cppstd_default("apple-clang", "12"), "gnu17")
self.assertEqual(_make_cppstd_default("apple-clang", "13"), "gnu17")
self.assertEqual(_make_cppstd_default("apple-clang", "14"), "gnu17")
self.assertEqual(_make_cppstd_default("apple-clang", "15"), "gnu17")
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved

def test_visual_cppstd_flags(self):
self.assertEqual(_make_cppstd_flag("msvc", "170", "11"), None)
Expand Down
6 changes: 4 additions & 2 deletions conans/test/unittests/tools/build/test_cppstd.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def test_supported_cppstd_mcst(compiler, compiler_version, values):
sot = supported_cppstd(conanfile)
assert sot == values


@pytest.mark.parametrize("compiler,compiler_version,values", [
("qcc", "4.4", ['98', 'gnu98']),
("qcc", "5.4", ['98', 'gnu98', '11', 'gnu11', "14", "gnu14", "17", "gnu17"]),
Expand All @@ -120,10 +121,11 @@ def test_supported_cppstd_qcc(compiler, compiler_version, values):
("gcc", "5", 'gnu98'),
("gcc", "8", "gnu14"),
("msvc", "190", "14"),
("apple-clang", "12.0", "gnu98"),
("apple-clang", "10.0", "gnu98"),
("apple-clang", "12.0", "gnu17"),
("clang", "6", "gnu14"),
])
def test_default_cppstd_gcc(compiler, compiler_version, result):
def test_default_cppstd(compiler, compiler_version, result):
settings = MockSettings({"compiler": compiler, "compiler.version": compiler_version})
conanfile = ConanFileMock(settings)
sot = default_cppstd(conanfile)
Expand Down