From 5d6171f4c3a3f87e4e7114131304028b8b54941b Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Sun, 10 Aug 2014 20:30:20 +0300 Subject: KDECompilerSettings: Be more portable across libc's. Defining _XOPEN_SOURCE to 500 is too restrictive: it corresponds to _POSIX_C_SOURCE 199506L, and hides several symbols that standard libraries like libc++ expect to find, leading to errors like this on FreeBSD: In file included from /tmp/attica/src/accountbalance.cpp:21: In file included from /tmp/attica/src/accountbalance.h:25: In file included from /usr/local/include/qt5/QtCore/QString:1: In file included from /usr/local/include/qt5/QtCore/qstring.h:50: In file included from /usr/include/c++/v1/string:437: In file included from /usr/include/c++/v1/string:437: /usr/include/c++/v1/cstdio:143:9: error: no member named 'snprintf' in the global namespace using ::snprintf; ~~^ This isn't a problem on Linux (actually, on systems using glibc) because defining _GNU_SOURCE enables a lot more features that are not made available on other libc implementations where it does not have any effect. Instead, stop defining _XOPEN_SOURCE at all and leave it up to the platform to show or hide as many symbols as necessary if no standards-related defines are set, and only set _GNU_SOURCE on systems where it is actually meaningful (ie. systems using glibc). REVIEW: 119696 --- kde-modules/KDECompilerSettings.cmake | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/kde-modules/KDECompilerSettings.cmake b/kde-modules/KDECompilerSettings.cmake index 138bddb1..f0d1aefe 100644 --- a/kde-modules/KDECompilerSettings.cmake +++ b/kde-modules/KDECompilerSettings.cmake @@ -102,13 +102,9 @@ macro (_KDE_ADD_PLATFORM_DEFINITIONS) set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${ARGV}) endmacro() -if (UNIX) - # Enable basically everything portable across modern UNIX systems. - # See http://www.delorie.com/gnu/docs/glibc/libc_13.html, although - # this define is for the benefit of other libc implementations - # (since _GNU_SOURCE is defined below). - _kde_add_platform_definitions(-D_XOPEN_SOURCE=500) - +include(CheckSymbolExists) +check_symbol_exists("__GLIBC__" "stdlib.h" LIBC_IS_GLIBC) +if (LIBC_IS_GLIBC) # Enable everything in GNU libc. Any code using non-portable features # needs to perform feature tests, but this ensures that any such features # will be found if they exist. @@ -118,7 +114,9 @@ if (UNIX) # functions). This, however, means that strlcat and strlcpy are not # provided by glibc. _kde_add_platform_definitions(-D_GNU_SOURCE) +endif () +if (UNIX) # Enable extra API for using 64-bit file offsets on 32-bit systems. # FIXME: this is included in _GNU_SOURCE in glibc; do other libc # implementation recognize it? -- cgit v1.2.1