Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 1 | macro(wpilib_target_warnings target) |
| 2 | if(NOT MSVC) |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame^] | 3 | set(WARNING_FLAGS |
| 4 | -Wall |
| 5 | -pedantic |
| 6 | -Wextra |
| 7 | -Wno-unused-parameter |
| 8 | ${WPILIB_TARGET_WARNINGS} |
| 9 | ) |
| 10 | if(NOT NO_WERROR) |
| 11 | set(WARNING_FLAGS ${WARNING_FLAGS} -Werror) |
| 12 | endif() |
| 13 | |
| 14 | target_compile_options(${target} PRIVATE ${WARNING_FLAGS}) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 15 | else() |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame^] | 16 | target_compile_options( |
| 17 | ${target} |
| 18 | PRIVATE |
| 19 | /wd4146 |
| 20 | /wd4244 |
| 21 | /wd4251 |
| 22 | /wd4267 |
| 23 | /WX |
| 24 | /D_CRT_SECURE_NO_WARNINGS |
| 25 | ${WPILIB_TARGET_WARNINGS} |
| 26 | ) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 27 | endif() |
| 28 | |
| 29 | # Suppress C++-specific OpenCV warning; C compiler rejects it with an error |
| 30 | # https://github.com/opencv/opencv/issues/20269 |
| 31 | if(UNIX AND NOT APPLE) |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame^] | 32 | target_compile_options( |
| 33 | ${target} |
| 34 | PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion> |
| 35 | ) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 36 | elseif(UNIX AND APPLE) |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame^] | 37 | target_compile_options( |
| 38 | ${target} |
| 39 | PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-anon-enum-enum-conversion> |
| 40 | ) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 41 | endif() |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 42 | |
| 43 | # Suppress warning "enumeration types with a fixed underlying type are a |
| 44 | # Clang extension" |
| 45 | if(APPLE) |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame^] | 46 | target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-fixed-enum-extension>) |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 47 | endif() |
| 48 | |
| 49 | # Compress debug info with GCC |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame^] | 50 | if( |
| 51 | (${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo") |
| 52 | AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" |
| 53 | ) |
| 54 | target_compile_options(${target} PRIVATE -gz=zlib) |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 55 | endif() |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 56 | endmacro() |