aboutsummaryrefslogtreecommitdiffhomepage
path: root/CMake/TdSetUpCompiler.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'CMake/TdSetUpCompiler.cmake')
-rw-r--r--CMake/TdSetUpCompiler.cmake29
1 files changed, 15 insertions, 14 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")