blob: 5de103201e26b930ba766de017f99442164b1f8d [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001macro(wpilib_target_warnings target)
2 if(NOT MSVC)
Maxwell Henderson80bec322024-01-09 15:48:44 -08003 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 Silverman8fce7482020-01-05 13:18:21 -080015 else()
Maxwell Henderson80bec322024-01-09 15:48:44 -080016 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 Kuszmaulcf324122023-01-14 14:07:17 -080027 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 Henderson80bec322024-01-09 15:48:44 -080032 target_compile_options(
33 ${target}
34 PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>
35 )
James Kuszmaulcf324122023-01-14 14:07:17 -080036 elseif(UNIX AND APPLE)
Maxwell Henderson80bec322024-01-09 15:48:44 -080037 target_compile_options(
38 ${target}
39 PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-anon-enum-enum-conversion>
40 )
Brian Silverman8fce7482020-01-05 13:18:21 -080041 endif()
James Kuszmaulb13e13f2023-11-22 20:44:04 -080042
43 # Suppress warning "enumeration types with a fixed underlying type are a
44 # Clang extension"
45 if(APPLE)
Maxwell Henderson80bec322024-01-09 15:48:44 -080046 target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-fixed-enum-extension>)
James Kuszmaulb13e13f2023-11-22 20:44:04 -080047 endif()
48
49 # Compress debug info with GCC
Maxwell Henderson80bec322024-01-09 15:48:44 -080050 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 Kuszmaulb13e13f2023-11-22 20:44:04 -080055 endif()
Brian Silverman8fce7482020-01-05 13:18:21 -080056endmacro()