From 4c058aefd9fb8a6dc9e8a2dd0c2a3cf7256b61fc Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 13 Aug 2018 09:21:17 +0200 Subject: [PATCH] cmake: Detect constructor and destructor attributes Signed-off-by: Andreas Schneider --- ConfigureChecks.cmake | 24 ++++++++++++++++++++++++ config.h.cmake | 3 +++ 2 files changed, 27 insertions(+) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 0c4beb72..4f4bcee2 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -272,6 +272,30 @@ int main(void) { # errors set(CMAKE_REQUIRED_FLAGS "-Werror") +check_c_source_compiles(" +void test_constructor_attribute(void) __attribute__ ((constructor)); + +void test_constructor_attribute(void) +{ + return; +} + +int main(void) { + return 0; +}" HAVE_CONSTRUCTOR_ATTRIBUTE) + +check_c_source_compiles(" +void test_destructor_attribute(void) __attribute__ ((destructor)); + +void test_destructor_attribute(void) +{ + return; +} + +int main(void) { + return 0; +}" HAVE_DESTRUCTOR_ATTRIBUTE) + check_c_source_compiles(" #define FALL_THROUGH __attribute__((fallthrough)) diff --git a/config.h.cmake b/config.h.cmake index 421f527d..edf5be21 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -193,6 +193,9 @@ #cmakedefine HAVE_FALLTHROUGH_ATTRIBUTE 1 +#cmakedefine HAVE_CONSTRUCTOR_ATTRIBUTE 1 +#cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1 + #cmakedefine HAVE_GCC_VOLATILE_MEMORY_PROTECTION 1 #cmakedefine HAVE_GCC_NARG_MACRO 1