From 4ad8fcf0352cf19c19a1b752aef86597b397d303 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 18 Aug 2018 15:04:39 +0100 Subject: [PATCH] Switch to C++17, MSVC 2017, GCC 8 This will allow use of newer language features and additions to the standard library, but is a breaking change as it changes the required C++ runtime. --- .travis.yml | 8 ++++---- CMakeLists.txt | 8 +++++--- appveyor.yml | 8 ++++---- src/tests/api/interface/create_game_handle_test.h | 10 +++++----- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c5b85da..8dcb7c5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,8 @@ addons: - libssl-dev - libhttp-parser-dev - libssh2-1-dev - - gcc-6 - - g++-6 + - gcc-8 + - g++-8 cache: directories: @@ -20,10 +20,10 @@ cache: cargo: true install: - - export CXX="g++-6" CC="gcc-6" + - export CXX="g++-8" CC="gcc-8" # Build Boost. - wget https://raw.githubusercontent.com/WrinklyNinja/ci-scripts/1.5.0/install_boost.py - - python install_boost.py --directory ~ --boost-version 1.67.0 -a 64 -t gcc-6 filesystem locale system thread + - python install_boost.py --directory ~ --boost-version 1.67.0 -a 64 -t gcc-8 filesystem locale system thread # Install packages for generating documentation - pip install --user -r docs/requirements.txt # Add sphinx-build to PATH diff --git a/CMakeLists.txt b/CMakeLists.txt index c1fc6b7a..87b4f017 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,8 @@ ELSE() ENDIF() set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) ############################## # Get Build Revision @@ -61,7 +63,7 @@ ELSE () set(RUST_TARGET x86_64-unknown-linux-gnu) ENDIF () -find_package(Boost REQUIRED COMPONENTS locale filesystem system) +find_package(Boost REQUIRED COMPONENTS filesystem locale system) ExternalProject_Add(GTest PREFIX "external" @@ -323,8 +325,6 @@ ENDIF () IF (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};.") set (CMAKE_BUILD_WITH_INSTALL_RPATH ON) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=c++14") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++14") set (LOOT_LIBS ssl curl @@ -343,6 +343,8 @@ IF (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") ENDIF () IF (MSVC) + # Turn off permissive mode to be more standards-compliant and avoid compiler errors. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-") # Set /bigobj to allow building Debug and RelWithDebInfo tests set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /bigobj") diff --git a/appveyor.yml b/appveyor.yml index cdf9bb2b..19838e4b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -os: Visual Studio 2015 +os: Visual Studio 2017 version: "{build}-{branch}" @@ -33,9 +33,9 @@ before_build: - cd build - ps: | if ($env:PLATFORM -eq 'Win32') { - cmake .. -G "Visual Studio 14 2015" -DBOOST_ROOT="C:\Libraries\boost_1_67_0" -DBOOST_LIBRARYDIR="C:\Libraries\boost_1_67_0\lib32-msvc-14.0" + cmake .. -G "Visual Studio 15 2017" -DBOOST_ROOT="C:\Libraries\boost_1_67_0" -DBOOST_LIBRARYDIR="C:\Libraries\boost_1_67_0\lib32-msvc-14.1" } else { - cmake .. -G "Visual Studio 14 2015 Win64" -DBOOST_ROOT="C:\Libraries\boost_1_67_0" -DBOOST_LIBRARYDIR="C:\Libraries\boost_1_67_0\lib64-msvc-14.0" + cmake .. -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:\Libraries\boost_1_67_0" -DBOOST_LIBRARYDIR="C:\Libraries\boost_1_67_0\lib64-msvc-14.1" } build: @@ -77,7 +77,7 @@ deploy: tag: $(APPVEYOR_REPO_TAG_NAME) release: LOOT API v$(APPVEYOR_REPO_TAG_NAME) description: | - Requires Windows 7 or later and the [MSVC 2015 x86 redistributable](https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x86.exe), and [7-Zip](http://www.7-zip.org/) to extract the archives. + Requires Windows 7 or later and the [MSVC 2017 x86 redistributable](https://download.visualstudio.microsoft.com/download/pr/12192785/88b50ce70017bf10f2d56d60fcba6ab1/VC_redist.x86.exe), and [7-Zip](http://www.7-zip.org/) to extract the archives. ## Change Logs - [API](https://loot-api.readthedocs.io/en/$(APPVEYOR_REPO_TAG_NAME)/api/changelog.html) diff --git a/src/tests/api/interface/create_game_handle_test.h b/src/tests/api/interface/create_game_handle_test.h index 5e9f9d41..1d77b435 100644 --- a/src/tests/api/interface/create_game_handle_test.h +++ b/src/tests/api/interface/create_game_handle_test.h @@ -87,7 +87,7 @@ TEST_P(CreateGameHandleTest, EXPECT_NO_THROW(handle_ = CreateGameHandle(GetParam(), relative(dataPath.parent_path()).string(), relative(localPath).string())); - EXPECT_NE(nullptr, handle_); + EXPECT_TRUE(handle_); } TEST_P(CreateGameHandleTest, @@ -95,7 +95,7 @@ TEST_P(CreateGameHandleTest, EXPECT_NO_THROW(handle_ = CreateGameHandle(GetParam(), dataPath.parent_path().string(), localPath.string())); - EXPECT_NE(nullptr, handle_); + EXPECT_TRUE(handle_); } TEST_P(CreateGameHandleTest, shouldThrowIfPassedAGamePathThatDoesNotExist) { @@ -115,7 +115,7 @@ TEST_P(CreateGameHandleTest, shouldThrowIfPassedALocalPathThatDoesNotExist) { TEST_P(CreateGameHandleTest, shouldReturnOkIfPassedAnEmptyLocalPathString) { EXPECT_NO_THROW(handle_ = CreateGameHandle( GetParam(), dataPath.parent_path().string(), "")); - EXPECT_NE(nullptr, handle_); + EXPECT_TRUE(handle_); } #endif @@ -123,7 +123,7 @@ TEST_P(CreateGameHandleTest, shouldReturnOkIfPassedGameAndLocalPathSymlinks) { EXPECT_NO_THROW(handle_ = CreateGameHandle(GetParam(), gamePathSymlink.string(), localPathSymlink.string())); - EXPECT_NE(nullptr, handle_); + EXPECT_TRUE(handle_); } #ifdef _WIN32 @@ -132,7 +132,7 @@ TEST_P(CreateGameHandleTest, EXPECT_NO_THROW(handle_ = CreateGameHandle(GetParam(), gamePathJunctionLink.string(), localPathJunctionLink.string())); - EXPECT_NE(nullptr, handle_); + EXPECT_TRUE(handle_); } #endif }