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

Autotools adds apple deployement target flag #7862

Merged
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
6 changes: 6 additions & 0 deletions conans/client/build/autotools_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
format_frameworks, format_framework_paths)
from conans.client.build.cppstd_flags import cppstd_from_settings, \
cppstd_flag_new as cppstd_flag
from conans.client import tools
from conans.client.tools.env import environment_append
from conans.client.tools.oss import OSInfo, args_to_string, cpu_count, cross_building, \
detected_architecture, detected_os, get_gnu_triplet, get_target_os_arch, get_build_os_arch
Expand Down Expand Up @@ -39,6 +40,7 @@ def __init__(self, conanfile, win_bash=False, include_rpath_flags=False):
self.subsystem = OSInfo().detect_windows_subsystem() if self._win_bash else None
self._deps_cpp_info = conanfile.deps_cpp_info
self._os = conanfile.settings.get_safe("os")
self._os_version = conanfile.settings.get_safe("os.version")
self._arch = conanfile.settings.get_safe("arch")
self._os_target, self._arch_target = get_target_os_arch(conanfile)

Expand Down Expand Up @@ -339,6 +341,10 @@ def append(*args):
tmp_compilation_flags = copy.copy(self.flags)
if self.fpic:
tmp_compilation_flags.append(pic_flag(self._conanfile.settings))
if tools.is_apple_os(self._os) and self._os_version:
flag = tools.apple_deployment_target_flag(self._os,
self._os_version)
tmp_compilation_flags.append(flag)
MartinDelille marked this conversation as resolved.
Show resolved Hide resolved

cxx_flags = append(tmp_compilation_flags, self.cxx_flags, self.cppstd_flag)
c_flags = tmp_compilation_flags
Expand Down
16 changes: 16 additions & 0 deletions conans/test/unittests/client/build/autotools_environment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,3 +671,19 @@ def autotools_fpic_test(self):
self.assertFalse(ab.fpic)
ab.fpic = True
self.assertIn("-fPIC", ab.vars["CXXFLAGS"])

def mac_version_min_test(self):
options = MockOptions({})
settings = MockSettings({"os": "Macos"})
conanfile = MockConanfile(settings, options)
be = AutoToolsBuildEnvironment(conanfile)
expected = be.vars["CXXFLAGS"]
self.assertEqual("", expected)

settings = MockSettings({"os": "Macos",
"os.version": "10.13",
"compiler.version": "12.0"})
conanfile = MockConanfile(settings, options)
be = AutoToolsBuildEnvironment(conanfile)
expected = be.vars["CXXFLAGS"]
self.assertIn("10.13", expected)