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 autodetect CMAKE_SYSTEM_VERSION to convert to Darwin version #16335

Merged
merged 8 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 5 additions & 12 deletions conan/tools/cmake/toolchain/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,12 +922,10 @@ def _is_apple_cross_building(self):

def _get_darwin_version(self, system_name, os_version):
juansblanco marked this conversation as resolved.
Show resolved Hide resolved
juansblanco marked this conversation as resolved.
Show resolved Hide resolved
darwin_versions = {
"macos_old": {
"Darwin": {
juansblanco marked this conversation as resolved.
Show resolved Hide resolved
"10.13": "17",
"10.14": "18",
"10.15": "19"
},
"macos_new": {
"10.15": "19",
"11": "20",
"12": "21",
"13": "22",
Expand Down Expand Up @@ -967,17 +965,12 @@ def _get_darwin_version(self, system_name, os_version):
if os_version is None:
return None
major_os_version = str(Version(os_version).major)
if system_name == "Darwin":
if Version(os_version) < 11:
if os_version in darwin_versions.get("macos_old"):
return darwin_versions.get("macos_old").get(os_version)
else:
if major_os_version in darwin_versions.get("macos_new"):
return darwin_versions.get("macos_new").get(major_os_version)
if system_name == "Darwin" and Version(os_version) < 11:
if os_version in darwin_versions.get("Darwin"):
return darwin_versions.get("Darwin").get(os_version)
elif system_name in darwin_versions:
if major_os_version in darwin_versions.get(system_name):
return darwin_versions.get(system_name).get(major_os_version)
raise ConanException("Unsupported macOS version: %s" % os_version)

def _get_cross_build(self):
user_toolchain = self._conanfile.conf.get("tools.cmake.cmaketoolchain:user_toolchain")
Expand Down
2 changes: 1 addition & 1 deletion test/integration/toolchains/cmake/test_cmaketoolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def test_cmaketoolchain_cmake_system_processor_cross_apple():
client.run("install hello.py -pr:h=./profile_ios -pr:b=default -g CMakeToolchain")
toolchain = client.load("conan_toolchain.cmake")
assert "set(CMAKE_SYSTEM_NAME iOS)" in toolchain
assert "set(CMAKE_SYSTEM_VERSION 15.0)" in toolchain
assert "set(CMAKE_SYSTEM_VERSION 21)" in toolchain
assert "set(CMAKE_SYSTEM_PROCESSOR arm64)" in toolchain


Expand Down