diff options
author | Paweł Bylica <chfast@gmail.com> | 2017-09-21 18:41:06 +0800 |
---|---|---|
committer | Paweł Bylica <chfast@gmail.com> | 2017-09-26 20:21:01 +0800 |
commit | 5722f3083cae829c28a28083fa806005ed71168c (patch) | |
tree | 4c4049fb31319c0c4ce417ce8b918f387fa528a8 /cmake/EthCheckCXXCompilerFlag.cmake | |
parent | af4d8779bb84e52607410bc512307a408d7f21a1 (diff) | |
download | dexon-solidity-5722f3083cae829c28a28083fa806005ed71168c.tar.gz dexon-solidity-5722f3083cae829c28a28083fa806005ed71168c.tar.zst dexon-solidity-5722f3083cae829c28a28083fa806005ed71168c.zip |
CMake: Add compiler warning about implicit fallthough
Diffstat (limited to 'cmake/EthCheckCXXCompilerFlag.cmake')
-rw-r--r-- | cmake/EthCheckCXXCompilerFlag.cmake | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cmake/EthCheckCXXCompilerFlag.cmake b/cmake/EthCheckCXXCompilerFlag.cmake new file mode 100644 index 00000000..c6ed35b4 --- /dev/null +++ b/cmake/EthCheckCXXCompilerFlag.cmake @@ -0,0 +1,23 @@ +include(CheckCXXCompilerFlag) + +# Adds CXX compiler flag if the flag is supported by the compiler. +# +# This is effectively a combination of CMake's check_cxx_compiler_flag() +# and add_compile_options(): +# +# if(check_cxx_compiler_flag(flag)) +# add_compile_options(flag) +# +function(eth_add_cxx_compiler_flag_if_supported FLAG) + # Remove leading - or / from the flag name. + string(REGEX REPLACE "^-|/" "" name ${FLAG}) + check_cxx_compiler_flag(${FLAG} ${name}) + if(${name}) + add_compile_options(${FLAG}) + endif() + + # If the optional argument passed, store the result there. + if(ARGV1) + set(${ARGV1} ${name} PARENT_SCOPE) + endif() +endfunction() |