include (CheckIncludeFileCXX)\r
include (CheckCXXSymbolExists)\r
\r
+if (MSVC)\r
+ set (HAVE_SYS_TYPES_H 1)\r
+ set (HAVE_STDINT_H 1)\r
+ set (HAVE_STDDEF_H 1) # used by CheckTypeSize module\r
+ set (HAVE_INTTYPES_H 0)\r
+ set (HAVE_UNISTD_H 0)\r
+ set (HAVE_SYS_STAT_H 1)\r
+ check_include_file_cxx ("shlwapi.h" HAVE_SHLWAPI_H)\r
+else ()\r
+ foreach (fname IN ITEMS unistd stdint inttypes sys/types sys/stat fnmatch)\r
+ string (TOUPPER "${fname}" FNAME)\r
+ string (REGEX REPLACE "/" "_" FNAME "${FNAME}")\r
+ if (NOT HAVE_${FNAME}_H)\r
+ check_include_file_cxx ("${fname}.h" HAVE_${FNAME}_H)\r
+ endif ()\r
+ endforeach ()\r
+ # the following are used in #if not #ifdef\r
+ bool_to_int (HAVE_STDINT_H)\r
+ bool_to_int (HAVE_SYS_TYPES_H)\r
+ bool_to_int (HAVE_INTTYPES_H)\r
+endif ()\r
+\r
set (GFLAGS_INTTYPES_FORMAT "" CACHE STRING "Format of integer types: \"C99\" (uint32_t), \"BSD\" (u_int32_t), \"VC7\" (__int32)")\r
set_property (CACHE GFLAGS_INTTYPES_FORMAT PROPERTY STRINGS "C99;BSD;VC7")\r
mark_as_advanced (GFLAGS_INTTYPES_FORMAT)\r
set (GFLAGS_INTTYPES_FORMAT_VC7 0)\r
set ("GFLAGS_INTTYPES_FORMAT_${GFLAGS_INTTYPES_FORMAT}" 1)\r
\r
-foreach (fname IN ITEMS stdint sys/types fnmatch inttypes unistd sys/stat)\r
- string (TOUPPER "${fname}" FNAME)\r
- string (REGEX REPLACE "/" "_" FNAME "${FNAME}")\r
- if (HAVE_${FNAME}_H)\r
- # set by check_type_size already\r
- set (GFLAGS_HAVE_${FNAME}_H ${HAVE_${FNAME}_H})\r
- else ()\r
- check_include_file_cxx ("${fname}.h" GFLAGS_HAVE_${FNAME}_H)\r
- endif ()\r
-endforeach ()\r
-if (NOT GFLAGS_HAVE_FNMATCH_H AND WINDOWS)\r
- check_include_file_cxx ("shlwapi.h" GFLAGS_HAVE_SHLWAPI_H)\r
-endif ()\r
-bool_to_int(GFLAGS_HAVE_STDINT_H)\r
-bool_to_int(GFLAGS_HAVE_SYS_TYPES_H)\r
-bool_to_int(GFLAGS_HAVE_INTTYPES_H)\r
-\r
if (MSVC)\r
- set (GFLAGS_HAVE_strtoll FALSE)\r
- set (GFLAGS_HAVE_strtoq FALSE)\r
+ set (HAVE_strtoll 0)\r
+ set (HAVE_strtoq 0)\r
else ()\r
foreach (fname IN ITEMS strtoll strtoq)\r
string (TOUPPER "${fname}" FNAME)\r
- check_cxx_symbol_exists ("${fname}" stdlib.h GFLAGS_HAVE_${FNAME})\r
+ check_cxx_symbol_exists ("${fname}" stdlib.h HAVE_${FNAME})\r
endforeach ()\r
endif ()\r
\r
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)\r
find_package (ThreadsCXX)\r
if (Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)\r
- set (GFLAGS_HAVE_PTHREAD TRUE)\r
+ set (HAVE_PTHREAD 1)\r
check_type_size (pthread_rwlock_t RWLOCK LANGUAGE CXX)\r
- if (HAVE_RWLOCK)\r
- set (GFLAGS_HAVE_RWLOCK TRUE)\r
- else ()\r
- set (GFLAGS_HAVE_RWLOCK FALSE)\r
- endif ()\r
else ()\r
- set (GFLAGS_HAVE_PTHREAD FALSE)\r
+ set (HAVE_PTHREAD 0)\r
endif ()\r
\r
-if (UNIX AND NOT GFLAGS_HAVE_PTHREAD AND BUILD_gflags_LIB)\r
- set_property (CACHE BUILD_gflags_LIB PROPERTY VALUE OFF)\r
+if (UNIX AND NOT HAVE_PTHREAD AND BUILD_gflags_LIB)\r
if (CMAKE_HAVE_PTHREAD_H)\r
- message (WARNING "Could not find the pthread(s) library."\r
- " Disabling the build of the multi-threaded gflags library.")\r
+ set (what "library")\r
else ()\r
- message (WARNING "Could not find the <pthread.h> header file."\r
- " Disabling the build of the multi-threaded gflags library.")\r
+ set (what ".h file")\r
endif ()\r
+ message (FATAL_ERROR "Could not find pthread${what}. Check the log file"\r
+ "\n\t${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"\r
+ "\nor disable the build of the multi-threaded gflags library (BUILD_gflags_LIB=OFF).")\r
endif ()\r
\r
# ----------------------------------------------------------------------------\r
\r
# ----------------------------------------------------------------------------\r
# installation\r
-if (WIN32)\r
+if (WINDOWS)\r
set (RUNTIME_INSTALL_DIR Bin)\r
set (LIBRARY_INSTALL_DIR Lib)\r
set (INCLUDE_INSTALL_DIR Include)\r
// System checks
// Define if you have the <stdint.h> header file.
-#cmakedefine GFLAGS_HAVE_STDINT_H
+#cmakedefine HAVE_STDINT_H
// Define if you have the <sys/types.h> header file.
-#cmakedefine GFLAGS_HAVE_SYS_TYPES_H
+#cmakedefine HAVE_SYS_TYPES_H
// Define if you have the <inttypes.h> header file.
-#cmakedefine GFLAGS_HAVE_INTTYPES_H
+#cmakedefine HAVE_INTTYPES_H
// Define if you have the <sys/stat.h> header file.
-#cmakedefine GFLAGS_HAVE_SYS_STAT_H
+#cmakedefine HAVE_SYS_STAT_H
// Define if you have the <unistd.h> header file.
-#cmakedefine GFLAGS_HAVE_UNISTD_H
+#cmakedefine HAVE_UNISTD_H
// Define if you have the <fnmatch.h> header file.
-#cmakedefine GFLAGS_HAVE_FNMATCH_H
+#cmakedefine HAVE_FNMATCH_H
// Define if you have the <shlwapi.h> header file (Windows 2000/XP).
-#cmakedefine GFLAGS_HAVE_SHLWAPI_H
+#cmakedefine HAVE_SHLWAPI_H
// Define if you have the strtoll function.
-#cmakedefine GFLAGS_HAVE_STRTOLL
+#cmakedefine HAVE_STRTOLL
// Define if you have the strtoq function.
-#cmakedefine GFLAGS_HAVE_STRTOQ
+#cmakedefine HAVE_STRTOQ
// Define if you have the <pthread.h> header file.
-#cmakedefine GFLAGS_HAVE_PTHREAD
+#cmakedefine HAVE_PTHREAD
// Define if your pthread library defines the type pthread_rwlock_t
-#cmakedefine GFLAGS_HAVE_RWLOCK
-
-// Backwards compatibility in case users defined these macros themselves
-// or allow users to use these more general macros if the gflags library
-// is build as part of a user project, e.g., included as Git submodule
-#if defined(HAVE_STDINT_H) && !defined(GFLAGS_HAVE_STDINT_H)
-# define GFLAGS_HAVE_STDINT_H
-#endif
-#if defined(HAVE_SYS_TYPES_H) && !defined(GFLAGS_HAVE_SYS_TYPES_H)
-# define GFLAGS_HAVE_SYS_TYPES_H
-#endif
-#if defined(HAVE_INTTYPES_H) && !defined(GFLAGS_HAVE_INTTYPES_H)
-# define GFLAGS_HAVE_INTTYPES_H
-#endif
-#if defined(HAVE_SYS_STAT_H) && !defined(GFLAGS_HAVE_SYS_STAT_H)
-# define GFLAGS_HAVE_SYS_STAT_H
-#endif
-#if defined(HAVE_UNISTD_H) && !defined(GFLAGS_HAVE_UNISTD_H)
-# define GFLAGS_HAVE_UNISTD_H
-#endif
-#if defined(HAVE_FNMATCH_H) && !defined(GFLAGS_HAVE_FNMATCH_H)
-# define GFLAGS_HAVE_FNMATCH_H
-#endif
-#if defined(HAVE_STRTOLL) && !defined(GFLAGS_HAVE_STRTOLL)
-# define GFLAGS_HAVE_STRTOLL
-#endif
-#if defined(HAVE_STRTOLQ) && !defined(GFLAGS_HAVE_STRTOLQ)
-# define GFLAGS_HAVE_STRTOLQ
-#endif
-#if defined(HAVE_PTHREAD) && !defined(GFLAGS_HAVE_PTHREAD)
-# define GFLAGS_HAVE_PTHREAD
-#endif
-#if defined(HAVE_RWLOCK) && !defined(GFLAGS_HAVE_RWLOCK)
-# define GFLAGS_HAVE_RWLOCK
-#endif
+#cmakedefine HAVE_RWLOCK
// gcc requires this to get PRId64, etc.
-#if defined(GFLAGS_HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS)
+#if defined(HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS)
# define __STDC_FORMAT_MACROS 1
#endif
# endif
# include "windows_port.h"
#endif
-
-// Export of STL class instantiations -- no extern keyword to not trigger a warning
-// \sa http://support.microsoft.com/default.aspx?scid=KB;EN-US;168958
-#if GFLAGS_IS_A_DLL && defined(_MSC_VER) && _MSC_VER >= 1100
-# define GFLAGS_EXTERN_STL
-#endif
\ No newline at end of file
#include <assert.h>
#include <ctype.h>
#include <errno.h>
-#if defined(GFLAGS_HAVE_FNMATCH_H)
+#if defined(HAVE_FNMATCH_H)
# include <fnmatch.h>
-#elif defined(GFLAGS_HAVE_SHLWAPI_H)
+#elif defined(_MSC_VER) && defined(HAVE_SHLWAPI_H)
# include <shlwapi.h>
# pragma comment(lib, "shlwapi.lib")
#endif
// We try matching both against the full argv0 and basename(argv0)
if (glob == ProgramInvocationName() // small optimization
|| glob == ProgramInvocationShortName()
-#if defined(GFLAGS_HAVE_FNMATCH_H)
+#if defined(HAVE_FNMATCH_H)
|| fnmatch(glob.c_str(), ProgramInvocationName(), FNM_PATHNAME) == 0
|| fnmatch(glob.c_str(), ProgramInvocationShortName(), FNM_PATHNAME) == 0
-#elif defined(GFLAGS_HAVE_SHLWAPI_H)
+#elif defined(_MSC_VER) && defined(HAVE_SHLWAPI_H)
|| PathMatchSpec(glob.c_str(), ProgramInvocationName())
|| PathMatchSpec(glob.c_str(), ProgramInvocationShortName())
#endif
// ---------------------------------------------------------------------------
// Flag types
#include <string>
-#if @GFLAGS_HAVE_STDINT_H@
+#if @HAVE_STDINT_H@
# include <stdint.h> // the normal place uint32_t is defined
-#elif @GFLAGS_HAVE_SYS_TYPES_H@
+#elif @HAVE_SYS_TYPES_H@
# include <sys/types.h> // the normal place u_int32_t is defined
-#elif @GFLAGS_HAVE_INTTYPES_H@
+#elif @HAVE_INTTYPES_H@
# include <inttypes.h> // a third place for uint32_t or u_int32_t
#endif
# endif
# include <windows.h>
typedef CRITICAL_SECTION MutexType;
-#elif defined(GFLAGS_HAVE_PTHREAD) && defined(GFLAGS_HAVE_RWLOCK)
+#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
// Needed for pthread_rwlock_*. If it causes problems, you could take it
// out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it
// *does* cause problems for FreeBSD, or MacOSX, but isn't needed
# endif
# include <pthread.h>
typedef pthread_rwlock_t MutexType;
-#elif defined(GFLAGS_HAVE_PTHREAD)
+#elif defined(HAVE_PTHREAD)
# include <pthread.h>
typedef pthread_mutex_t MutexType;
#else
void Mutex::ReaderLock() { Lock(); } // we don't have read-write locks
void Mutex::ReaderUnlock() { Unlock(); }
-#elif defined(GFLAGS_HAVE_PTHREAD) && defined(GFLAGS_HAVE_RWLOCK)
+#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \
if (is_safe_ && fncall(&mutex_) != 0) abort(); \
void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
#undef SAFE_PTHREAD
-#elif defined(GFLAGS_HAVE_PTHREAD)
+#elif defined(HAVE_PTHREAD)
#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \
if (is_safe_ && fncall(&mutex_) != 0) abort(); \
#include <assert.h>
#include <config.h>
-#ifdef GFLAGS_HAVE_INTTYPES_H
+#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <stdarg.h> // for va_*
#include <iostream>
#include <string>
#include <errno.h>
-#ifdef GFLAGS_HAVE_SYS_STAT_H
+#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h> // for mkdir
#endif
extern GFLAGS_DLL_DECL void (*gflags_exitfunc)(int);
// Work properly if either strtoll or strtoq is on this system
-#if defined(GFLAGS_HAVE_STRTOLL)
+#if defined(HAVE_STRTOLL)
# define strto64 strtoll
# define strtou64 strtoull
-#elif defined(GFLAGS_HAVE_STRTOQ)
+#elif defined(HAVE_STRTOQ)
# define strto64 strtoq
# define strtou64 strtouq
#elif defined(_WIN32) && !defined(__MINGW32__) && !defined(__MINGW64__)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifdef GFLAGS_HAVE_UNISTD_H
+#ifdef HAVE_UNISTD_H
# include <unistd.h> // for unlink()
#endif
#include <vector>