diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2019-11-01 12:12:05 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2019-12-10 22:56:48 (GMT) |
commit | 2467a2b3184595a87e93db510408fc14ddbaf3b9 (patch) | |
tree | 37e35f4a3c821634cc18c6cd8df8acf2391d4f5c /Modules/Compiler | |
parent | f62c674202045f877eaed9da0f9cbe2046452b40 (diff) | |
download | CMake-2467a2b3184595a87e93db510408fc14ddbaf3b9.zip CMake-2467a2b3184595a87e93db510408fc14ddbaf3b9.tar.gz CMake-2467a2b3184595a87e93db510408fc14ddbaf3b9.tar.bz2 |
CUDA: Add cuda meta-features (e.g. ``cuda_std_11``) support
Diffstat (limited to 'Modules/Compiler')
-rw-r--r-- | Modules/Compiler/CMakeCommonCompilerMacros.cmake | 44 | ||||
-rw-r--r-- | Modules/Compiler/NVIDIA-CUDA.cmake | 25 |
2 files changed, 63 insertions, 6 deletions
diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake index 96537f8..409b65a 100644 --- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake +++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake @@ -134,3 +134,47 @@ macro(cmake_record_cxx_compile_features) unset(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT) endif() endmacro() + +macro(cmake_record_cuda_compile_features) + set(_result 0) + if(_result EQUAL 0 AND DEFINED CMAKE_CUDA20_STANDARD_COMPILE_OPTION) + if(CMAKE_CUDA20_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cuda(20) + else() + _record_compiler_features_cuda(20) + endif() + unset(CMAKE_CUDA20_STANDARD__HAS_FULL_SUPPORT) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CUDA17_STANDARD_COMPILE_OPTION) + if(CMAKE_CUDA17_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cuda(17) + else() + _record_compiler_features_cuda(17) + endif() + unset(CMAKE_CUDA17_STANDARD__HAS_FULL_SUPPORT) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CUDA14_STANDARD_COMPILE_OPTION) + if(CMAKE_CUDA14_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cuda(14) + else() + _record_compiler_features_cuda(14) + endif() + unset(CMAKE_CUDA14_STANDARD__HAS_FULL_SUPPORT) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CUDA11_STANDARD_COMPILE_OPTION) + if(CMAKE_CUDA11_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cuda(11) + else() + _record_compiler_features_cuda(11) + endif() + unset(CMAKE_CUDA11_STANDARD__HAS_FULL_SUPPORT) + endif() + if(_result EQUAL 0 AND DEFINED CMAKE_CUDA03_STANDARD_COMPILE_OPTION) + if(CMAKE_CUDA03_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cuda(03) + else() + _record_compiler_features_cuda(03) + endif() + unset(CMAKE_CUDA03_STANDARD__HAS_FULL_SUPPORT) + endif() +endmacro() diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index 2b24fa5..ad7f084 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -1,3 +1,5 @@ +include(Compiler/CMakeCommonCompilerMacros) + set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE True) set(CMAKE_CUDA_VERBOSE_FLAG "-v") set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v") @@ -42,17 +44,26 @@ set(CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS -shared) set(CMAKE_INCLUDE_SYSTEM_FLAG_CUDA -isystem=) if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC") - set(CMAKE_CUDA_STANDARD_DEFAULT "") + set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "") + set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "") + + set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "") + set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "") + + if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0) + set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "") + set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "") + endif() else() - set(CMAKE_CUDA_STANDARD_DEFAULT 98) - set(CMAKE_CUDA98_STANDARD_COMPILE_OPTION "") - set(CMAKE_CUDA98_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "") + set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "-std=c++11") if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0) - set(CMAKE_CUDA98_STANDARD_COMPILE_OPTION "-std=c++03") - set(CMAKE_CUDA98_EXTENSION_COMPILE_OPTION "-std=c++03") + set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "-std=c++03") + set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "-std=c++03") set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "-std=c++14") endif() @@ -69,3 +80,5 @@ if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0") set(CMAKE_CUDA_RESPONSE_FILE_LINK_FLAG "--options-file ") set(CMAKE_CUDA_RESPONSE_FILE_FLAG "--options-file ") endif() + +__compiler_check_default_language_standard(CUDA 6.0 03) |