Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THRIFT-4720:migrate code to c++11 #1677

Merged
merged 22 commits into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,6 @@ jobs:
- JOB="CMake"

# C++ specific options: compiler plug-in, threading model
- script: build/docker/run.sh
env:
- JOB="C++98 (Boost Thread)"
- SCRIPT="cmake.sh"
- BUILD_LIBS="CPP TESTING TUTORIALS"
- BUILD_ARG="-DCMAKE_CXX_STANDARD=98 -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_CXX_EXTENSIONS=OFF --DWITH_BOOSTTHREADS=ON -DWITH_PYTHON=OFF -DWITH_C_GLIB=OFF -DWITH_JAVA=OFF -DWITH_HASKELL=OFF"
- BUILD_ENV="-e CC=clang -e CXX=clang++"

- script: build/docker/run.sh
env:
- JOB="C++ (Std Thread) and Plugin"
Expand Down
11 changes: 2 additions & 9 deletions build/appveyor/cl_setenv.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

@ECHO OFF

IF "%PROFILE%" == "MSVC2010" (
CALL "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" %PLATFORM%
) ELSE IF "%PROFILE%" == "MSVC2012" (
IF "%PROFILE%" == "MSVC2012" (
CALL "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" %PLATFORM%
) ELSE IF "%PROFILE%" == "MSVC2013" (
CALL "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %PLATFORM%
Expand Down Expand Up @@ -54,12 +52,7 @@ IF "%PROFILE:~0,4%" == "MSVC" (
SET OPENSSL_ROOT=C:\OpenSSL-Win%NORM_PLATFORM%
SET WIN3P=%APPVEYOR_BUILD_FOLDER%\thirdparty

:: MSVC2010 doesn't "do" std::thread
IF "%COMPILER%" == "vc100" (
SET THREADMODEL=BOOST
) ELSE (
SET THREADMODEL=STD
)
SET THREADMODEL=STD

IF "%PYTHON_VERSION%" == "" (
SET WITH_PYTHON=OFF
Expand Down
17 changes: 7 additions & 10 deletions build/cmake/DefineCMakeDefaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,16 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# C++ Language Level Defaults - this depends on the compiler capabilities
#
if (NOT DEFINED CMAKE_CXX_STANDARD)
if (MSVC AND MSVC_VERSION LESS 1800)
# MSVC 2012 and earlier don't support template aliases so you have to use C++98
set(CMAKE_CXX_STANDARD 98)
message(STATUS "Setting C++98 as the default language level (for an older MSVC compiler).")
else()
set(CMAKE_CXX_STANDARD 11) # C++11
message(STATUS "Setting C++11 as the default language level.")
endif()
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
if (CMAKE_CXX_STANDARD EQUAL 98)
message(FATAL_ERROR "only C++11 or above C++ standard is supported")
elseif (CMAKE_CXX_STANDARD EQUAL 11)
# should not fallback to C++98
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
Expand Down
19 changes: 2 additions & 17 deletions build/cmake/DefineOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ option(BUILD_LIBRARIES "Build Thrift libraries" ON)
# and enables the library if all are found. This means the default is to build as
# much as possible but leaving out libraries if their dependencies are not met.

option(WITH_BOOST_FUNCTIONAL "Use boost/tr1/functional.hpp even under C++11 or later" OFF)
if (WITH_BOOST_FUNCTIONAL)
add_definitions(-DFORCE_BOOST_FUNCTIONAL)
endif()

option(WITH_BOOST_SMART_PTR "Use boost/smart_ptr.hpp even under C++11 or later" OFF)
if (WITH_BOOST_SMART_PTR)
add_definitions(-DFORCE_BOOST_SMART_PTR)
endif()

option(WITH_BOOST_STATIC "Build with Boost static link library" OFF)
set(Boost_USE_STATIC_LIBS ${WITH_BOOST_STATIC})
if (NOT WITH_BOOST_STATIC)
Expand Down Expand Up @@ -88,9 +78,7 @@ if(WITH_CPP)
find_package(OpenSSL QUIET)
CMAKE_DEPENDENT_OPTION(WITH_OPENSSL "Build with OpenSSL support" ON
"OPENSSL_FOUND" OFF)
option(WITH_STDTHREADS "Build with C++ std::thread support" OFF)
CMAKE_DEPENDENT_OPTION(WITH_BOOSTTHREADS "Build with Boost threads support" OFF
"NOT WITH_STDTHREADS;Boost_FOUND" OFF)
option(WITH_STDTHREADS "Build with C++ std::thread support" ON)
endif()
CMAKE_DEPENDENT_OPTION(BUILD_CPP "Build C++ library" ON
"BUILD_LIBRARIES;WITH_CPP;Boost_FOUND" OFF)
Expand All @@ -107,7 +95,7 @@ CMAKE_DEPENDENT_OPTION(BUILD_C_GLIB "Build C (GLib) library" ON

if(BUILD_CPP)
set(boost_components)
if(WITH_BOOSTTHREADS OR BUILD_TESTING)
if(BUILD_TESTING)
list(APPEND boost_components system thread)
endif()
if(BUILD_TESTING)
Expand Down Expand Up @@ -206,9 +194,6 @@ message(STATUS " Library features:")
message(STATUS " Build shared libraries: ${WITH_SHARED_LIB}")
message(STATUS " Build static libraries: ${WITH_STATIC_LIB}")
message(STATUS " Build with Boost static link library: ${WITH_BOOST_STATIC}")
message(STATUS " Build with Boost thread support: ${WITH_BOOSTTHREADS}")
message(STATUS " Build with boost/tr1/functional (forced) ${WITH_BOOST_FUNCTIONAL}")
message(STATUS " Build with boost/smart_ptr (forced) ${WITH_BOOST_SMART_PTR}")
message(STATUS " Build with C++ std::thread support: ${WITH_STDTHREADS}")
message(STATUS " Build with libevent support: ${WITH_LIBEVENT}")
message(STATUS " Build with OpenSSL support: ${WITH_OPENSSL}")
Expand Down
13 changes: 1 addition & 12 deletions build/cmake/DefinePlatformSpecifc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ add_definitions("-D__STDC_FORMAT_MACROS")
add_definitions("-D__STDC_LIMIT_MACROS")

# WITH_*THREADS selects which threading library to use
if(WITH_BOOSTTHREADS)
add_definitions("-DUSE_BOOST_THREAD=1")
elseif(WITH_STDTHREADS)
if(WITH_STDTHREADS)
add_definitions("-DUSE_STD_THREAD=1")
endif()

Expand All @@ -105,13 +103,6 @@ else()
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")
endif()
if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND NOT MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-long-long")
endif()
endif()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand All @@ -123,7 +114,5 @@ if (WITH_PLUGIN)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8")
message(SEND_ERROR "Thrift compiler plug-in support is not possible with older gcc ( < 4.8 ) compiler")
endif()
message(STATUS "Forcing use of boost::smart_ptr to build WITH_PLUGIN")
add_definitions("-DFORCE_BOOST_SMART_PTR=1")
endif()

2 changes: 1 addition & 1 deletion build/cmake/README-MSYS2.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Use cmake to create a MinGW makefile, out of tree (assumes you are in the top le
cmake -G"MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=/mingw64/bin/mingw32-make \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc.exe \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++.exe \
-DWITH_BOOSTTHREADS=ON -DWITH_LIBEVENT=OFF \
-DWITH_LIBEVENT=OFF \
-DWITH_SHARED_LIB=OFF -DWITH_STATIC_LIB=ON \
-DWITH_JAVA=OFF -DWITH_PYTHON=OFF -DWITH_PERL=OFF \
../thrift
Expand Down
2 changes: 1 addition & 1 deletion build/cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ or on Windows
cmake -G "Visual Studio 12 2013 Win64" \
-DBOOST_ROOT=C:/3rdparty/boost_1_58_0 \
-DZLIB_ROOT=C:/3rdparty/zlib128-dll \
-DWITH_SHARED_LIB=off -DWITH_BOOSTTHREADS=ON ..
-DWITH_SHARED_LIB=off ..

and open the development environment you like with the solution or do this:

Expand Down
3 changes: 0 additions & 3 deletions build/cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@
see: aclocal/ac_prog_bison.m4 */
#cmakedefine BISON_USE_PARSER_H_EXTENSION 1

/* replaces POSIX pthread by boost::thread */
#cmakedefine USE_BOOST_THREAD 1

/* replaces POSIX pthread by std::thread */
#cmakedefine USE_STD_THREAD 1

Expand Down
1 change: 0 additions & 1 deletion build/wincpp/build-thrift.bat
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ IF %OPT_GENERATE% == 1 (
-DOPENSSL_USE_STATIC_LIBS=OFF ^
-DZLIB_LIBRARY=%WIN3P_ROOT%\dist\zlib-%TP_ZLIB_VERSION%\%COMPILER%\%ARCH%\lib\zlib%ZLIB_LIB_SUFFIX%.lib ^
-DZLIB_ROOT=%WIN3P_ROOT%\dist\zlib-%TP_ZLIB_VERSION%\%COMPILER%\%ARCH% ^
-DWITH_BOOSTTHREADS=ON ^
-DWITH_SHARED_LIB=OFF ^
-DWITH_STATIC_LIB=ON || EXIT /B

Expand Down
Loading