threeal / CheckWarning.cmake

Check for compiler warnings in your CMake project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Functions Do Not Set Warning Flags

threeal opened this issue · comments

This issue pinpoints a bug when using either target_check_warning or add_check_warning functions. It seems that those functions does not set any warning flags to the compile options. After further investigation this issue seems caused by the usage of the WARNING_FLAGS variable which is introduced in #45. Variables in CMake work differently from common programming language logic and may not persist between project, so it is discouraged to set variable that will later be used on a function.

To address this, one of the solution is to replace the WARNING_FLAGS variable with a function that will output the same value as the WARNING_FLAGS variable. By this, there will still a single source for warning flags while also preventing the flags from being unavailable when either target_check_warning or add_check_warning functions needed it.