Skip to content

Commit ab36e5b

Browse files
theIDinsiderocallahan
authored andcommitted
Support for C++>=20
Changes the CMake so that we can configure what c++ version we want to build with instead of hardcoding -std=c++17. The part about turning off extensions, is because without it, rr is compiled with -std=gnu++17/20/23, instead of -std=c++17/... which would not match the previous hard coding. If a user tries configuring with anything lower than c++17, it will fail at configuration time, instead of at build time.
1 parent 359e3d4 commit ab36e5b

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@
33
cmake_minimum_required(VERSION 3.12)
44
project(rr C CXX ASM)
55

6+
# Require c++17 as minimum
7+
if(NOT DEFINED CMAKE_CXX_STANDARD)
8+
set(CMAKE_CXX_STANDARD 17)
9+
endif()
10+
11+
# Configure so that we use -std=c++17 (as previously done) not -std=gnu++17
12+
if(NOT DEFINED CMAKE_CXX_EXTENSIONS)
13+
set(CMAKE_CXX_EXTENSIONS OFF)
14+
endif()
15+
16+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
17+
18+
# Because `CMAKE_CXX_STANDARD_REQUIRED ON` does not enforce this for us.
19+
if(CMAKE_CXX_STANDARD LESS 17)
20+
message(FATAL_ERROR "C++ standard too low: CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}. Minimum required is C++17.")
21+
endif()
22+
623
# "Do not add flags to export symbols from executables without the ENABLE_EXPORTS target property."
724
# This avoids linking executables with -rdynamic. -rdynamic has been observed
825
# to cause rr_exec_stub to be linked with the dynamic linker with some
@@ -104,7 +121,7 @@ endif()
104121
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS_COMMON} -Wstrict-prototypes -std=gnu11")
105122
# Define __STDC_LIMIT_MACROS so |#include <stdint.h>| works as expected.
106123
# Define __STDC_FORMAT_MACROS so |#include <inttypes.h>| works as expected.
107-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS_COMMON} -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -std=c++17")
124+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS_COMMON} -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS")
108125

109126
# We support three build types:
110127
# DEBUG: suitable for debugging rr

0 commit comments

Comments
 (0)