How to test for gnu extensions

David Faure faure at kde.org
Thu Feb 9 21:25:32 CET 2006


Currently kdelibs fails to compile for me with cmake because S_ISSOCK isn't detected
(so the config.h defines it, and it clashes with the one from sys/stat.h during compilation).
Anyway - the reason is that _GNU_SOURCE isn't defined, so sys/stat.h doesn't define S_ISSOCK.

I tried porting the check from acinclude.m4.in to define _GNU_SOURCE, which gives something like:

--- ConfigureChecks.cmake       (revision 507577)
+++ ConfigureChecks.cmake       (working copy)
@@ -5,6 +5,7 @@ include(CheckFunctionExists)
 include(CheckLibraryExists)
 include(CheckPrototypeExists)
 include(CheckTypeSize)
+include(CheckCSourceCompiles)

 #check for libz using the cmake supplied FindZLIB.cmake
 if(ZLIB_FOUND)
@@ -148,6 +149,13 @@ check_include_files( "X11/Xlib.h;X11/ext
 check_include_files( X11/ICE/ICElib.h       HAVE_X11_ICE_ICELIB_H)
 check_include_files( X11/extensions/Xrender.h HAVE_XRENDER)

+# Check if we need GNU extensions. E.g. for S_ISSOCK etc.
+CheckCSourceCompiles("
+#include <features.h>
+#ifndef __GNU_LIBRARY__
+#error no gnu here
+#endif
+" _GNU_SOURCE)

 #check_symbol_exists(sockaddr_in6 "netinet/in.h" HAVE_STRUCT_SOCKADDR_IN6)
 check_symbol_exists(LC_MESSAGES "locale.h" HAVE_LC_MESSAGES)


But this gives me:

CMake Error: Error in cmake code at
/devel/kde/src/4/kdelibs/ConfigureChecks.cmake:153:
Unknown CMake command "CheckCSourceCompiles".

(BTW, is the multi-line string for the source code OK?)

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).



More information about the Kde-buildsystem mailing list