diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-08-13 09:15:35 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-08-13 09:15:35 +0200 |
commit | 8c2ad7bdd34c6a0b5d920528b2061fb90ab12316 (patch) | |
tree | 9d9a31b877843f23a4896dd3e012d7be6b34dc81 /ConfigureChecks.cmake | |
parent | e04a8b3abd87fd31eab550831c030000b87f83b4 (diff) | |
download | libssh-8c2ad7bdd34c6a0b5d920528b2061fb90ab12316.tar.gz libssh-8c2ad7bdd34c6a0b5d920528b2061fb90ab12316.tar.xz libssh-8c2ad7bdd34c6a0b5d920528b2061fb90ab12316.zip |
cmake: Fix fallthrough attribute detection
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'ConfigureChecks.cmake')
-rw-r--r-- | ConfigureChecks.cmake | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index d1c4d2ca..0c4beb72 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -267,25 +267,21 @@ int main(void) { return 0; }" HAVE_MSC_THREAD_LOCAL_STORAGE) +########################################################### +# For detecting attributes we need to treat warnings as +# errors +set(CMAKE_REQUIRED_FLAGS "-Werror") + check_c_source_compiles(" #define FALL_THROUGH __attribute__((fallthrough)) -enum direction_e { - UP = 0, - DOWN, -}; - int main(void) { - enum direction_e key = UP; - int i = 10; - int j = 0; + int i = 2; - switch (key) { - case UP: - i = 5; + switch (i) { + case 0: FALL_THROUGH; - case DOWN: - j = i * 2; + case 1: break; default: break; @@ -332,6 +328,8 @@ int main(void) { return 0; }" HAVE_COMPILER__FUNCTION__) +# Stop treating warnings as errors +unset(CMAKE_REQUIRED_FLAGS) check_c_source_compiles(" #define ARRAY_LEN 16 |