I've a CMake project containing C and C++ files, and I have a CI set up. In the CI, I want to build my project with some additional flags to make the compiler stricter, in particular -Wall -Wextra -Werror -pedantic
.
To configure the project, I'm currently repeating myself by doing this:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Wall -Wextra -Werror -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -Werror -pedantic"
As I don't want these flags baked into the CMakeLists file (since this strictness is only wanted in the CI), I'm setting the flags on the configure command in the CI.
Is there any way to rewrite this command in a way where I don't need to repeat the flags?
Note: CMAKE_CPP_FLAGS
does not work.