changeset 1418:a51f71694121

fix build with MySQL >= 8.0 MySQL 8.0 deprecated my_bool in favour of C99's bool. Detect if my_bool is available, and if not, provide a replacement.
author Luke Mewburn <luke@mewburn.net>
date Tue, 18 Feb 2020 20:58:20 +1100
parents 0918e88f7c33
children 89cbb08d3189
files extensions/app_diameap/CMakeLists.txt extensions/app_diameap/diameap_init.c
diffstat 2 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/app_diameap/CMakeLists.txt	Tue Feb 18 19:12:16 2020 +1100
+++ b/extensions/app_diameap/CMakeLists.txt	Tue Feb 18 20:58:20 2020 +1100
@@ -1,11 +1,26 @@
 # The Diameter EAP Application extension
 PROJECT("Diameter EAP Application extension" C)
 
+INCLUDE (CheckCSourceCompiles)
+
 # Find MySQL 
 FIND_PACKAGE(MySQL REQUIRED)
 FIND_PACKAGE(Gcrypt REQUIRED)
 INCLUDE_DIRECTORIES(${MySQL_INCLUDE_DIR})
 
+# Check for my_bool, deprecated in MySQL 8.0
+SET(CHECK_MYSQL_MY_BOOL "
+#include <mysql.h>
+int main() {
+my_bool f;
+}")
+SET(CMAKE_REQUIRED_INCLUDES ${MySQL_INCLUDE_DIR})
+SET(CMAKE_REQUIRED_LIBRARIES ${MySQL_LIBRARY})
+CHECK_C_SOURCE_COMPILES("${CHECK_MYSQL_MY_BOOL}" HAVE_MYSQL_MY_BOOL)
+IF (HAVE_MYSQL_MY_BOOL)
+  ADD_DEFINITIONS(-DHAVE_MYSQL_MY_BOOL)
+ENDIF()
+
 # Parse plugins
 ADD_SUBDIRECTORY(plugins)
 
--- a/extensions/app_diameap/diameap_init.c	Tue Feb 18 19:12:16 2020 +1100
+++ b/extensions/app_diameap/diameap_init.c	Tue Feb 18 20:58:20 2020 +1100
@@ -38,6 +38,11 @@
 
 #include "diameap_common.h"
 
+#ifndef HAVE_MYSQL_MY_BOOL
+#include <stdbool.h>
+typedef bool my_bool;
+#endif /* HAVE_MYSQL_MY_BOOL */
+
 /* Dictionary Object templates */
 struct dict_object * dataobj_diameap_cmd = NULL; /* Diameter-EAP-Request Command Code */
 struct dict_object * dataobj_diameap_app = NULL; /* Diameter EAP Application object */
"Welcome to our mercurial repository"