mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
CUDA, CXX, OBJCXX: C++23 support with Clang 12
Clang 12 landed initial support for C++23 language mode flag -std={c|gnu}++2b in commit 6627a3c2873fdf7ccba1a1573371079be48b36e8.
This commit is contained in:
@@ -30,3 +30,6 @@ The features known to this version of CMake are:
|
||||
|
||||
``cuda_std_20``
|
||||
Compiler mode is at least CUDA/C++ 20.
|
||||
|
||||
``cuda_std_23``
|
||||
Compiler mode is at least CUDA/C++ 23.
|
||||
|
@@ -37,6 +37,8 @@ but it does not necessarily imply complete conformance to that standard.
|
||||
``cxx_std_20``
|
||||
Compiler mode is at least C++ 20.
|
||||
|
||||
``cxx_std_23``
|
||||
Compiler mode is at least C++ 23.
|
||||
|
||||
Low level individual compile features
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@@ -9,7 +9,7 @@ This property specifies the CUDA/C++ standard whose features are requested
|
||||
to build this target. For some compilers, this results in adding a
|
||||
flag such as ``-std=gnu++11`` to the compile line.
|
||||
|
||||
Supported values are ``98``, ``03``, ``11``, ``14``, ``17``, ``20``.
|
||||
Supported values are ``98``, ``03``, ``11``, ``14``, ``17``, ``20``, ``23``.
|
||||
|
||||
If the value requested does not result in a compile flag being added for
|
||||
the compiler in use, a previous standard flag will be added instead. This
|
||||
|
@@ -11,7 +11,7 @@ flag such as ``-std=gnu++11`` to the compile line. For compilers that
|
||||
have no notion of a standard level, such as Microsoft Visual C++ before
|
||||
2015 Update 3, this has no effect.
|
||||
|
||||
Supported values are ``98``, ``11``, ``14``, ``17``, and ``20``.
|
||||
Supported values are ``98``, ``11``, ``14``, ``17``, ``20``, ``23``.
|
||||
|
||||
If the value requested does not result in a compile flag being added for
|
||||
the compiler in use, a previous standard flag will be added instead. This
|
||||
|
@@ -9,7 +9,7 @@ This property specifies the ObjC++ standard whose features are requested
|
||||
to build this target. For some compilers, this results in adding a
|
||||
flag such as ``-std=gnu++11`` to the compile line.
|
||||
|
||||
Supported values are ``98``, ``11``, ``14``, ``17``, and ``20``.
|
||||
Supported values are ``98``, ``11``, ``14``, ``17``, ``20``, ``23``.
|
||||
|
||||
If the value requested does not result in a compile flag being added for
|
||||
the compiler in use, a previous standard flag will be added instead. This
|
||||
|
7
Help/release/dev/cpp-cuda-23.rst
Normal file
7
Help/release/dev/cpp-cuda-23.rst
Normal file
@@ -0,0 +1,7 @@
|
||||
cpp-cuda-23
|
||||
-----------
|
||||
|
||||
* :prop_tgt:`CXX_STANDARD`, :prop_tgt:`CUDA_STANDARD`,
|
||||
:prop_tgt:`OBJCXX_STANDARD` and the
|
||||
:manual:`Compile Features <cmake-compile-features(7)>` functionality gained
|
||||
support for C++23.
|
@@ -12,6 +12,7 @@ set(CMAKE_CUDA11_COMPILE_FEATURES "@CMAKE_CUDA11_COMPILE_FEATURES@")
|
||||
set(CMAKE_CUDA14_COMPILE_FEATURES "@CMAKE_CUDA14_COMPILE_FEATURES@")
|
||||
set(CMAKE_CUDA17_COMPILE_FEATURES "@CMAKE_CUDA17_COMPILE_FEATURES@")
|
||||
set(CMAKE_CUDA20_COMPILE_FEATURES "@CMAKE_CUDA20_COMPILE_FEATURES@")
|
||||
set(CMAKE_CUDA23_COMPILE_FEATURES "@CMAKE_CUDA23_COMPILE_FEATURES@")
|
||||
|
||||
set(CMAKE_CUDA_PLATFORM_ID "@CMAKE_CUDA_PLATFORM_ID@")
|
||||
set(CMAKE_CUDA_SIMULATE_ID "@CMAKE_CUDA_SIMULATE_ID@")
|
||||
|
@@ -17,7 +17,9 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
|
||||
@CMAKE_CUDA_COMPILER_ID_ERROR_FOR_TEST@
|
||||
|
||||
const char* info_language_dialect_default = "INFO" ":" "dialect_default["
|
||||
#if __cplusplus > 201703L
|
||||
#if __cplusplus > 202002L
|
||||
"23"
|
||||
#elif __cplusplus > 201703L
|
||||
"20"
|
||||
#elif __cplusplus >= 201703L
|
||||
"17"
|
||||
|
@@ -11,6 +11,7 @@ set(CMAKE_CXX11_COMPILE_FEATURES "@CMAKE_CXX11_COMPILE_FEATURES@")
|
||||
set(CMAKE_CXX14_COMPILE_FEATURES "@CMAKE_CXX14_COMPILE_FEATURES@")
|
||||
set(CMAKE_CXX17_COMPILE_FEATURES "@CMAKE_CXX17_COMPILE_FEATURES@")
|
||||
set(CMAKE_CXX20_COMPILE_FEATURES "@CMAKE_CXX20_COMPILE_FEATURES@")
|
||||
set(CMAKE_CXX23_COMPILE_FEATURES "@CMAKE_CXX23_COMPILE_FEATURES@")
|
||||
|
||||
set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@")
|
||||
set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@")
|
||||
|
@@ -44,7 +44,9 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
|
||||
#endif
|
||||
|
||||
const char* info_language_dialect_default = "INFO" ":" "dialect_default["
|
||||
#if CXX_STD > 201703L
|
||||
#if CXX_STD > 202002L
|
||||
"23"
|
||||
#elif CXX_STD > 201703L
|
||||
"20"
|
||||
#elif CXX_STD >= 201703L
|
||||
"17"
|
||||
|
@@ -50,6 +50,7 @@ function(cmake_determine_compile_features lang)
|
||||
set(CMAKE_CXX14_COMPILE_FEATURES)
|
||||
set(CMAKE_CXX17_COMPILE_FEATURES)
|
||||
set(CMAKE_CXX20_COMPILE_FEATURES)
|
||||
set(CMAKE_CXX23_COMPILE_FEATURES)
|
||||
|
||||
include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
|
||||
|
||||
@@ -60,6 +61,9 @@ function(cmake_determine_compile_features lang)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX20_COMPILE_FEATURES AND CMAKE_CXX23_COMPILE_FEATURES)
|
||||
list(REMOVE_ITEM CMAKE_CXX23_COMPILE_FEATURES ${CMAKE_CXX20_COMPILE_FEATURES})
|
||||
endif()
|
||||
if (CMAKE_CXX17_COMPILE_FEATURES AND CMAKE_CXX20_COMPILE_FEATURES)
|
||||
list(REMOVE_ITEM CMAKE_CXX20_COMPILE_FEATURES ${CMAKE_CXX17_COMPILE_FEATURES})
|
||||
endif()
|
||||
@@ -80,6 +84,7 @@ function(cmake_determine_compile_features lang)
|
||||
${CMAKE_CXX14_COMPILE_FEATURES}
|
||||
${CMAKE_CXX17_COMPILE_FEATURES}
|
||||
${CMAKE_CXX20_COMPILE_FEATURES}
|
||||
${CMAKE_CXX23_COMPILE_FEATURES}
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -89,6 +94,7 @@ function(cmake_determine_compile_features lang)
|
||||
set(CMAKE_CXX14_COMPILE_FEATURES ${CMAKE_CXX14_COMPILE_FEATURES} PARENT_SCOPE)
|
||||
set(CMAKE_CXX17_COMPILE_FEATURES ${CMAKE_CXX17_COMPILE_FEATURES} PARENT_SCOPE)
|
||||
set(CMAKE_CXX20_COMPILE_FEATURES ${CMAKE_CXX20_COMPILE_FEATURES} PARENT_SCOPE)
|
||||
set(CMAKE_CXX23_COMPILE_FEATURES ${CMAKE_CXX23_COMPILE_FEATURES} PARENT_SCOPE)
|
||||
|
||||
message(CHECK_PASS "done")
|
||||
|
||||
@@ -100,6 +106,7 @@ function(cmake_determine_compile_features lang)
|
||||
set(CMAKE_CUDA14_COMPILE_FEATURES)
|
||||
set(CMAKE_CUDA17_COMPILE_FEATURES)
|
||||
set(CMAKE_CUDA20_COMPILE_FEATURES)
|
||||
set(CMAKE_CUDA23_COMPILE_FEATURES)
|
||||
|
||||
include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
|
||||
|
||||
@@ -110,7 +117,10 @@ function(cmake_determine_compile_features lang)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (CMAKE_CUDA17_COMPILE_FEATURES AND CMAKE_CUDA20_COMPILE_FEATURES)
|
||||
if (CMAKE_CUDA20_COMPILE_FEATURES AND CMAKE_CUDA23_COMPILE_FEATURES)
|
||||
list(REMOVE_ITEM CMAKE_CUDA23_COMPILE_FEATURES ${CMAKE_CUDA20_COMPILE_FEATURES})
|
||||
endif()
|
||||
if (CMAKE_CUDA17_COMPILE_FEATURES AND CMAKE_CUDA20_COMPILE_FEATURES)
|
||||
list(REMOVE_ITEM CMAKE_CUDA20_COMPILE_FEATURES ${CMAKE_CUDA17_COMPILE_FEATURES})
|
||||
endif()
|
||||
if (CMAKE_CUDA14_COMPILE_FEATURES AND CMAKE_CUDA17_COMPILE_FEATURES)
|
||||
@@ -130,6 +140,7 @@ function(cmake_determine_compile_features lang)
|
||||
${CMAKE_CUDA14_COMPILE_FEATURES}
|
||||
${CMAKE_CUDA17_COMPILE_FEATURES}
|
||||
${CMAKE_CUDA20_COMPILE_FEATURES}
|
||||
${CMAKE_CUDA23_COMPILE_FEATURES}
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -139,6 +150,7 @@ function(cmake_determine_compile_features lang)
|
||||
set(CMAKE_CUDA14_COMPILE_FEATURES ${CMAKE_CUDA14_COMPILE_FEATURES} PARENT_SCOPE)
|
||||
set(CMAKE_CUDA17_COMPILE_FEATURES ${CMAKE_CUDA17_COMPILE_FEATURES} PARENT_SCOPE)
|
||||
set(CMAKE_CUDA20_COMPILE_FEATURES ${CMAKE_CUDA20_COMPILE_FEATURES} PARENT_SCOPE)
|
||||
set(CMAKE_CUDA23_COMPILE_FEATURES ${CMAKE_CUDA23_COMPILE_FEATURES} PARENT_SCOPE)
|
||||
|
||||
message(CHECK_PASS "done")
|
||||
|
||||
|
@@ -11,6 +11,7 @@ set(CMAKE_OBJCXX11_COMPILE_FEATURES "@CMAKE_OBJCXX11_COMPILE_FEATURES@")
|
||||
set(CMAKE_OBJCXX14_COMPILE_FEATURES "@CMAKE_OBJCXX14_COMPILE_FEATURES@")
|
||||
set(CMAKE_OBJCXX17_COMPILE_FEATURES "@CMAKE_OBJCXX17_COMPILE_FEATURES@")
|
||||
set(CMAKE_OBJCXX20_COMPILE_FEATURES "@CMAKE_OBJCXX20_COMPILE_FEATURES@")
|
||||
set(CMAKE_OBJCXX23_COMPILE_FEATURES "@CMAKE_OBJCXX23_COMPILE_FEATURES@")
|
||||
|
||||
set(CMAKE_OBJCXX_PLATFORM_ID "@CMAKE_OBJCXX_PLATFORM_ID@")
|
||||
set(CMAKE_OBJCXX_SIMULATE_ID "@CMAKE_OBJCXX_SIMULATE_ID@")
|
||||
|
@@ -30,7 +30,9 @@ char const* qnxnto = "INFO" ":" "qnxnto[]";
|
||||
#endif
|
||||
|
||||
const char* info_language_dialect_default = "INFO" ":" "dialect_default["
|
||||
#if CXX_STD > 201703L
|
||||
#if CXX_STD > 202002L
|
||||
"23"
|
||||
#elfif CXX_STD > 201703L
|
||||
"20"
|
||||
#elif CXX_STD >= 201703L
|
||||
"17"
|
||||
|
@@ -93,6 +93,9 @@ endmacro()
|
||||
# Define to allow compile features to be automatically determined
|
||||
macro(cmake_record_cxx_compile_features)
|
||||
set(_result 0)
|
||||
if(_result EQUAL 0 AND DEFINED CMAKE_CXX23_STANDARD_COMPILE_OPTION)
|
||||
_has_compiler_features_cxx(23)
|
||||
endif()
|
||||
if(_result EQUAL 0 AND DEFINED CMAKE_CXX20_STANDARD_COMPILE_OPTION)
|
||||
_has_compiler_features_cxx(20)
|
||||
endif()
|
||||
@@ -127,6 +130,9 @@ endmacro()
|
||||
|
||||
macro(cmake_record_cuda_compile_features)
|
||||
set(_result 0)
|
||||
if(_result EQUAL 0 AND DEFINED CMAKE_CUDA23_STANDARD_COMPILE_OPTION)
|
||||
_has_compiler_features_cuda(23)
|
||||
endif()
|
||||
if(_result EQUAL 0 AND DEFINED CMAKE_CUDA20_STANDARD_COMPILE_OPTION)
|
||||
_has_compiler_features_cuda(20)
|
||||
endif()
|
||||
|
@@ -165,6 +165,11 @@ macro(__compiler_clang_cxx_standards lang)
|
||||
|
||||
unset(_clang_version_std17)
|
||||
|
||||
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0)
|
||||
set(CMAKE_${lang}23_STANDARD_COMPILE_OPTION "-std=c++2b")
|
||||
set(CMAKE_${lang}23_EXTENSION_COMPILE_OPTION "-std=gnu++2b")
|
||||
endif()
|
||||
|
||||
if("x${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||
# The MSVC standard library requires C++14, and MSVC itself has no
|
||||
# notion of operating in a mode not aware of at least that standard.
|
||||
@@ -215,6 +220,8 @@ macro(__compiler_clang_cxx_standards lang)
|
||||
set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "")
|
||||
set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "")
|
||||
set(CMAKE_${lang}23_STANDARD_COMPILE_OPTION "")
|
||||
set(CMAKE_${lang}23_EXTENSION_COMPILE_OPTION "")
|
||||
|
||||
# There is no meaningful default for this
|
||||
set(CMAKE_${lang}_STANDARD_DEFAULT "")
|
||||
@@ -230,6 +237,7 @@ macro(__compiler_clang_cxx_standards lang)
|
||||
cxx_std_14
|
||||
cxx_std_17
|
||||
cxx_std_20
|
||||
cxx_std_23
|
||||
)
|
||||
_record_compiler_features(${lang} "" CMAKE_${lang}_COMPILE_FEATURES)
|
||||
endmacro()
|
||||
|
@@ -311,19 +311,19 @@ std::unordered_map<std::string, StanardLevelComputer> StandardComputerMapping =
|
||||
std::vector<std::string>{ "90", "99", "11" } } },
|
||||
{ "CXX",
|
||||
StanardLevelComputer{
|
||||
"CXX", std::vector<int>{ 98, 11, 14, 17, 20 },
|
||||
std::vector<std::string>{ "98", "11", "14", "17", "20" } } },
|
||||
"CXX", std::vector<int>{ 98, 11, 14, 17, 20, 23 },
|
||||
std::vector<std::string>{ "98", "11", "14", "17", "20", "23" } } },
|
||||
{ "CUDA",
|
||||
StanardLevelComputer{
|
||||
"CUDA", std::vector<int>{ 03, 11, 14, 17, 20 },
|
||||
std::vector<std::string>{ "03", "11", "14", "17", "20" } } },
|
||||
"CUDA", std::vector<int>{ 03, 11, 14, 17, 20, 23 },
|
||||
std::vector<std::string>{ "03", "11", "14", "17", "20", "23" } } },
|
||||
{ "OBJC",
|
||||
StanardLevelComputer{ "OBJC", std::vector<int>{ 90, 99, 11 },
|
||||
std::vector<std::string>{ "90", "99", "11" } } },
|
||||
{ "OBJCXX",
|
||||
StanardLevelComputer{
|
||||
"OBJCXX", std::vector<int>{ 98, 11, 14, 17, 20 },
|
||||
std::vector<std::string>{ "98", "11", "14", "17", "20" } } },
|
||||
"OBJCXX", std::vector<int>{ 98, 11, 14, 17, 20, 23 },
|
||||
std::vector<std::string>{ "98", "11", "14", "17", "20", "23" } } },
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -811,6 +811,7 @@ private:
|
||||
F(cxx_std_14) \
|
||||
F(cxx_std_17) \
|
||||
F(cxx_std_20) \
|
||||
F(cxx_std_23) \
|
||||
FOR_EACH_CXX98_FEATURE(F) \
|
||||
FOR_EACH_CXX11_FEATURE(F) \
|
||||
FOR_EACH_CXX14_FEATURE(F)
|
||||
@@ -820,4 +821,5 @@ private:
|
||||
F(cuda_std_11) \
|
||||
F(cuda_std_14) \
|
||||
F(cuda_std_17) \
|
||||
F(cuda_std_20)
|
||||
F(cuda_std_20) \
|
||||
F(cuda_std_23)
|
||||
|
@@ -268,6 +268,7 @@ if (CMAKE_CXX_COMPILE_FEATURES)
|
||||
if (std_flag_idx EQUAL -1)
|
||||
add_executable(default_dialect default_dialect.cpp)
|
||||
target_compile_definitions(default_dialect PRIVATE
|
||||
DEFAULT_CXX23=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},23>
|
||||
DEFAULT_CXX20=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},20>
|
||||
DEFAULT_CXX17=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},17>
|
||||
DEFAULT_CXX14=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},14>
|
||||
@@ -349,6 +350,7 @@ else()
|
||||
HAVE_CXX_STD_14=$<COMPILE_FEATURES:cxx_std_14>
|
||||
HAVE_CXX_STD_17=$<COMPILE_FEATURES:cxx_std_17>
|
||||
HAVE_CXX_STD_20=$<COMPILE_FEATURES:cxx_std_20>
|
||||
HAVE_CXX_STD_23=$<COMPILE_FEATURES:cxx_std_23>
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@@ -18,7 +18,11 @@ struct Outputter;
|
||||
# define CXX_STD __cplusplus
|
||||
#endif
|
||||
|
||||
#if DEFAULT_CXX20
|
||||
#if DEFAULT_CXX23
|
||||
# if CXX_STD <= 202002L
|
||||
Outputter<CXX_STD> o;
|
||||
# endif
|
||||
#elif DEFAULT_CXX20
|
||||
# if CXX_STD <= 201703L
|
||||
Outputter<CXX_STD> o;
|
||||
# endif
|
||||
|
@@ -21,6 +21,12 @@
|
||||
# if HAVE_CXX_STD_17 && !defined(ALLOW_LATER_STANDARDS)
|
||||
# error HAVE_CXX_STD_17 is true with CXX_STANDARD == 11
|
||||
# endif
|
||||
# if HAVE_CXX_STD_20 && !defined(ALLOW_LATER_STANDARDS)
|
||||
# error HAVE_CXX_STD_20 is true with CXX_STANDARD == 11
|
||||
# endif
|
||||
# if HAVE_CXX_STD_23 && !defined(ALLOW_LATER_STANDARDS)
|
||||
# error HAVE_CXX_STD_23 is true with CXX_STANDARD == 11
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !HAVE_OVERRIDE_CONTROL
|
||||
|
Reference in New Issue
Block a user