If setting CFLAGS to cmake from command-line does not work

What happens if you really try to add some CFLAGS to cmake from command-line…

export CFLAGS="-Werror"
export CXXFLAGS="-Werror"
cmake ..
make VERBOSE=1

…but it does not do anything at all?

If you encounter this problem, it is likely that you overwrite CFLAGS somewehere in your CMakeLists.txt files.

For example, replace this:

set(CMAKE_C_FLAGS "-std=c99")

…with the correct one that appends the new flags instead of overwriting them:

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")