From f8a9a21428357a322473497e24dda849c603fe5f Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 16 Mar 2016 14:25:58 +0100 Subject: [PATCH] cmake: add _U_ and NGHTTP2_NORETURN to config.h Do not add _U_ and NGHTTP2_NORETURN definitions to the command line, instead add it to config.h. This matches what autotools does. --- CMakeLists.txt | 9 ++++----- cmakeconfig.h.in | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f56d7ce..83692e9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,12 +118,11 @@ endforeach() # XXX - similar hints for other compilers? # if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") - add_definitions( - "-D_U_=__attribute__((unused))" - "-DNGHTTP2_NORETURN=__attribute__((noreturn))" - ) + set(HINT_UNUSED_PARAM "__attribute__((unused))") + set(HINT_NORETURN "__attribute__((noreturn))") else() - add_definitions(-D_U_ -DNGHTTP2_NORETURN) + set(HINT_UNUSED_PARAM) + set(HINT_NORETURN) endif() include(ExtractValidFlags) diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index d7db50f3..3e39463d 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -1,4 +1,10 @@ +/* Hint to the compiler that a function parameter is not used */ +#define _U_ @HINT_UNUSED_PARAM@ + +/* Hint to the compiler that a function never returns */ +#define NGHTTP2_NORETURN @HINT_NORETURN@ + /* Define to 1 if you have the `std::map::emplace`. */ #cmakedefine HAVE_STD_MAP_EMPLACE 1