CMake: Allow user build flags to override default build flags
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>
Sun, 24 Sep 2017 01:30:08 +0000 (02:30 +0100)
committerPeter Wu <peter@lekensteyn.nl>
Fri, 13 Oct 2017 21:32:18 +0000 (21:32 +0000)
commit9bba3866ffc0d382d511d298d2460c618bfa6c0d
treed900cce53485ca54b579cc71c3e0e726ff898041
parent68ef8797118b6015ac47130c789cd93e73b03597
CMake: Allow user build flags to override default build flags

Autotools has the very useful feature by design of allowing the user
to override the default build flags (you break it you keep it).

Apparently CMake applies COMPILE_OPTIONS target property after
CMAKE_{C,CXX}_FLAGS so that doesn't work here. Prepend our flags to those
variables instead to make it work then.

Specific target flag overrides can still be added with COMPILER_OPTIONS
(e.g: generated files with -Wno-warning) but this is less effective and
then we're back at the point where this overrides user flags. It's less
of a concern though.

Change-Id: I44761a79be4289238e02d4e781fef0099628817b
Reviewed-on: https://code.wireshark.org/review/23675
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
20 files changed:
CMakeLists.txt
capchild/CMakeLists.txt
caputils/CMakeLists.txt
cmake/modules/WiresharkPlugin.cmake
codecs/CMakeLists.txt
epan/CMakeLists.txt
epan/crypt/CMakeLists.txt
epan/dfilter/CMakeLists.txt
epan/dissectors/CMakeLists.txt
epan/ftypes/CMakeLists.txt
epan/wmem/CMakeLists.txt
epan/wslua/CMakeLists.txt
randpkt_core/CMakeLists.txt
tools/lemon/CMakeLists.txt
ui/CMakeLists.txt
ui/gtk/CMakeLists.txt
ui/qt/CMakeLists.txt
wiretap/CMakeLists.txt
writecap/CMakeLists.txt
wsutil/CMakeLists.txt