Index: ConfigureChecks.cmake
===================================================================
--- ConfigureChecks.cmake	(revision 508119)
+++ ConfigureChecks.cmake	(working copy)
@@ -77,11 +77,21 @@
 
 #now check for dlfcn.h using the cmake supplied CHECK_include_FILE() macro
 
+# If extra include paths or libraries are needed for these checks they
+# may be added to CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_LIBRARIES
+# here.
 if (WIN32)
    set(CMAKE_REQUIRED_LIBRARIES ${KDEWIN32_LIBRARY} ws2_32)
    set(CMAKE_REQUIRED_INCLUDES  ${KDEWIN32_INCLUDES} )
 endif (WIN32)
 
+# If definitions like -D_GNU_SOURCE are needed for these checks they
+# should be added to _KDE4_PLATFORM_DEFINITIONS when it is originally
+# defined outside this file.  Here we include these definitions in
+# CMAKE_REQUIRED_DEFINITIONS so they will be included in the build of
+# checks below.
+set(CMAKE_REQUIRED_DEFINITIONS ${_KDE4_PLATFORM_DEFINITIONS})
+
 check_include_files(stdio.h HAVE_STDIO_H)
 check_include_files(stdlib.h HAVE_STDLIB_H)
 check_include_files(string.h HAVE_STRING_H)
@@ -201,23 +211,30 @@
 check_function_exists(setgroups       HAVE_SETGROUPS)
 check_function_exists(setlocale       HAVE_SETLOCALE)
 check_function_exists(setlocale       HAVE_SETPRIORITY)
-check_function_exists(snprintf        HAVE_SNPRINTF)
 check_function_exists(socket          HAVE_SOCKET)
 check_function_exists(srandom         HAVE_SRANDOM)
-check_function_exists(stpcpy          HAVE_STPCPY)
-check_function_exists(strcasecmp      HAVE_STRCASECMP)
-check_function_exists(strfmon         HAVE_STRFMON)
-check_function_exists(strrchr         HAVE_STRRCHR)
-check_function_exists(strcmp          HAVE_STRCMP)
-check_function_exists(strchr          HAVE_STRCHR)
-check_function_exists(strtoll         HAVE_STRTOLL)
 check_function_exists(unlockpt        HAVE_UNLOCKPT)
-check_function_exists(vsnprintf       HAVE_VSNPRINTF)
 check_function_exists(_NSGetEnviron   HAVE_NSGETENVIRON)
 check_function_exists(__argz_count    HAVE___ARGZ_COUNT)
 check_function_exists(__argz_next     HAVE___ARGZ_NEXT)
 check_function_exists(__argz_stringify HAVE___ARGZ_STRINGIFY)
 
+# Use check_symbol_exists to check for symbols in a reliable
+# cross-platform manner.  It accounts for different calling
+# conventions and the possibility that the symbol is defined as a
+# macro.  Note that some symbols require multiple includes in a
+# specific order.  Refer to the man page for each symbol for which a
+# check is to be added to get the proper set of headers.
+check_symbol_exists(stpcpy          "string.h"                 HAVE_STPCPY)
+check_symbol_exists(strcasecmp      "strings.h"                HAVE_STRCASECMP)
+check_symbol_exists(strchr          "string.h"                 HAVE_STRCHR)
+check_symbol_exists(strcmp          "string.h"                 HAVE_STRCMP)
+check_symbol_exists(strrchr         "string.h"                 HAVE_STRRCHR)
+check_symbol_exists(strtoll         "stdlib.h"                 HAVE_STRTOLL)
+check_symbol_exists(snprintf        "stdio.h"                  HAVE_SNPRINTF)
+check_symbol_exists(vsnprintf       "stdio.h"                  HAVE_VSNPRINTF)
+check_symbol_exists(strfmon         "monetary.h"               HAVE_STRFMON)
+
 check_library_exists(utempter addToUtmp "" HAVE_UTEMPTER)
 check_library_exists(crypt crypt "" HAVE_CRYPT)
 check_library_exists(volmgt volmgt_running "" HAVE_VOLMGT)
