GothenburgBitFactory / taskwarrior

Taskwarrior - Command line Task Management
https://taskwarrior.org
MIT License
4.49k stars 309 forks source link

Set CMake C++ standard #3688

Closed kietavainen closed 1 week ago

kietavainen commented 1 week ago

Instead of setting -std compiler flag directly, set the CMAKE_CXX_STANDARD variable. This lets CMake know the required C++ standard and evaluate the final compiler flag correctly, taking into account compile features set by target_compile_features().

This change preserves the existing behavior, where compiler extensions are disabled for other targets than Cygwin.

Fixes #3687.

kietavainen commented 1 week ago

Previously, the standard was set with -std=c++17 flag, except on Cygwin where -std=gnu++17 was used. I wasn't sure if this was really intentional, so I preserved the earlier behavior. CMake enables compiler extensions by default, so by removing the CMAKE_CXX_EXTENSIONS settings, it would use -std=gnu++17 on all platforms. Please let me know if that would be acceptable, and I can update the PR.

djmitche commented 1 week ago

@felixschurk what do you think? This flag was also set, but just for CI, in 01ced3238e87b71647fcdf8179907524e97ff54a.

felixschurk commented 1 week ago

I think that's the better solution which also enables to easily upgrade the standard in one place in the future.

We can then remove the flag introduced in 01ced32.

felixschurk commented 1 week ago

In regards to the difference with cygwin, I unfortunately have no clue.

djmitche commented 1 week ago

Great! I'll revert that commit then.

djmitche commented 1 week ago

In regards to the difference with cygwin, I unfortunately have no clue.

I think WSL is much more common these days, so maybe this doesn't matter?