Use a unique variable name when checking if a flag is valid (#3532)
This commit is contained in:
parent
e998cd13ca
commit
1f5c3670bd
|
@ -1,15 +1,17 @@
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
function(add_compile_options_safe FLAG)
|
function(add_compile_options_safe FLAG)
|
||||||
check_cxx_compiler_flag(${FLAG} _has_flag)
|
string(MAKE_C_IDENTIFIER "HAS_CXX_FLAG${FLAG}" mangled_flag)
|
||||||
if (_has_flag)
|
check_cxx_compiler_flag(${FLAG} ${mangled_flag})
|
||||||
|
if (${mangled_flag})
|
||||||
add_compile_options(${FLAG})
|
add_compile_options(${FLAG})
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(target_compile_options_safe TARGET FLAG)
|
function(target_compile_options_safe TARGET FLAG)
|
||||||
check_cxx_compiler_flag(${FLAG} _has_flag)
|
string(MAKE_C_IDENTIFIER "HAS_CXX_FLAG${FLAG}" mangled_flag)
|
||||||
if (_has_flag)
|
check_cxx_compiler_flag(${FLAG} ${mangled_flag})
|
||||||
|
if (${mangled_flag})
|
||||||
target_compile_options(${TARGET} PRIVATE ${FLAG})
|
target_compile_options(${TARGET} PRIVATE ${FLAG})
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
Loading…
Reference in New Issue