-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Set correct minimum macOS version with CMake #14813
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the right approach.
See the docs: https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html
MACOSX_DEPLOYMENT_TARGET
is supposed to be an environment variable. As such, it should not be forced in the build script.
According to the docs, it's CMAKE_OSX_DEPLOYMENT_TARGET
that is supposed to be initialized by MACOSX_DEPLOYMENT_TARGET
, not the other way around.
Also, according to the docs, this is also the wrong place to set it:
The value of this variable should be set prior to the first
project()
orenable_language()
command invocation because it may influence configuration of the toolchain and flags. It is intended to be set locally by the user creating a build tree. This variable should be set as aCACHE
entry (or else CMake may remove it while initializing a cache entry of the same name).
In addition, the fact that currently ${MACOSX_DEPLOYMENT_TARGET}
is currently used as the variable name for the substitution in the Info.plist file is a problem IMO, so the fix should start by changing that probably.
Let's hope qmake does not conflict with "the right way" to do things here. Ah, the joys of maintaining 2 build systems...
I think this should work (sorry for not posting in actual patch format, doing this in a hurry; the explanation for each change is at the end of the post):
change this: # substitute @EXECUTABLE@ in dist/mac/Info.plist
get_target_property(EXECUTABLE qbt_app OUTPUT_NAME)
configure_file(${qBittorrent_SOURCE_DIR}/dist/mac/Info.plist
${qBittorrent_BINARY_DIR}/dist/mac/pregen.plist @ONLY)
file(GENERATE
OUTPUT ${qBittorrent_BINARY_DIR}/dist/mac/Info.plist
INPUT ${qBittorrent_BINARY_DIR}/dist/mac/Info.plist
) to this: # perform @ substitutions
get_target_property(EXECUTABLE qbt_app OUTPUT_NAME)
configure_file(${qBittorrent_SOURCE_DIR}/dist/mac/Info.plist
${qBittorrent_BINARY_DIR}/dist/mac/pregen.plist @ONLY)
change this: <string>${MACOSX_DEPLOYMENT_TARGET}.0</string> to this: <string>@CMAKE_OSX_DEPLOYMENT_TARGET@</string> Basically, I don't think we need the IDK what changes would be required on the qmake side though. If the naming of the substitution is a problem for qmake, you could do something like |
@FranciscoPombal thanks for such good review! I waited it. |
so, I'm back.
that's how qmake actually "sets" these variables. also I made some search for any solutions how to make variable substitutions if files using qmake, unfortunately there is no such API... one solution I see that read whole file into variable, make string substitutions, and write it again using qmake functions. but I think such inconvenient approach is not worth this small issue... from other side, cmake also doesn't provide any "right way" to "deliver" this particular value to Info.plist. what I did just works due to cmake feature mentioned in last sentences of that page. so, now I can suggest next solutions for it:
I'm fine with any of suggested options, but first two are preferable for me. any thoughts and criticism are welcome. |
There may be a simpler solution: can't we get away with simply changing every Then you could apply the changes suggested in my comment, and just remove the That way, there would be no problem with qmake. If this is not possible, then I would personally prefer solution 2) that you suggested. A bunch of other stuff is also hardcoded, and it's not like we would have to update that field too often...
|
@FranciscoPombal |
@FranciscoPombal , PR is updated. I used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, seems reasonable, just 2 more comments based on the new changes.
- drop configure_file() and file(GENERATE) calls - fill missed MACOSX_DEPLOYMENT_TARGET variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now, thanks @Kolcha!
@Kolcha |
Set correct minimum macOS version with CMake
Info.plist has ${MACOSX_DEPLOYMENT_TARGET} placeholder which is filled
by qmake, but not CMake. And as result, when building with CMake value
of LSMinimumSystemVersion field is '.0'. This happens because CMake has
possibility to substitute placeholders with values from corresponding
variables, and as so as there is no such variable, empty value is used.
So, to fix this, just set CMake variable MACOSX_DEPLOYMENT_TARGET to
CMAKE_OSX_DEPLOYMENT_TARGET value.
no fix, master as is:
![Screen Shot 2021-04-18 at 15 44 09](https://user-images.githubusercontent.com/947647/115150356-9fa36900-a070-11eb-9790-aaa25a5f874c.png)
with fix, this branch:
![Screen Shot 2021-04-18 at 17 30 09](https://user-images.githubusercontent.com/947647/115150371-afbb4880-a070-11eb-92f0-86a8bf5d016c.png)
P.S> maybe it is worth to set
CMAKE_OSX_DEPLOYMENT_TARGET
explicitly in root CMakeLists.txt instead of passing it to command line each time (especially when 10.14 is required)? similar thing is done for qmake:qBittorrent/macxconf.pri
Line 10 in c7c7924