cloudflare/ClickHouse
Publicmirrored fromhttps://github.com/cloudflare/ClickHouse
cmake/add_warning.cmake
29lines · modecode
unknown
| 1 | include (CheckCXXCompilerFlag) |
| 2 | include (CheckCCompilerFlag) |
| 3 | |
| 4 | # Try to add -Wflag if compiler supports it |
| 5 | macro (add_warning flag) |
| 6 | string (REPLACE "-" "_" underscored_flag ${flag}) |
| 7 | string (REPLACE "+" "x" underscored_flag ${underscored_flag}) |
| 8 | |
| 9 | check_cxx_compiler_flag("-W${flag}" SUPPORTS_CXXFLAG_${underscored_flag}) |
| 10 | check_c_compiler_flag("-W${flag}" SUPPORTS_CFLAG_${underscored_flag}) |
| 11 | |
| 12 | if (SUPPORTS_CXXFLAG_${underscored_flag}) |
| 13 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W${flag}") |
| 14 | else () |
| 15 | message (WARNING "Flag -W${flag} is unsupported") |
| 16 | endif () |
| 17 | |
| 18 | if (SUPPORTS_CFLAG_${underscored_flag}) |
| 19 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W${flag}") |
| 20 | else () |
| 21 | message (WARNING "Flag -W${flag} is unsupported") |
| 22 | endif () |
| 23 | |
| 24 | endmacro () |
| 25 | |
| 26 | # Try to add -Wno flag if compiler supports it |
| 27 | macro (no_warning flag) |
| 28 | add_warning(no-${flag}) |
| 29 | endmacro () |