summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. King, III <jim.king@simplivity.com>2017-04-04 13:04:29 -0400
committerJames E. King, III <jking@apache.org>2017-04-05 08:58:38 -0400
commit43e959bc5c4e68d0c2545a09ad4fc1c226885a22 (patch)
tree98657bcdad212f03ad340eb22890b1fc584aa51f
parent7f5a8c28bc58011abef0cede10915c2071efbe41 (diff)
downloadthrift-43e959bc5c4e68d0c2545a09ad4fc1c226885a22.tar.gz
THRIFT-4165: better cmake support for C++ language level selection; fixed compiler warnings
This closes #1236
-rw-r--r--CMakeLists.txt9
-rw-r--r--build/cmake/DefineCMakeDefaults.cmake17
-rw-r--r--build/cmake/DefineOptions.cmake1
-rw-r--r--build/cmake/DefinePlatformSpecifc.cmake21
-rw-r--r--build/docker/debian/Dockerfile25
-rw-r--r--build/docker/ubuntu/Dockerfile29
-rwxr-xr-xconfigure.ac8
7 files changed, 80 insertions, 30 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 93ed8d2ac..9f57a66c4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,7 +17,14 @@
# under the License.
#
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.1)
+
+# CMake 3.1 supports C++ standards selection with CMAKE_CXX_STANDARD
+# If you need CMake 3.1+ for Ubuntu 14.04, try
+# https://launchpad.net/~george-edison55/+archive/ubuntu/cmake-3.x
+# If you need CMake 3.1+ for debian "jessie", get it from jessie-backports
+# Otherwise
+# http://cmake.org
project("Apache Thrift")
diff --git a/build/cmake/DefineCMakeDefaults.cmake b/build/cmake/DefineCMakeDefaults.cmake
index 7073e8ef8..365c0a434 100644
--- a/build/cmake/DefineCMakeDefaults.cmake
+++ b/build/cmake/DefineCMakeDefaults.cmake
@@ -68,3 +68,20 @@ set(CMAKE_MACOSX_RPATH TRUE)
# locations and running the executables without LD_PRELOAD or similar.
# This requires the library to be built with rpath support.
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+
+#
+# C++ Language Level Defaults
+#
+if (NOT DEFINED CMAKE_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD 11) # C++11
+ message(STATUS "Setting C++11 as the default language level.")
+ message(STATUS "To specify a different C++ language level, set CMAKE_CXX_STANDARD")
+endif()
+
+if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
+ set(CMAKE_CXX_STANDARD_REQUIRED OFF) # can degrade to C++98 if compiler does not support C++11
+endif()
+
+if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
+ set(CMAKE_CXX_EXTENSIONS OFF) # use standards compliant language level for portability
+endif()
diff --git a/build/cmake/DefineOptions.cmake b/build/cmake/DefineOptions.cmake
index 93fe2c0af..63981e94d 100644
--- a/build/cmake/DefineOptions.cmake
+++ b/build/cmake/DefineOptions.cmake
@@ -173,6 +173,7 @@ message(STATUS " Language libraries:")
message(STATUS " Build C++ library: ${BUILD_CPP}")
MESSAGE_DEP(WITH_CPP "Disabled by WITH_CPP=OFF")
MESSAGE_DEP(Boost_FOUND "Boost headers missing")
+message(STATUS " C++ Language Level: ${CXX_LANGUAGE_LEVEL}")
message(STATUS " Build C (GLib) library: ${BUILD_C_GLIB}")
MESSAGE_DEP(WITH_C_GLIB "Disabled by WITH_C_GLIB=OFF")
MESSAGE_DEP(GLIB_FOUND "GLib missing")
diff --git a/build/cmake/DefinePlatformSpecifc.cmake b/build/cmake/DefinePlatformSpecifc.cmake
index e8479bc73..d5d27e2d0 100644
--- a/build/cmake/DefinePlatformSpecifc.cmake
+++ b/build/cmake/DefinePlatformSpecifc.cmake
@@ -98,12 +98,23 @@ elseif(WITH_STDTHREADS)
add_definitions("-DUSE_STD_THREAD=1")
endif()
-# GCC and Clang: use C++11
-if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.6.4")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+# C++ Language Level
+set(CXX_LANGUAGE_LEVEL "C++${CMAKE_CXX_STANDARD}")
+if (CMAKE_CXX_STANDARD_REQUIRED)
+ string(CONCAT CXX_LANGUAGE_LEVEL "${CXX_LANGUAGE_LEVEL} [compiler must support it]")
+else()
+ string(CONCAT CXX_LANGUAGE_LEVEL "${CXX_LANGUAGE_LEVEL} [fallback to earlier if compiler does not support it]")
+endif()
+if (CMAKE_CXX_EXTENSIONS)
+ string(CONCAT CXX_LANGUAGE_LEVEL "${CXX_LANGUAGE_LEVEL} [with compiler-specific extensions]")
+else()
+ if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND NOT MINGW)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros -Wno-long-long -Wno-c++11-long-long")
endif()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -Wextra -pedantic")
+endif()
+
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
endif()
# If gcc older than 4.8 is detected and plugin support was requested, fail fast
diff --git a/build/docker/debian/Dockerfile b/build/docker/debian/Dockerfile
index 155e0af15..7bc74fc24 100644
--- a/build/docker/debian/Dockerfile
+++ b/build/docker/debian/Dockerfile
@@ -10,10 +10,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Apache Thrift Docker build environment for Centos
+# Apache Thrift Docker build environment for Debian
#
# Known missing client libraries:
-# - None
+# - dotnetcore
+# - rust
FROM buildpack-deps:jessie-scm
MAINTAINER Apache Thrift <dev@thrift.apache.org>
@@ -21,6 +22,9 @@ MAINTAINER Apache Thrift <dev@thrift.apache.org>
ENV DEBIAN_FRONTEND noninteractive
# Add apt sources
+# jessie-backports for cmake and some ruby bits
+RUN echo "deb http://ftp.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list
+
# Dart
RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \
@@ -31,12 +35,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
bison \
build-essential \
clang \
- cmake \
debhelper \
flex \
- pkg-config
+ pkg-config && \
+ apt-get -t jessie-backports install -y --no-install-recommends cmake
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# C++ dependencies` \
libboost-dev \
libboost-filesystem-dev \
@@ -50,14 +54,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
qtbase5-dev \
qtbase5-dev-tools
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# Java dependencies` \
ant \
ant-optional \
openjdk-7-jdk \
maven
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# Python dependencies` \
python-all \
python-all-dbg \
@@ -72,7 +76,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
python3-setuptools \
python3-pip
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# Ruby dependencies` \
ruby \
ruby-dev \
@@ -83,9 +87,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libio-socket-ssl-perl \
libnet-ssleay-perl
-RUN echo "deb http://ftp.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list
-RUN apt-get update && apt-get -t jessie-backports install -y ruby-bundler
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get -t jessie-backports install -y ruby-bundler
+RUN apt-get install -y --no-install-recommends \
`# Php dependencies` \
php5 \
php5-dev \
diff --git a/build/docker/ubuntu/Dockerfile b/build/docker/ubuntu/Dockerfile
index 451087fd7..d1f69d8b5 100644
--- a/build/docker/ubuntu/Dockerfile
+++ b/build/docker/ubuntu/Dockerfile
@@ -10,10 +10,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Apache Thrift Docker build environment for Centos
+# Apache Thrift Docker build environment for Ubuntu
#
# Known missing client libraries:
-# - None
+# - dotnetcore
+# - rust
FROM buildpack-deps:trusty-scm
MAINTAINER Apache Thrift <dev@thrift.apache.org>
@@ -21,9 +22,15 @@ MAINTAINER Apache Thrift <dev@thrift.apache.org>
ENV DEBIAN_FRONTEND noninteractive
# Add apt sources
+# CMAKE
+RUN apt-get update && \
+ apt-get install -y --no-install-recommends software-properties-common && \
+ add-apt-repository -y ppa:george-edison55/cmake-3.x
+
# Erlang
RUN echo 'deb http://packages.erlang-solutions.com/debian trusty contrib' > /etc/apt/sources.list.d/erlang_solutions.list && \
curl -sSL https://packages.erlang-solutions.com/debian/erlang_solutions.asc | apt-key add -
+
# Dart
RUN curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \
@@ -51,7 +58,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
`# libtool` \
`# make`
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# C++ dependencies` \
`# libevent and OpenSSL are needed by D too` \
libboost-dev \
@@ -66,14 +73,14 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
qtbase5-dev \
qtbase5-dev-tools
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# Java dependencies` \
ant \
ant-optional \
openjdk-7-jdk \
maven
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# Python dependencies` \
`# TODO:` \
`# Install twisted and zope.interface via pip. we need twisted at ./configure time, otherwise` \
@@ -91,7 +98,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
python3-setuptools \
python3-pip
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# Ruby dependencies` \
ruby \
ruby-dev \
@@ -103,7 +110,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libio-socket-ssl-perl \
libnet-ssleay-perl
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# Php dependencies` \
php5 \
php5-dev \
@@ -122,7 +129,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
erlang-tools \
rebar
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# Haskell dependencies` \
ghc \
cabal-install \
@@ -131,18 +138,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
neko-dev \
libneko0
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# Node.js dependencies` \
nodejs \
nodejs-dev \
nodejs-legacy
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# CSharp dependencies` \
libmono-system-web2.0-cil \
mono-devel
-RUN apt-get update && apt-get install -y --no-install-recommends \
+RUN apt-get install -y --no-install-recommends \
`# D dependencies` \
xdg-utils \
`# Dart dependencies` \
diff --git a/configure.ac b/configure.ac
index bb25495e4..0c628da4a 100755
--- a/configure.ac
+++ b/configure.ac
@@ -100,6 +100,10 @@ AC_PROG_RANLIB
AC_LANG([C++])
AX_CXX_COMPILE_STDCXX_11([noext], [optional])
+if test "$ac_success" = "no"; then
+ CXXFLAGS="$CXXFLAGS -Wno-variadic-macros -Wno-long-long -Wno-c++11-long-long"
+fi
+CXXFLAGS="$CXXFLAGS -Wno-deprecated-register"
AM_EXTRA_RECURSIVE_TARGETS([style])
AC_SUBST(CPPSTYLE_CMD, 'find . -type f \( -iname "*.h" -or -iname "*.cpp" -or -iname "*.cc" -or -iname "*.tcc" \) -printf "Reformatting: %h/%f\n" -exec clang-format -i {} \;')
@@ -198,8 +202,8 @@ AM_CONDITIONAL(WITH_C_GLIB, [test "$have_glib2" = "yes" -a "$have_gobject2" = "y
echo "OpenSSL check"
if test "$have_cpp" = "yes" -o "$have_c_glib" = "yes"; then
- echo "Have cpp or c so we check for OpenSSL"
- AX_CHECK_OPENSSL()
+ echo "Have cpp or c so we check for OpenSSL"
+ AX_CHECK_OPENSSL()
fi
AX_THRIFT_LIB(csharp, [C#], yes)