|
| 1 | +2017-08-08 Michael Catanzaro < [email protected]> |
| 2 | + |
| 3 | + [CMake] Properly test if compiler supports compiler flags |
| 4 | + https://bugs.webkit.org/show_bug.cgi?id=174490 |
| 5 | + |
| 6 | + Reviewed by Konstantin Tokarev. |
| 7 | + |
| 8 | + This turned out to be a massive pain. I didn't want to merely check options before using |
| 9 | + them: I also wanted to organize the code to avoid setting similar flags in different places. |
| 10 | + Right now we set a bunch of global flags in OptionsCommon.cmake, and a bunch more flags in |
| 11 | + WEBKIT_SET_EXTRA_COMPILER_FLAGS on a per-target basis. |
| 12 | + |
| 13 | + Setting flags per-target seems better in general, e.g. because it makes it very easy to |
| 14 | + disable warnings for particular ThirdParty targets. But it turns out that all the flags set |
| 15 | + on a per-target basis get passed to both the C compiler and the C++ compiler, so it's |
| 16 | + impossible to pass C++-only flags there. That's terrible. It's possible to make the flags |
| 17 | + language-conditional using generator expressions, but that doesn't work for the Visual |
| 18 | + Studio backend, so we would have to drop support for that (not going to happen). The CMake |
| 19 | + documentation suggests that C and C++ files ought to be built in separate targets to avoid |
| 20 | + this. It's a mess, basically. |
| 21 | + |
| 22 | + So I've wound up removing WEBKIT_SET_EXTRA_COMPILER_FLAGS and adding most of those flags to |
| 23 | + CMAKE_C_FLAGS and CMAKE_CXX_FLAGS instead. Really the only disadvantage of this is we now |
| 24 | + have to suppress individual warnings when building ANGLESupport in WebCore. That's not the |
| 25 | + end of the world. The only remaining useful feature of WEBKIT_SET_EXTRA_COMPILER_FLAGS was |
| 26 | + to add -fPIC to static library targets, but turns out CMake does that for us if we just set |
| 27 | + the variable CMAKE_POSITION_INDEPENDENT_CODE, so we can get rid of it completely. |
| 28 | + |
| 29 | + Of course there are also macros for setting target-specific compiler flags, which we |
| 30 | + frequently need in order to suppress specific warnings, particularly warnings coming from |
| 31 | + third-party libraries like ANGLE and gtest. But remember the footgun: these macros will test |
| 32 | + the flag against only one compiler, but must work with both C and C++ compilers unless the |
| 33 | + build target exclusively contains targets built with just one of those compilers. Yuck. |
| 34 | + |
| 35 | + * CMakeLists.txt: |
| 36 | + * Source/CMakeLists.txt: |
| 37 | + * Source/PlatformGTK.cmake: |
| 38 | + * Source/cmake/OptionsCommon.cmake: |
| 39 | + * Source/cmake/WebKitCommon.cmake: |
| 40 | + * Source/cmake/WebKitCompilerFlags.cmake: Added. |
| 41 | + * Source/cmake/WebKitMacros.cmake: |
| 42 | + |
1 | 43 | 2017-08-07 Brian Burg < [email protected]>
|
2 | 44 |
|
3 | 45 | Remove CANVAS_PATH compilation guard
|
|
0 commit comments