diff options
author | Raphael Kubo da Costa <rakuco@FreeBSD.org> | 2014-08-10 20:30:20 +0300 |
---|---|---|
committer | Raphael Kubo da Costa <rakuco@FreeBSD.org> | 2014-08-13 01:12:11 +0300 |
commit | 5d6171f4c3a3f87e4e7114131304028b8b54941b (patch) | |
tree | 042de89bd4e2756bda6885d9e522ef5a830cfb46 /kde-modules | |
parent | 8cf3d0ae17b84adb484c4a32e4475a45fa51848a (diff) | |
download | extra-cmake-modules-5d6171f4c3a3f87e4e7114131304028b8b54941b.tar.gz extra-cmake-modules-5d6171f4c3a3f87e4e7114131304028b8b54941b.tar.bz2 |
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
Diffstat (limited to 'kde-modules')
-rw-r--r-- | kde-modules/KDECompilerSettings.cmake | 12 |
1 files 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? |