From ec4abaea25a6e96ee09e5df7f460755266410af2 Mon Sep 17 00:00:00 2001 From: Mathieu Faverge <mathieu.faverge@inria.fr> Date: Mon, 11 Oct 2021 19:37:01 +0200 Subject: [PATCH] cmake: check for fallthrough attribute --- CMakeLists.txt | 21 ++++++++++++++++++++- include/chameleon/config.h.in | 7 +++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b7a6af28..2c515d7e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -503,13 +503,32 @@ else (NOT CHAMELEON_SIMULATION) endif(NOT CHAMELEON_SIMULATION) -# getopt +# Check for getopt +# ---------------- unset(CMAKE_REQUIRED_LIBRARIES) check_include_files(getopt.h CHAMELEON_HAVE_GETOPT_H) if (CHAMELEON_HAVE_GETOPT_H) check_function_exists(getopt_long CHAMELEON_HAVE_GETOPT_LONG) endif() +# Check for attribute fallthrough +# ------------------------------- +check_c_source_compiles(" +#include <stdarg.h> +int main(void) { + int a = 2; + switch( a ){ + case 0: + __attribute__((fallthrough)); + default: + ; + } + return 0; +} +" + HAVE_FALLTHROUGH + ) + # Add option to exploit cublas API v2 # ----------------------------------- cmake_dependent_option(CHAMELEON_USE_CUBLAS_V2 diff --git a/include/chameleon/config.h.in b/include/chameleon/config.h.in index dc878d47b..2b7e3e4bc 100644 --- a/include/chameleon/config.h.in +++ b/include/chameleon/config.h.in @@ -70,6 +70,13 @@ /* chameleon runtime starpu */ #cmakedefine CHAMELEON_ENABLE_PRUNING_STATS +#cmakedefine HAVE_FALLTHROUGH +#if defined(HAVE_FALLTHROUGH) +#define chameleon_attr_fallthrough __attribute__((fallthrough)) +#else +#define chameleon_attr_fallthrough do {} while(0) +#endif + #ifdef BEGIN_C_DECLS #undef BEGIN_C_DECLS #endif -- GitLab