Skip to content

Commit 56811bf

Browse files
committed
Build: Update to C++17 version
The immediate driver for this change is related when fetching GTest. Currently we are stuck with GTest-1.12.1 because is the latest version supporting C++11. Later versions require C++14. However, GTest-1.12.1 has a CMakeLists.txt with ``cmake_minimum_required(VERSION 3.5)`` which causes the following warning with modern CMake versions: ``` CMake Deprecation Warning at build/_deps/googletest-src/CMakeLists.txt:4 (cmake_minimum_required): Compatibility with CMake < 3.10 will be removed from a future version of CMake. ``` Updating to >= C++14 allows us to use GTest-1.15.2 which has a ``cmake_minimum_required(VERSION 3.13)``
1 parent 5500ba7 commit 56811bf

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

.github/workflows/windows.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,13 @@ jobs:
7171
cd %PROJ_BUILD%
7272
set PROJ_DIR=%GITHUB_WORKSPACE%\proj_dir
7373
:: Not directly linked to BUILD_SHARED_LIBS, but a way to test different C++ standard versions
74-
if "${{ env.BUILD_SHARED_LIBS }}"=="ON" (set EXTRA_CXX_FLAGS="/std:c++20")
74+
if "${{ env.BUILD_SHARED_LIBS }}"=="ON" (set CMAKE_CXX_STANDARD="-DCMAKE_CXX_STANDARD=20")
7575
if "${{ env.BUILD_TYPE }}"=="Release" (set CMAKE_UNITY_BUILD_OPT="-DCMAKE_UNITY_BUILD=ON")
7676
cmake -D CMAKE_BUILD_TYPE="${{ env.BUILD_TYPE }}" ^
7777
-D BUILD_SHARED_LIBS="${{ env.BUILD_SHARED_LIBS }}" ^
7878
-D CMAKE_C_FLAGS="/WX" ^
79-
-D CMAKE_CXX_FLAGS="/WX %EXTRA_CXX_FLAGS%" ^
79+
-D CMAKE_CXX_FLAGS="/WX" ^
80+
%CMAKE_CXX_STANDARD% ^ ..
8081
-D CMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake ^
8182
-D CMAKE_INSTALL_PREFIX="%PROJ_DIR%" ^
8283
-D PROJ_DB_CACHE_DIR=%PROJ_DB_CACHE_DIR% ^

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ cmake_policy(SET CMP0054 NEW)
2121

2222
# Set C++ version
2323
# Make CMAKE_CXX_STANDARD available as cache option overridable by user
24-
set(CMAKE_CXX_STANDARD 11
25-
CACHE STRING "C++ standard version to use (default is 11)")
24+
set(CMAKE_CXX_STANDARD 17
25+
CACHE STRING "C++ standard version to use (default is 17)")
2626
message(STATUS "Requiring C++${CMAKE_CXX_STANDARD}")
2727
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2828
set(CMAKE_CXX_EXTENSIONS OFF)

docs/source/install.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Build requirements
146146
++++++++++++++++++
147147

148148
- C99 compiler
149-
- C++11 compiler
149+
- C++17 compiler
150150
- CMake >= 3.16
151151
- SQLite3 >= 3.11: headers and library for target architecture, and sqlite3 executable for build architecture
152152
- libtiff >= 4.0 (optional but recommended)
@@ -160,7 +160,7 @@ Test requirements
160160

161161
These are only required if testing is built (see :option:`BUILD_TESTING`, default ON)
162162

163-
- GoogleTest (GTest) >= 1.8.1; if not found and :option:`TESTING_USE_NETWORK` is ON, then version 1.12.1 is fetched from GitHub and locally installed
163+
- GoogleTest (GTest) >= 1.8.1; if not found and :option:`TESTING_USE_NETWORK` is ON, then version 1.15.2 is fetched from GitHub and locally installed
164164
- Python >= 3.7
165165
- `importlib_metadata <https://pypi.org/project/importlib-metadata/>`_ only needed for Python 3.7
166166
- One of either `PyYAML <https://pypi.org/project/PyYAML/>`_ or `ruamel.yaml <https://pypi.org/project/ruamel.yaml/>`_

test/unit/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ elseif(HAS_NETWORK)
6060
cmake_policy(SET CMP0135 NEW) # for DOWNLOAD_EXTRACT_TIMESTAMP option
6161
endif()
6262

63+
set(GTEST_VERSION "1.15.2")
64+
6365
include(FetchContent)
6466
FetchContent_Declare(
6567
googletest
66-
URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip
68+
URL https://github.com/google/googletest/archive/refs/tags/v${GTEST_VERSION}.zip
6769
EXCLUDE_FROM_ALL # ignored before CMake 3.28
6870
)
6971

0 commit comments

Comments
 (0)