cmake-cookbook icon indicating copy to clipboard operation
cmake-cookbook copied to clipboard

set_compiler_flag confusing

Open JVApen opened this issue 6 years ago • 2 comments

Reading through the book, the function set_compiler_flag doesn't result in the expected behavior.

Expected Behavior

After calling set_compiler_flag, I would expect that compiler flag to be set.

Current Behavior

The function sets a status variable to indicate that the flag is valid.

Possible Solution

Rename to check_compiler_flag or find_valid_compiler_flag

JVApen avatar Mar 31 '19 10:03 JVApen

Thank you for reporting! I will try to reproduce this.

bast avatar Apr 08 '19 07:04 bast

And I believe you mean this example: https://github.com/dev-cafe/cmake-cookbook/blob/master/chapter-07/recipe-03/c-cxx-example/set_compiler_flag.cmake

Which indeed sets a variable but does not modify global compiler flag variables since we wanted to give the caller the flexibility to set them per-target or project-wide.

bast avatar Apr 08 '19 07:04 bast