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

Use CMAKE_OSX_DEPLOYMENT_TARGET to get -version-min set in CMakeToolchain #9282

Closed
memsharded opened this issue Jul 17, 2021 · 6 comments · Fixed by #9301
Closed

Use CMAKE_OSX_DEPLOYMENT_TARGET to get -version-min set in CMakeToolchain #9282

memsharded opened this issue Jul 17, 2021 · 6 comments · Fixed by #9301

Comments

@memsharded
Copy link
Member

I still have to use CMAKE_OSX_DEPLOYMENT_TARGET to get -version-min set properly in macOS and iOS builds in Conan 1.38.

Here's my generate function:

def generate(self):
        tc = CMakeToolchain(self)
        tc.generator = "Ninja Multi-Config"
        tc.generate()
        deps = CMakeDeps(self)
        deps.generate()

macOS configuration:

[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=12.0
os=Macos
os.version=10.9
os_build=Macos

iOS configuration:

[settings]
arch=armv7
arch_build=x86_64
build_type=Debug
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=12.0
os=iOS
os.version=9.0
os_build=Macos

Adding this to the generate function still fixes it:

if self.settings.os == "iOS":
            tc.variables["CMAKE_OSX_DEPLOYMENT_TARGET"] = self.settings.os.version
        elif self.settings.os == "Macos":
            tc.variables["CMAKE_OSX_DEPLOYMENT_TARGET"] = self.settings.os.version

So I'm not blocked, but it sounded like you were interested in implementing this capability. Let me know if I should log a separate item.

Originally posted by @ssrobins in #9025 (comment)

@ssrobins
Copy link
Contributor

Thanks for posting a new issue.

To answer your questions in the closed issue, yes the change would be:

if self.settings.os == "iOS" or self.settings.os == "Macos":
      # assign CMAKE_OSX_DEPLOYMENT_TARGET

I had them as separate if statements only because I was adding/removing lots of settings and hadn't cleaned anything up yet.

According to CMake, this setting is also used for tvOS and watchOS:
https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html

@SSE4
Copy link
Contributor

SSE4 commented Jul 19, 2021

@memsharded we have a comment there:

# TODO: Discuss how to handle CMAKE_OSX_DEPLOYMENT_TARGET to set min-version

        # TODO: Discuss how to handle CMAKE_OSX_DEPLOYMENT_TARGET to set min-version
        #       add a setting? check an option and if not present set a default?
        #       default to os.version?

@memsharded
Copy link
Member Author

@ssrobins #9301 added this, and has been merged for 1.39, in case you want to give it a try from develop branch. Thanks!

@ssrobins
Copy link
Contributor

When I installed 1.39, and removed tc.variables["CMAKE_OSX_DEPLOYMENT_TARGET"] = self.settings.os.version, I see -version-min set properly on iOS, but not macOS.

@memsharded
Copy link
Member Author

When I installed 1.39, and removed tc.variables["CMAKE_OSX_DEPLOYMENT_TARGET"] = self.settings.os.version, I see -version-min set properly on iOS, but not macOS.

Can you please check if you have the os.version defined in your profile for Macos?

@ssrobins
Copy link
Contributor

I have -s os.version=10.9 in my conan create command. I confirmed that everything worked fine when my conanfile.py had tc.variables["CMAKE_OSX_DEPLOYMENT_TARGET"] = self.settings.os.version, but when I removed that code, -version-min show in the build output. Just tried with the release of 1.39.0 to double check and it's still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants