dev-cafe / cmake-cookbook

CMake Cookbook recipes.
Other
2.71k stars 696 forks source link

set_compiler_flag confusing #510

Open JVApen opened 5 years ago

JVApen commented 5 years ago

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

bast commented 5 years ago

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

bast commented 5 years ago

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.