| 1 |
# add compile options to warning_options to ensure unused-function throws a warning |
| 2 |
# if warning_options is NOT DEFINED, assume compiler doesn't support warning as error |
| 3 |
macro(get_warning_options warning_options lang) |
| 4 |
if (CMAKE_${lang}_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang|XLClang|IBMClang|LCC|IntelLLVM|NVHPC)$") |
| 5 |
set(${warning_options} "-Wall") |
| 6 |
elseif (CMAKE_${lang}_COMPILER_ID STREQUAL "MSVC" |
| 7 |
OR (CMAKE_${lang}_COMPILER_ID STREQUAL "Intel" AND CMAKE_${lang}_SIMULATE_ID MATCHES "MSVC")) |
| 8 |
set(${warning_options} "-W4") |
| 9 |
elseif (CMAKE_${lang}_COMPILER_ID STREQUAL "NVIDIA" |
| 10 |
AND CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 10.2.89) |
| 11 |
if(CMAKE_${lang}_SIMULATE_ID MATCHES "MSVC") |
| 12 |
set(${warning_options} "-Xcompiler=-W4") |
| 13 |
else() |
| 14 |
set(${warning_options} "-Xcompiler=-Wall") |
| 15 |
endif() |
| 16 |
elseif (CMAKE_${lang}_COMPILER_ID STREQUAL "Intel") |
| 17 |
set(${warning_options} "-w3") |
| 18 |
elseif (CMAKE_${lang}_COMPILER_ID STREQUAL "XL") |
| 19 |
set(${warning_options} "-qinfo=all") |
| 20 |
elseif (CMAKE_${lang}_COMPILER_ID STREQUAL "SunPro") |
| 21 |
if(lang STREQUAL CXX) |
| 22 |
set(${warning_options} "+w;+w2") |
| 23 |
else() |
| 24 |
set(${warning_options} "") |
| 25 |
endif() |
| 26 |
elseif (CMAKE_${lang}_COMPILER_ID STREQUAL "Fujitsu") |
| 27 |
set(${warning_options} "SHELL:-w 8") |
| 28 |
endif() |
| 29 |
|
| 30 |
if(${lang} STREQUAL Swift) |
| 31 |
# No extra flags required for Swift |
| 32 |
set(${warning_options} "") |
| 33 |
endif() |
| 34 |
endmacro() |