Commit 8566bcf1 authored by Andreas Schuh's avatar Andreas Schuh

Replace GFLAGS_HAVE_* #defines by HAVE_* again.

parent 6e9f4166
......@@ -75,6 +75,28 @@ include (CheckTypeSize)
include (CheckIncludeFileCXX)
include (CheckCXXSymbolExists)
if (MSVC)
set (HAVE_SYS_TYPES_H 1)
set (HAVE_STDINT_H 1)
set (HAVE_STDDEF_H 1) # used by CheckTypeSize module
set (HAVE_INTTYPES_H 0)
set (HAVE_UNISTD_H 0)
set (HAVE_SYS_STAT_H 1)
check_include_file_cxx ("shlwapi.h" HAVE_SHLWAPI_H)
else ()
foreach (fname IN ITEMS unistd stdint inttypes sys/types sys/stat fnmatch)
string (TOUPPER "${fname}" FNAME)
string (REGEX REPLACE "/" "_" FNAME "${FNAME}")
if (NOT HAVE_${FNAME}_H)
check_include_file_cxx ("${fname}.h" HAVE_${FNAME}_H)
endif ()
endforeach ()
# the following are used in #if not #ifdef
bool_to_int (HAVE_STDINT_H)
bool_to_int (HAVE_SYS_TYPES_H)
bool_to_int (HAVE_INTTYPES_H)
endif ()
set (GFLAGS_INTTYPES_FORMAT "" CACHE STRING "Format of integer types: \"C99\" (uint32_t), \"BSD\" (u_int32_t), \"VC7\" (__int32)")
set_property (CACHE GFLAGS_INTTYPES_FORMAT PROPERTY STRINGS "C99;BSD;VC7")
mark_as_advanced (GFLAGS_INTTYPES_FORMAT)
......@@ -114,56 +136,34 @@ set (GFLAGS_INTTYPES_FORMAT_BSD 0)
set (GFLAGS_INTTYPES_FORMAT_VC7 0)
set ("GFLAGS_INTTYPES_FORMAT_${GFLAGS_INTTYPES_FORMAT}" 1)
foreach (fname IN ITEMS stdint sys/types fnmatch inttypes unistd sys/stat)
string (TOUPPER "${fname}" FNAME)
string (REGEX REPLACE "/" "_" FNAME "${FNAME}")
if (HAVE_${FNAME}_H)
# set by check_type_size already
set (GFLAGS_HAVE_${FNAME}_H ${HAVE_${FNAME}_H})
else ()
check_include_file_cxx ("${fname}.h" GFLAGS_HAVE_${FNAME}_H)
endif ()
endforeach ()
if (NOT GFLAGS_HAVE_FNMATCH_H AND WINDOWS)
check_include_file_cxx ("shlwapi.h" GFLAGS_HAVE_SHLWAPI_H)
endif ()
bool_to_int(GFLAGS_HAVE_STDINT_H)
bool_to_int(GFLAGS_HAVE_SYS_TYPES_H)
bool_to_int(GFLAGS_HAVE_INTTYPES_H)
if (MSVC)
set (GFLAGS_HAVE_strtoll FALSE)
set (GFLAGS_HAVE_strtoq FALSE)
set (HAVE_strtoll 0)
set (HAVE_strtoq 0)
else ()
foreach (fname IN ITEMS strtoll strtoq)
string (TOUPPER "${fname}" FNAME)
check_cxx_symbol_exists ("${fname}" stdlib.h GFLAGS_HAVE_${FNAME})
check_cxx_symbol_exists ("${fname}" stdlib.h HAVE_${FNAME})
endforeach ()
endif ()
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package (ThreadsCXX)
if (Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
set (GFLAGS_HAVE_PTHREAD TRUE)
set (HAVE_PTHREAD 1)
check_type_size (pthread_rwlock_t RWLOCK LANGUAGE CXX)
if (HAVE_RWLOCK)
set (GFLAGS_HAVE_RWLOCK TRUE)
else ()
set (GFLAGS_HAVE_RWLOCK FALSE)
endif ()
else ()
set (GFLAGS_HAVE_PTHREAD FALSE)
set (HAVE_PTHREAD 0)
endif ()
if (UNIX AND NOT GFLAGS_HAVE_PTHREAD AND BUILD_gflags_LIB)
set_property (CACHE BUILD_gflags_LIB PROPERTY VALUE OFF)
if (UNIX AND NOT HAVE_PTHREAD AND BUILD_gflags_LIB)
if (CMAKE_HAVE_PTHREAD_H)
message (WARNING "Could not find the pthread(s) library."
" Disabling the build of the multi-threaded gflags library.")
set (what "library")
else ()
message (WARNING "Could not find the <pthread.h> header file."
" Disabling the build of the multi-threaded gflags library.")
set (what ".h file")
endif ()
message (FATAL_ERROR "Could not find pthread${what}. Check the log file"
"\n\t${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
"\nor disable the build of the multi-threaded gflags library (BUILD_gflags_LIB=OFF).")
endif ()
# ----------------------------------------------------------------------------
......@@ -226,7 +226,7 @@ endif ()
# ----------------------------------------------------------------------------
# installation
if (WIN32)
if (WINDOWS)
set (RUNTIME_INSTALL_DIR Bin)
set (LIBRARY_INSTALL_DIR Lib)
set (INCLUDE_INSTALL_DIR Include)
......
......@@ -9,74 +9,40 @@
// 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
......@@ -139,9 +105,3 @@
# 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
......@@ -93,9 +93,9 @@
#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
......@@ -1307,10 +1307,10 @@ string CommandLineFlagParser::ProcessOptionsFromStringLocked(
// 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
......
......@@ -79,11 +79,11 @@
// ---------------------------------------------------------------------------
// 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
......
......@@ -127,7 +127,7 @@
# 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
......@@ -140,7 +140,7 @@
# 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
......@@ -247,7 +247,7 @@ bool Mutex::TryLock() { return is_safe_ ?
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(); \
......@@ -272,7 +272,7 @@ void Mutex::ReaderLock() { SAFE_PTHREAD(pthread_rwlock_rdlock); }
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(); \
......
......@@ -38,7 +38,7 @@
#include <assert.h>
#include <config.h>
#ifdef GFLAGS_HAVE_INTTYPES_H
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <stdarg.h> // for va_*
......@@ -47,7 +47,7 @@
#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
......@@ -59,10 +59,10 @@ namespace GFLAGS_NAMESPACE {
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__)
......
......@@ -39,7 +39,7 @@
#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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment