[libxml2] cmake: fix `ATTRIBUTE_DESTRUCTOR` definition



commit f86082359b6b95fc5ed2e2614f641df79040b43f
Author: Ben Boeckel <ben boeckel kitware com>
Date:   Mon Jul 26 20:06:18 2021 -0400

    cmake: fix `ATTRIBUTE_DESTRUCTOR` definition
    
    The code expects it to be set to the attribute for `xmlDestructor`, but
    in CMake, it is only ever available as `1` or undefined. Instead, match
    the behavior or autoconf.

 CMakeLists.txt    | 5 ++++-
 config.h.cmake.in | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 073869fc..e1d2cd32 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -139,7 +139,10 @@ else()
                void __attribute__((destructor))
                f(void) {}
                int main(void) { return 0; }
-       " ATTRIBUTE_DESTRUCTOR)
+       " HAVE_ATTRIBUTE_DESTRUCTOR)
+       if(HAVE_ATTRIBUTE_DESTRUCTOR)
+               set(ATTRIBUTE_DESTRUCTOR "__attribute__((destructor))")
+       endif()
        check_c_source_compiles("
                #include <netdb.h>
                int main() { (void) gethostbyname((const char*) \"\"); return 0; }
diff --git a/config.h.cmake.in b/config.h.cmake.in
index 22b3c920..fa72c46d 100644
--- a/config.h.cmake.in
+++ b/config.h.cmake.in
@@ -2,7 +2,7 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
 /* Define if __attribute__((destructor)) is accepted */
-#cmakedefine ATTRIBUTE_DESTRUCTOR 1
+#cmakedefine ATTRIBUTE_DESTRUCTOR @ATTRIBUTE_DESTRUCTOR@
 
 /* Type cast for the gethostbyname() argument */
 #cmakedefine GETHOSTBYNAME_ARG_CAST @GETHOSTBYNAME_ARG_CAST@


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]