From 6b65aed4433347f13c849f19bbdd2e75bad99cb3 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 11 Aug 2022 16:15:30 +0200 Subject: [PATCH] Fix getdnsapi/stubby#295 set default build type to RelWithDebInfo And expose CFLAGS through GETDNS_BUILD_CFLAGS define and via getdns_context_get_api_information() --- CMakeLists.txt | 6 ++++-- src/context.c | 3 +++ src/getdns/getdns_extra.h.in | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fde37c72..869633ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,8 @@ endif () # The following must be set BEFORE doing project() or enable_language(). if (NOT CMAKE_BUILD_TYPE) - message(STATUS "No build type defined; defaulting to 'Debug'") - set(CMAKE_BUILD_TYPE "Debug" CACHE STRING + message(STATUS "No build type defined; defaulting to 'RelWithDebInfo'") + set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "The type of build. Possible values are: Debug, Release, RelWithDebInfo and MinSizeRel.") endif () @@ -1026,6 +1026,8 @@ if (BUILD_TESTING) endif () # Substitutions in files. +string(TOUPPER "${CMAKE_BUILD_TYPE}" GETDNS_BUILD_RELTYPE) +string(REPLACE "\"" "\\\"" GETDNS_BUILD_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${GETDNS_BUILD_RELTYPE}}") configure_file(cmake/include/cmakeconfig.h.in config.h) configure_file(src/getdns/getdns.h.in getdns/getdns.h) configure_file(src/getdns/getdns_extra.h.in getdns/getdns_extra.h) diff --git a/src/context.c b/src/context.c index 7937a1f2..8c04bb26 100644 --- a/src/context.c +++ b/src/context.c @@ -4096,6 +4096,9 @@ getdns_context_get_api_information(const getdns_context* context) && ! getdns_dict_util_set_string( result, "compilation_comment", GETDNS_COMPILATION_COMMENT) + && ! getdns_dict_util_set_string( + result, "build_cflags", GETDNS_BUILD_CFLAGS) + && ! getdns_dict_util_set_string( result, "default_trust_anchor_location", TRUST_ANCHOR_FILE) diff --git a/src/getdns/getdns_extra.h.in b/src/getdns/getdns_extra.h.in index c4fcf561..223b1de4 100644 --- a/src/getdns/getdns_extra.h.in +++ b/src/getdns/getdns_extra.h.in @@ -128,6 +128,7 @@ extern "C" { #define GETDNS_NUMERIC_VERSION @GETDNS_NUMERIC_VERSION@ #define GETDNS_API_VERSION "@API_VERSION@" #define GETDNS_API_NUMERIC_VERSION @API_NUMERIC_VERSION@ +#define GETDNS_BUILD_CFLAGS "@GETDNS_BUILD_CFLAGS@" /** @} */