From 12e6796b6289dbc910b9b7fe57f6b564edbc46dd Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 2 Apr 2018 14:44:39 -0400 Subject: Android: Do not pass non-existent Clang -std flags Android NDK r16b comes with Android clang version 5.0.300080 (based on LLVM 5.0.300080) Although it claims version 5, it does not support the `-std=c++17` or `-std=c++2a` flags that upstream Clang does. Android NDK r17-beta1 comes with Android (4639204 based on r316199) clang version 6.0.1 that does have the flags. --- Modules/Compiler/Clang-CXX.cmake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index 321ddf6..77866e9 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -32,7 +32,12 @@ if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") endif() - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + set(_clang_version_std17 5.0) + if(CMAKE_SYSTEM_NAME STREQUAL "Android") + set(_clang_version_std17 6.0) + endif() + + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}") set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) @@ -40,10 +45,12 @@ if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") endif() - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}") set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") endif() + + unset(_clang_version_std17) else() # clang-cl does not know these options because it behaves like cl.exe set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") -- cgit v0.12