-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Modernize compiler and linker flags #7255
Conversation
There are a couple of things going on here, so I'll explain them bit by bit in the hope that it'll help you (and maybe others reading this too) to figure things out more easily in the future. First, it's worth understanding how quotes work in CMake. The only data type in CMake is the string - a list is merely a string with semicolons separating the different elements. When you pass a variable as an argument to a command, it is passed as a list by default. This means that it will be split on semicolons, and each part will be passed as a separate argument. To pass a variable as a string, it can be wrapped in double quotes, which ensures that it remains a single argument. For example: set(VARIABLE "a;b")
# These are equivalent to one another:
some_function(${VARIABLE})
some_function("a" "b")
# As are these
some_function("${VARIABLE}")
some_function("a;b") Spaces are not list separators: set(VARIABLE "a b")
# All three of these are equivalent
some_function(${VARIABLE})
some_function("${VARIABLE}")
some_function("a b") Spaces do, however, separate arguments. Quotes in CMake are optional, but will be necessary if you want to include a space within a string: # These two are equivalent, passing two arguments
some_function(a b)
some_function("a" "b")
# This is different, passing a single argument
some_function("a b") The # These are equivalent
set(VARIABLE a b)
set(VARIABLE "a;b") All in all, a good rule of thumb is to use quotes for strings, and to omit them for lists. Now, CMake has a variety of ways to add libraries, definitions, compiler options, linker options, include directories, etc. There are typically two commands for each category: one affects all future targets defined in the current directory and its subdirectories, and the other begins with The values in use for each category are stored in properties on targets. Targets typically have two properties for each category: one stores the values used for building the current target itself, and the other begins with Here is a summary of the categories that are most likely to be relevant to this task:
There is also a An important difference between the I realise this is a bit of a wall of text, but I hope it's more generally useful than simply telling you what to do for each line. I recommend going through each change here and asking yourself: "which command is appropriate?", "should the flags be public, private, or interface?", and "how should I separate the flags?", using the information above to help you. Let me know if there's a line you're stuck on, and I can walk you through what my decision process would be. (Finally, I'm not sure |
Thanks for the info dom, though to be honest, I couldn't chew most of it. So from what you are saying, it seems like I'm handling the lists and "s wrong. I will attempt another fix but I'll wait for cmake to get bumped to 3.13, atleast that's what i understand. |
Somewhat related; @messmerd is working on bumping the cmake version we have in the containers. The snap store has a much newer version as well (e.g. available to older Ubuntu versions) , so we can recommend that in our wiki to end-users. |
Switching this to a draft, because @DomClark requests we use newer language features prior to merging, quoting:
@Rossmaxx I would recommend that you bump the require CMake version and update this PR accordingly.
It's paramount to the project that you can "chew" it because it modernizes our CMake calls. Furthemore, the difference between using lists (versus strings with spaces) should make code cleaner and easier to maintain. If you don't want to do this task, someone else eventually will, but I'm moving this to draft until the PR's OP has a clearer direction. |
Ahh, I found out what the actual mistake was in my PR. I used |
I am resetting this PR and will push the new changes soon. |
Looking back at dom's text wall, I realize that that is exactly what he said. I will do the changes anyway and get it to compile everywhere else and then take another look when we get cmake > 3.13 on mingw |
I'll look at the new errors later. |
All that's left now is bumping the cmake version. Waiting for #7259 for that |
This reverts commit 43fbcca.
This reverts commit 43fbcca.
fixes: #4430