Skip to content

Commit

Permalink
Merge pull request protocolbuffers#497 from pherl/config_h
Browse files Browse the repository at this point in the history
Check HAVE_CONFIG_H before including "config.h"
  • Loading branch information
liujisi committed Jun 17, 2015
2 parents 4cbb612 + 78d470c commit b36395b
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 156 deletions.
3 changes: 0 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -744,12 +744,9 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
CONTRIBUTORS.txt \
CHANGES.txt \
cmake/CMakeLists.txt \
cmake/config.h.in \
cmake/find_hash_map.cmake \
cmake/libprotobuf.cmake \
cmake/libprotobuf-lite.cmake \
cmake/libprotoc.cmake \
cmake/pbconfig.h.in \
cmake/protoc.cmake \
cmake/README.md \
cmake/tests.cmake \
Expand Down
14 changes: 7 additions & 7 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ if (MSVC)
option(ZLIB "Build with zlib support" OFF)
endif (MSVC)

add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD)

find_package(Threads REQUIRED)
if (CMAKE_USE_PTHREADS_INIT)
set(HAVE_PTHREAD 1)
else (CMAKE_USE_PTHREADS_INIT)
set(HAVE_PTHREAD 0)
add_definitions(-DHAVE_PTHREAD)
endif (CMAKE_USE_PTHREADS_INIT)

if (MSVC)
Expand All @@ -36,17 +36,17 @@ else (MSVC)
endif (ZLIB_FOUND)
endif (MSVC)

if (HAVE_ZLIB)
add_definitions(-DHAVE_ZLIB)
endif (HAVE_ZLIB)

if (MSVC)
if (BUILD_SHARED_LIBS)
add_definitions(-DPROTOBUF_USE_DLLS)
endif (BUILD_SHARED_LIBS)
add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305)
endif (MSVC)

include(find_hash_map.cmake)

configure_file(config.h.in config.h)
configure_file(pbconfig.h.in google/protobuf/stubs/pbconfig.h)
if (MSVC)
string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR})
Expand Down
4 changes: 0 additions & 4 deletions cmake/config.h.in

This file was deleted.

119 changes: 0 additions & 119 deletions cmake/find_hash_map.cmake

This file was deleted.

9 changes: 0 additions & 9 deletions cmake/pbconfig.h.in

This file was deleted.

6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ AC_INIT([Protocol Buffers],[3.0.0-alpha-4-pre],[[email protected]],[prot
AM_MAINTAINER_MODE([enable])

AC_CONFIG_SRCDIR(src/google/protobuf/message.cc)
# The config file is generated but not used by the source code, since we only
# need very few of them, e.g. HAVE_PTHREAD and HAVE_ZLIB. Those macros are
# passed down in CXXFLAGS manually in src/Makefile.am
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])

Expand Down Expand Up @@ -146,6 +149,9 @@ AS_IF([test "$with_protoc" != "no"], [
AM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test "$with_protoc" != "no"])

ACX_PTHREAD
AM_CONDITIONAL([HAVE_PTHREAD], [test "x$acx_pthread_ok" = "xyes"])

# We still keep this for improving pbconfig.h for unsupported platforms.
AC_CXX_STL_HASH

case "$target_os" in
Expand Down
12 changes: 10 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ if HAVE_ZLIB
GZCHECKPROGRAMS = zcgzip zcgunzip
GZHEADERS = google/protobuf/io/gzip_stream.h
GZTESTS = google/protobuf/io/gzip_stream_unittest.sh
ZLIB_DEF = -DHAVE_ZLIB=1
else
GZCHECKPROGRAMS =
GZHEADERS =
GZTESTS =
ZLIB_DEF =
endif

if HAVE_PTHREAD
PTHREAD_DEF = -DHAVE_PTHREAD=1
else
PTHREAD_DEF =
endif

if GCC
# These are good warnings to turn on by default
NO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS) -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
NO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
else
NO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS)
NO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF)
endif

AM_CXXFLAGS = $(NO_OPT_CXXFLAGS) $(PROTOBUF_OPT_FLAG)
Expand Down
2 changes: 0 additions & 2 deletions src/google/protobuf/io/gzip_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
// This file contains the implementation of classes GzipInputStream and
// GzipOutputStream.

#include "config.h"

#if HAVE_ZLIB
#include <google/protobuf/io/gzip_stream.h>

Expand Down
2 changes: 0 additions & 2 deletions src/google/protobuf/io/zero_copy_stream_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
// "parametized tests" so that one set of tests can be used on all the
// implementations.

#include "config.h"

#ifdef _MSC_VER
#include <io.h>
#else
Expand Down
2 changes: 0 additions & 2 deletions src/google/protobuf/stubs/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
#include <errno.h>
#include <vector>

#include "config.h"

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN // We only need minimal includes
#include <windows.h>
Expand Down
2 changes: 0 additions & 2 deletions src/google/protobuf/stubs/common_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
#include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h>

#include "config.h"

namespace google {
namespace protobuf {
namespace {
Expand Down
2 changes: 0 additions & 2 deletions src/google/protobuf/testing/zcgunzip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
// Reads gzip stream on standard input and writes decompressed data to standard
// output.

#include "config.h"

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
2 changes: 0 additions & 2 deletions src/google/protobuf/testing/zcgzip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
// Reads data on standard input and writes compressed gzip stream to standard
// output.

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
Expand Down

0 comments on commit b36395b

Please sign in to comment.