Only add flags if compiler supports them
advanced disk information utility
Brought to you by:
bll123
As an aside in another ticket, I mentioned that an old clang compiler failed to build di 5.0.0 with this error:
clang: error: unknown argument: '-fstack-protector-strong'
The workaround was to use the make flag DI_FORTIFY=N to disable the use of that flag.
A MacPorts user using the gcc compiler (possibly the very old version 4.2.1, since they reported using Mac OS X 10.6 on which that was the default compiler) has now reported this build failure with di 5.0.3:
cc1: error: unrecognized command line option "-Wno-unused-but-set-variable"
cc1: error: unrecognized command line option "-Wmaybe-uninitialized"
cc1: error: unrecognized command line option "-Wno-stringop-overflow"
cc1: error: unrecognized command line option "-Wno-stringop-truncation"
cc1: error: unrecognized command line option "-Wno-format-truncation"
Instead of adding yet more makefile flags that need to be specified manually to enable or disable compiler flags, maybe the build system could check if the compiler supports a flag before deciding to add it.
I actually have no idea how to do this with cmake. My mkconfig build system does do these checks.
I don't want to use check-source-compiles, as I'd like to keep the requirements for cmake on 3.13. I'll look into creating some sort of macro that tests the warnings. It's going to be quite the mess.
As I said before, I really wasn't expecting to run into modern cmake on old computers, and this is causing problems.
gcc-4 is a real pain on old computers -- I get a lot of "code cannot be reached" warnings. di still seems to run ok.
I am not well versed in writing cmake files but a quick search suggests using
check_c_compiler_flag.It doesn't strike me as an old-cmake vs new-cmake problem. It strikes me as a problem of your CMakeLists.txt adding flags unconditionally when not all compilers support them.
Ah, great, thanks for that. Apparently I never even looked to see if that existed.
If the modern cmake was not on old systems, the flag settings would generally work fine (well, that's a generalization), as all modern compilers support them, though as you pointed out in the other ticket, I was unaware of the split of clang versions.
In any case, flag testing is a very good thing. It will get done.
Fixed in 5.0.5
Fixed in 5.0.5