conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.13k stars 968 forks source link

macOS minosx option aka version #2534

Closed mathieu closed 6 years ago

mathieu commented 6 years ago

Hi,

I'd like so to see (like tvOS, iOS, watchOS) Macos (maybe renamed macOS btw) have a version settings. I need to ensure that my packages are upward compatible with a specific minimum macOS version. Today I handle it by myself via the options mechanisms but then it s also passed to non-macOS packages, thus I have to remove it.

The sole usage of this version would be to add compiler flags to some generators and add the CMAKE_OSX_DEPLOYMENT_TARGET variable to CMake generator see CMake's doc on the subject

from Apple's Developer docs -mmacosx-version-min version

Specifies the version of OS X you are targeting. You must target your compile for the oldest version of OS X on which you want to run the executable. In addition, you should install and use the cross-development SDK for that version of OS X. For more information, see SDK Compatibility Guide.

Here is an example of how I do it now via the options mechanism

class MyConanProject(ConanFile):
    name = "MyConanProject"
    version = "2.4.1"
    generators = "cmake", "txt", "virtualenv"
    settings = "os", "arch", "compiler", "build_type"
    options = {"shared": [True, False],
               "minosx": ['10.7', '10.8', '10.9', '10.10', '10.11', '10.12', '10.13']
               }
    default_options = "shared=True", "minosx=10.7"
    requires = "mylib/2.4.1@user/channel"

   def config_options(self):            
        self.options["mylib"].shared = self.options.shared

        if self.settings.os == "Macos":
            self.options["mylib"].minosx = self.options.minosx
        else:
            self.options.remove('minosx')

    def build(self):
        cmake = CMake(self)

        cmake.definitions['CMAKE_OSX_DEPLOYMENT_TARGET'] = self.options.minosx

[...]
lasote commented 6 years ago

Kind of related with #2476 , not in contents but about taking decisions on new settings for flags.

lasote commented 6 years ago

Look at #2534. It should be managed with the new os.version (to be considered a min version)