Different OSX Deployment version between projects
Closed this issue · 4 comments
I’m a beginner at cmake but this looks awesome, I was wondering how subprojects could use different minimum deployment versions for OS X projects?
edit: Sorry for the mini-stroke I had here! I want to support an old project while also benefit from C++17 that requires macOS 10.14. There’s a global conflict when having two projects with different deployment version targets, I’m just hoping for any advice and there’s no issue with the actual template:)
Hey! So there are definitely ways to do it per target:
function(set_min_macos_version target version)
if (APPLE)
set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET ${version})
target_compile_options(${target} PUBLIC "-mmacosx-version-min=${version}")
target_link_options(${target} PUBLIC "-mmacosx-version-min=${version}")
endif ()
endfunction()
And then:
set_min_macos_version(MyPluginTarget 10.14)
P.S. You can definitely support C++17 even on MacOS 10.9.
There are only a few non-supported things like std::variant, std::optional and std::filesystem.
I'm using both std::variant and std::optional in my code but nice to know that if I drop using them I can support older macOS versions. Thank you for the helper function, this is perfect!
There are some alternative implementations that implement both std::variant and std::optional but with C++11 compatibility:
https://github.com/mpark/variant
https://github.com/TartanLlama/optional
I've personally used the variant one and it works really well and surprisingly compiles much faster, too.