Commit fe136448 authored by Fumitoshi Ukai's avatar Fumitoshi Ukai

Merge pull request #7 from sergiud/master

Add CMake support. closes #4 
parents 454906f4 8453b085
This diff is collapsed.
macro(determine_gflags_namespace VARIABLE)
if (NOT DEFINED "${VARIABLE}")
if (CMAKE_REQUIRED_INCLUDES)
set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
else ()
set (CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS)
endif ()
set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(_NAMESPACES gflags google)
set(_check_code
"
#include <gflags/gflags.h>
int main(int argc, char**argv)
{
GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
}
")
if (NOT CMAKE_REQUIRED_QUIET)
message (STATUS "Looking for gflags namespace")
endif ()
if (${ARGC} EQUAL 3)
set (CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}")
endif ()
set (_check_file
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/DetermineGflagsNamespace.cxx)
foreach (_namespace ${_NAMESPACES})
file (WRITE "${_check_file}" "${_check_code}")
try_compile (${VARIABLE}
"${CMAKE_BINARY_DIR}" "${_check_file}"
COMPILE_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}" -DGFLAGS_NAMESPACE=${_namespace}
LINK_LIBRARIES "${gflags_LIBRARIES}"
CMAKE_FLAGS -DINCLUDE_DIRECTORIES:STRING="${gflags_INCLUDE_DIR}"
OUTPUT_VARIABLE OUTPUT)
if (${VARIABLE})
set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace" FORCE)
break ()
else ()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining the gflags namespace ${_namespace} failed with the following output:\n"
"${OUTPUT}\n\n")
endif ()
endforeach (_namespace)
if (${ARGC} EQUAL 3)
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE})
endif ()
if (${VARIABLE})
if (NOT CMAKE_REQUIRED_QUIET)
message (STATUS "Looking for gflags namespace - ${${VARIABLE}}")
endif ()
file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining the gflags namespace passed with the following output:\n"
"${OUTPUT}\n\n")
else ()
if (NOT CMAKE_REQUIRED_QUIET)
message (STATUS "Looking for gflags namespace - failed")
endif ()
set (${VARIABLE} ${_namespace} CACHE INTERNAL "gflags namespace")
endif ()
endif ()
endmacro ()
@PACKAGE_INIT@
include ("${CMAKE_CURRENT_LIST_DIR}/glog-targets.cmake")
set_and_check (glog_INCLUDE_DIR "@PACKAGE_glog_INCLUDE_DIR@")
@glog_PACKAGE_DEPS@
set (glog_LIBRARY glog)
set (glog_LIBRARIES ${glog_LIBRARY})
set (glog_INCLUDE_DIRS ${glog_INCLUDE_DIR})
/* define if glog doesn't use RTTI */
#cmakedefine DISABLE_RTTI
/* Namespace for Google classes */
#cmakedefine GOOGLE_NAMESPACE ${GOOGLE_NAMESPACE}
/* Define if you have the `dladdr' function */
#cmakedefine HAVE_DLADDR
/* Define if you have the `snprintf' function */
#cmakedefine HAVE_SNPRINTF
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine HAVE_DLFCN_H
/* Define to 1 if you have the <execinfo.h> header file. */
#cmakedefine HAVE_EXECINFO_H
/* Define if you have the `fcntl' function */
#cmakedefine HAVE_FCNTL
/* Define to 1 if you have the <glob.h> header file. */
#cmakedefine HAVE_GLOB_H
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
/* Define to 1 if you have the `pthread' library (-lpthread). */
#cmakedefine HAVE_LIBPTHREAD
/* Define to 1 if you have the <libunwind.h> header file. */
#cmakedefine HAVE_LIBUNWIND_H
/* define if you have google gflags library */
#cmakedefine HAVE_LIB_GFLAGS
/* define if you have google gmock library */
#cmakedefine HAVE_LIB_GMOCK
/* define if you have google gtest library */
#cmakedefine HAVE_LIB_GTEST
/* define if you have libunwind */
#cmakedefine HAVE_LIB_UNWIND
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H
/* define if the compiler implements namespaces */
#cmakedefine HAVE_NAMESPACES
/* Define if you have the 'pread' function */
#cmakedefine HAVE_PREAD
/* Define if you have POSIX threads libraries and header files. */
#cmakedefine HAVE_PTHREAD
/* Define to 1 if you have the <pwd.h> header file. */
#cmakedefine HAVE_PWD_H
/* Define if you have the 'pwrite' function */
#cmakedefine HAVE_PWRITE
/* define if the compiler implements pthread_rwlock_* */
#cmakedefine HAVE_RWLOCK
/* Define if you have the 'sigaction' function */
#cmakedefine HAVE_SIGACTION
/* Define if you have the `sigaltstack' function */
#cmakedefine HAVE_SIGALTSTACK
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H
/* Define to 1 if you have the <syscall.h> header file. */
#cmakedefine HAVE_SYSCALL_H
/* Define to 1 if you have the <syslog.h> header file. */
#cmakedefine HAVE_SYSLOG_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/syscall.h> header file. */
#cmakedefine HAVE_SYS_SYSCALL_H
/* Define to 1 if you have the <sys/time.h> header file. */
#cmakedefine HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H}
/* Define to 1 if you have the <sys/ucontext.h> header file. */
#cmakedefine HAVE_SYS_UCONTEXT_H
/* Define to 1 if you have the <sys/utsname.h> header file. */
#cmakedefine HAVE_SYS_UTSNAME_H
/* Define to 1 if you have the <ucontext.h> header file. */
#cmakedefine HAVE_UCONTEXT_H
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H}
/* Define to 1 if you have the <unwind.h> header file. */
#cmakedefine HAVE_UNWIND_H ${HAVE_UNWIND_H}
/* define if the compiler supports using expression for operator */
#cmakedefine HAVE_USING_OPERATOR
/* define if your compiler has __attribute__ */
#cmakedefine HAVE___ATTRIBUTE__
/* define if your compiler has __builtin_expect */
#cmakedefine HAVE___BUILTIN_EXPECT ${HAVE___BUILTIN_EXPECT}
/* define if your compiler has __sync_val_compare_and_swap */
#cmakedefine HAVE___SYNC_VAL_COMPARE_AND_SWAP
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#cmakedefine LT_OBJDIR
/* Name of package */
#cmakedefine PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#cmakedefine PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#cmakedefine PACKAGE_NAME
/* Define to the full name and version of this package. */
#cmakedefine PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#cmakedefine PACKAGE_TARNAME
/* Define to the home page for this package. */
#cmakedefine PACKAGE_URL
/* Define to the version of this package. */
#cmakedefine PACKAGE_VERSION
/* How to access the PC from a struct ucontext */
#cmakedefine PC_FROM_UCONTEXT
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
#cmakedefine PTHREAD_CREATE_JOINABLE
/* The size of `void *', as computed by sizeof. */
#cmakedefine SIZEOF_VOID_P ${SIZEOF_VOID_P}
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS
/* the namespace where STL code like vector<> is defined */
#cmakedefine STL_NAMESPACE ${STL_NAMESPACE}
/* location of source code */
#cmakedefine TEST_SRC_DIR ${TEST_SRC_DIR}
/* Version number of package */
#cmakedefine VERSION
/* Stops putting the code inside the Google namespace */
#cmakedefine _END_GOOGLE_NAMESPACE_ ${_END_GOOGLE_NAMESPACE_}
/* Puts following code inside the Google namespace */
#cmakedefine _START_GOOGLE_NAMESPACE_ ${_START_GOOGLE_NAMESPACE_}
......@@ -178,3 +178,12 @@
/* Puts following code inside the Google namespace */
#undef _START_GOOGLE_NAMESPACE_
// Annoying stuff for windows -- makes sure clients can import these functions
#ifndef GOOGLE_GLOG_DLL_DECL
# if defined(_WIN32) && !defined(__CYGWIN__)
# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
# else
# define GOOGLE_GLOG_DLL_DECL
# endif
#endif
......@@ -77,7 +77,7 @@ _START_GOOGLE_NAMESPACE_
// Demangle "mangled". On success, return true and write the
// demangled symbol name to "out". Otherwise, return false.
// "out" is modified even if demangling is unsuccessful.
bool Demangle(const char *mangled, char *out, int out_size);
bool GOOGLE_GLOG_DLL_DECL Demangle(const char *mangled, char *out, int out_size);
_END_GOOGLE_NAMESPACE_
......
......@@ -41,6 +41,11 @@
#include "googletest.h"
#include "config.h"
#ifdef HAVE_LIB_GFLAGS
#include <gflags/gflags.h>
using namespace GFLAGS_NAMESPACE;
#endif
GLOG_DEFINE_bool(demangle_filter, false,
"Run demangle_unittest in filter mode");
......
......@@ -48,14 +48,6 @@
#endif
#include <vector>
// Annoying stuff for windows -- makes sure clients can import these functions
#ifndef GOOGLE_GLOG_DLL_DECL
# if defined(_WIN32) && !defined(__CYGWIN__)
# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
# else
# define GOOGLE_GLOG_DLL_DECL
# endif
#endif
#if defined(_MSC_VER)
#define GLOG_MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
__pragma(warning(disable:n))
......@@ -65,6 +57,15 @@
#define GLOG_MSVC_POP_WARNING()
#endif
// Annoying stuff for windows -- makes sure clients can import these functions
#ifndef GOOGLE_GLOG_DLL_DECL
# if defined(_WIN32) && !defined(__CYGWIN__)
# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
# else
# define GOOGLE_GLOG_DLL_DECL
# endif
#endif
// We care a lot about number of bits things take up. Unfortunately,
// systems define their bit-specific ints in a lot of different ways.
// We use our own way, and have a typedef to get there.
......@@ -1164,6 +1165,8 @@ public:
char* str() const { return pbase(); }
private:
LogStream(const LogStream&);
LogStream& operator=(const LogStream&);
base_logging::LogStreamBuf streambuf_;
int ctr_; // Counter hack (for the LOG_EVERY_X() macro)
LogStream *self_; // Consistency check hack
......@@ -1231,7 +1234,7 @@ public:
void SendToSyslogAndLog(); // Actually dispatch to syslog and the logs
// Call abort() or similar to perform LOG(FATAL) crash.
static void Fail() @ac_cv___attribute___noreturn@;
static void @ac_cv___attribute___noreturn@ Fail();
std::ostream& stream();
......@@ -1279,7 +1282,7 @@ class GOOGLE_GLOG_DLL_DECL LogMessageFatal : public LogMessage {
public:
LogMessageFatal(const char* file, int line);
LogMessageFatal(const char* file, int line, const CheckOpString& result);
~LogMessageFatal() @ac_cv___attribute___noreturn@;
@ac_cv___attribute___noreturn@ ~LogMessageFatal();
};
// A non-macro interface to the log facility; (useful
......@@ -1583,7 +1586,7 @@ class GOOGLE_GLOG_DLL_DECL NullStreamFatal : public NullStream {
NullStreamFatal() { }
NullStreamFatal(const char* file, int line, const CheckOpString& result) :
NullStream(file, line, result) { }
@ac_cv___attribute___noreturn@ ~NullStreamFatal() { _exit(1); }
@ac_cv___attribute___noreturn@ ~NullStreamFatal() throw () { _exit(1); }
};
// Install a signal handler that will dump signal information and a stack
......
......@@ -81,7 +81,7 @@ static inline string GetTempDir() {
#endif
}
#if defined(OS_WINDOWS) && defined(_MSC_VER)
#if defined(OS_WINDOWS) && defined(_MSC_VER) && !defined(TEST_SRC_DIR)
// The test will run in glog/vsproject/<project name>
// (e.g., glog/vsproject/logging_unittest).
static const char TEST_SRC_DIR[] = "../..";
......
......@@ -61,6 +61,7 @@ DECLARE_string(log_backtrace_at); // logging.cc
#ifdef HAVE_LIB_GFLAGS
#include <gflags/gflags.h>
using namespace GFLAGS_NAMESPACE;
#endif
#ifdef HAVE_LIB_GMOCK
......
......@@ -41,6 +41,11 @@
#include <string>
#include "glog/logging.h"
#ifdef HAVE_LIB_GFLAGS
#include <gflags/gflags.h>
using namespace gflags;
#endif
using namespace GOOGLE_NAMESPACE;
void* DieInThread(void*) {
......
......@@ -31,6 +31,7 @@
#ifdef HAVE_USING_OPERATOR
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
......@@ -41,11 +42,19 @@
// C++0x isn't enabled by default in GCC and libc++ does not have
// non-standard ext/* and tr1/unordered_*.
# if defined(_LIBCPP_VERSION)
# ifndef GLOG_STL_LOGGING_FOR_UNORDERED
# define GLOG_STL_LOGGING_FOR_UNORDERED
# endif
# else
# ifndef GLOG_STL_LOGGING_FOR_EXT_HASH
# define GLOG_STL_LOGGING_FOR_EXT_HASH
# endif
# ifndef GLOG_STL_LOGGING_FOR_EXT_SLIST
# define GLOG_STL_LOGGING_FOR_EXT_SLIST
# endif
# ifndef GLOG_STL_LOGGING_FOR_TR1_UNORDERED
# define GLOG_STL_LOGGING_FOR_TR1_UNORDERED
# endif
# endif
#endif
......
......@@ -41,6 +41,11 @@
#include "googletest.h"
#include "config.h"
#ifdef HAVE_LIB_GFLAGS
#include <gflags/gflags.h>
using namespace GFLAGS_NAMESPACE;
#endif
using namespace std;
using namespace GOOGLE_NAMESPACE;
......
......@@ -28,11 +28,15 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: Shinichiro Hamaji
#include "utilities.h"
#include "googletest.h"
#include "glog/logging.h"
#ifdef HAVE_LIB_GFLAGS
#include <gflags/gflags.h>
using namespace GFLAGS_NAMESPACE;
#endif
using namespace GOOGLE_NAMESPACE;
TEST(utilities, sync_val_compare_and_swap) {
......
......@@ -55,6 +55,7 @@ int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
return _vsnprintf(str, size-1, format, ap);
}
#ifndef HAVE_SNPRINTF
int snprintf(char *str, size_t size, const char *format, ...) {
va_list ap;
va_start(ap, format);
......@@ -62,3 +63,4 @@ int snprintf(char *str, size_t size, const char *format, ...) {
va_end(ap);
return r;
}
#endif
......@@ -111,12 +111,16 @@ enum { STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2 };
* because they don't always NUL-terminate. :-( We also can't use the
* name vsnprintf, since windows defines that (but not snprintf (!)).
*/
extern int snprintf(char *str, size_t size,
#ifndef HAVE_SNPRINTF
extern int GOOGLE_GLOG_DLL_DECL snprintf(char *str, size_t size,
const char *format, ...);
extern int safe_vsnprintf(char *str, size_t size,
#endif
extern int GOOGLE_GLOG_DLL_DECL safe_vsnprintf(char *str, size_t size,
const char *format, va_list ap);
#define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap)
#ifndef va_copy
#define va_copy(dst, src) (dst) = (src)
#endif
/* Windows doesn't support specifying the number of buckets as a
* hash_map constructor arg, so we leave this blank.
......
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