Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
deleted 2 characters in body
Source Link
Bernard
  • 5.8k
  • 1
  • 43
  • 76

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 -DCXXMAKE_C_FLAGS="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.

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 -DCXXMAKE_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.

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.

Source Link
Bernard
  • 5.8k
  • 1
  • 43
  • 76

Setting CMAKE_C_FLAGS and CMAKE_CXX_FLAGS to the same thing without repeating oneself?

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 -DCXXMAKE_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.