File tree Expand file tree Collapse file tree 5 files changed +19
-10
lines changed Expand file tree Collapse file tree 5 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,17 @@ macro(add_flags LANG)
115
115
set (CMAKE_${LANG}_FLAGS "${CMAKE_${LANG} _FLAGS}" PARENT_SCOPE )
116
116
endmacro ()
117
117
118
+ include (CheckCXXCompilerFlag )
119
+
120
+ # Set single compiler flag only if it is supported, ignore otherwise
121
+
122
+ macro (set_compiler_flag FLAG )
123
+ unset (flag_supported CACHE )
124
+ CHECK_CXX_COMPILER_FLAG (${FLAG} flag_supported )
125
+ if (flag_supported )
126
+ add_compile_options (${FLAG} )
127
+ endif ()
128
+ endmacro ()
118
129
119
130
# -----------------------------------------------------------------
120
131
Original file line number Diff line number Diff line change @@ -96,20 +96,20 @@ set_visibility(hidden)
96
96
97
97
if (GCC AND GCC VERSION_GREATER 11 )
98
98
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106199
99
- add_compile_options (-Wno-stringop-overflow )
100
- add_compile_options (-Wno-stringop-overread )
99
+ set_compiler_flag (-Wno-stringop-overflow )
100
+ set_compiler_flag (-Wno-stringop-overread )
101
101
endif ()
102
102
103
103
if (NOT MSVC OR CLANG )
104
- add_compile_options (-Wno-unused-const-variable )
104
+ set_compiler_flag (-Wno-unused-const-variable )
105
105
endif ()
106
106
107
107
if (WIN32 )
108
108
add_compile_definitions (_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS )
109
109
endif ()
110
110
111
111
if (APPLE )
112
- add_compile_options (-Wno-deprecated-declarations )
112
+ set_compiler_flag (-Wno-deprecated-declarations )
113
113
endif ()
114
114
115
115
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ if(WIN32)
25
25
# conformant name: _open. See online help for details.
26
26
27
27
if (CLANG )
28
- add_compile_options (-Wno-deprecated-declarations )
28
+ set_compiler_flag (-Wno-deprecated-declarations )
29
29
else ()
30
30
add_compile_options (/wd4996 )
31
31
endif ()
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ endif()
22
22
if (WIN32 AND CLANG )
23
23
# This warning shows only when building with clang on Win (clang 18):
24
24
# lib\compress\huf_compress.c(519,16): error : unused function 'HUF_isSorted'
25
- add_compile_options (-Wno-unused-function )
25
+ set_compiler_flag (-Wno-unused-function )
26
26
endif ()
27
27
28
28
Original file line number Diff line number Diff line change @@ -215,10 +215,8 @@ if(NOT SHOW_JDBC_WARNINGS)
215
215
216
216
else ()
217
217
218
- add_compile_options (
219
- -Wno-unused-parameter
220
- -Wno-deprecated-declarations
221
- )
218
+ set_compiler_flag (-Wno-unused-parameter )
219
+ set_compiler_flag (-Wno-deprecated-declarations )
222
220
223
221
endif ()
224
222
You can’t perform that action at this time.
0 commit comments