diff options
| author | levlam <levlam@telegram.org> | 2025-02-13 20:31:15 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2025-02-13 20:31:15 +0300 |
| commit | 5beadff4489b4e71246208f7c866ed4650d69d77 (patch) | |
| tree | 838a62e503f7f23611e9081fd80f31120c1ca02c | |
| parent | 051b1d4d32a315e59ce87cfafab350887843de8c (diff) | |
Require a C++17-compatible compiler.
| -rw-r--r-- | CMake/TdSetUpCompiler.cmake | 29 | ||||
| -rw-r--r-- | README.md | 2 |
2 files changed, 16 insertions, 15 deletions
diff --git a/CMake/TdSetUpCompiler.cmake b/CMake/TdSetUpCompiler.cmake index 747d0aaa7..be0b57ef5 100644 --- a/CMake/TdSetUpCompiler.cmake +++ b/CMake/TdSetUpCompiler.cmake @@ -1,4 +1,4 @@ -# Configures C++14 compiler, setting TDLib-specific compilation options. +# Configures C++17 compiler, setting TDLib-specific compilation options. function(td_set_up_compiler) set(CMAKE_EXPORT_COMPILE_COMMANDS 1 PARENT_SCOPE) @@ -24,22 +24,23 @@ function(td_set_up_compiler) if (GCC OR CLANG OR INTEL) if (WIN32 AND INTEL) - set(STD14_FLAG /Qstd=c++14) + set(STD17_FLAG /Qstd=c++17) else() - set(STD14_FLAG -std=c++14) + set(STD17_FLAG -std=c++17) endif() - check_cxx_compiler_flag(${STD14_FLAG} HAVE_STD14) - if (NOT HAVE_STD14) - string(REPLACE "c++14" "c++1y" STD14_FLAG "${STD14_FLAG}") - check_cxx_compiler_flag(${STD14_FLAG} HAVE_STD1Y) - set(HAVE_STD14 ${HAVE_STD1Y}) + if (GCC AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)) + message(FATAL_ERROR "No C++17 support in the compiler. Please upgrade the compiler to at least GCC 7.0.") endif() + if (CLANG AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)) + message(FATAL_ERROR "No C++17 support in the compiler. Please upgrade the compiler to at least clang 5.0.") + endif() + check_cxx_compiler_flag(${STD17_FLAG} HAVE_STD17) elseif (MSVC) - set(HAVE_STD14 MSVC_VERSION>=1900) + set(HAVE_STD17 MSVC_VERSION>=1914) # MSVC 2017 version 15.7 endif() - if (NOT HAVE_STD14) - message(FATAL_ERROR "No C++14 support in the compiler. Please upgrade the compiler.") + if (NOT HAVE_STD17) + message(FATAL_ERROR "No C++17 support in the compiler. Please upgrade the compiler.") endif() if (MSVC) @@ -49,7 +50,7 @@ function(td_set_up_compiler) add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /GR- /W4 /wd4100 /wd4127 /wd4324 /wd4505 /wd4814 /wd4702 /bigobj") elseif (CLANG OR GCC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STD14_FLAG} -fno-omit-frame-pointer -fno-exceptions -fno-rtti") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STD17_FLAG} -fno-omit-frame-pointer -fno-exceptions -fno-rtti") if (APPLE) set(TD_LINKER_FLAGS "-Wl,-dead_strip") if (NOT CMAKE_BUILD_TYPE MATCHES "Deb") @@ -77,7 +78,7 @@ function(td_set_up_compiler) endif() endif() elseif (INTEL) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STD14_FLAG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STD17_FLAG}") endif() if (WIN32) @@ -119,7 +120,7 @@ function(td_set_up_compiler) add_cxx_compiler_flag("-Wno-unused-parameter") add_cxx_compiler_flag("-Wconversion") add_cxx_compiler_flag("-Wno-sign-conversion") - add_cxx_compiler_flag("-Wc++14-compat-pedantic") + add_cxx_compiler_flag("-Wc++17-compat-pedantic") add_cxx_compiler_flag("-Wdeprecated") add_cxx_compiler_flag("-Wno-unused-command-line-argument") add_cxx_compiler_flag("-Qunused-arguments") @@ -45,7 +45,7 @@ for a list of all available `TDLib` [methods](https://core.telegram.org/tdlib/do ## Dependencies `TDLib` depends on: -* C++14 compatible compiler (Clang 3.4+, GCC 4.9+, MSVC 19.0+ (Visual Studio 2015+), Intel C++ Compiler 17+) +* C++17 compatible compiler (Clang 5.0+, GCC 7.0+, MSVC 19.1+ (Visual Studio 2017.7+), Intel C++ Compiler 19+) * OpenSSL * zlib * gperf (build only) |
