summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-08-10 19:25:40 (GMT)
committerBrad King <brad.king@kitware.com>2023-08-10 20:31:58 (GMT)
commit2c6fe6487651656327bfb30cfbe9ce5d6e92b250 (patch)
tree8cfe4c0e7b7d4f4a6bcff1673a0a5466b00a5d8d /Modules
parent1368e219d95c471cfc5456172afaca22e5c24c7c (diff)
downloadCMake-2c6fe6487651656327bfb30cfbe9ce5d6e92b250.zip
CMake-2c6fe6487651656327bfb30cfbe9ce5d6e92b250.tar.gz
CMake-2c6fe6487651656327bfb30cfbe9ce5d6e92b250.tar.bz2
NVIDIA-CUDA: Factor out helper for NVCC C++ standard flags
These standard flags will be the same for other C++-derived languages supported by nvcc. Follow the pattern from commit 25439c7d62 (Clang: Refactor CXX standard flags ..., 2020-03-16, v3.18.0-rc1~362^2~4) to factor them into a single macro so we can easily reuse them. Issue: #25143
Diffstat (limited to 'Modules')
-rw-r--r--Modules/Compiler/NVIDIA-CUDA.cmake64
-rw-r--r--Modules/Compiler/NVIDIA.cmake69
2 files changed, 71 insertions, 62 deletions
diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake
index c839d1c..13d8d8e 100644
--- a/Modules/Compiler/NVIDIA-CUDA.cmake
+++ b/Modules/Compiler/NVIDIA-CUDA.cmake
@@ -1,4 +1,5 @@
-include(Compiler/CMakeCommonCompilerMacros)
+include(Compiler/NVIDIA)
+__compiler_nvidia_cxx_standards(CUDA)
set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE True)
set(CMAKE_CUDA_VERBOSE_FLAG "-v")
@@ -98,65 +99,6 @@ if(UNIX AND NOT (CMAKE_SYSTEM_NAME STREQUAL "QNX"))
list(APPEND CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_STATIC "rt" "pthread" "dl")
endif()
-if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
- # MSVC requires c++14 as the minimum level
- set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "")
- set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "")
-
- # MSVC requires c++14 as the minimum level
- set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "")
- set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "")
-
- if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0)
- if(CMAKE_CUDA_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.10.25017)
- set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "-std=c++14")
- set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "-std=c++14")
- else()
- set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "")
- set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "")
- endif()
- endif()
-
- if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.0)
- if(CMAKE_CUDA_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.11.25505)
- set(CMAKE_CUDA17_STANDARD_COMPILE_OPTION "-std=c++17")
- set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17")
- endif()
- endif()
-
- if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 12.0)
- if(CMAKE_CUDA_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.11.25505)
- set(CMAKE_CUDA20_STANDARD_COMPILE_OPTION "-std=c++20")
- set(CMAKE_CUDA20_EXTENSION_COMPILE_OPTION "-std=c++20")
- endif()
- endif()
-
-else()
- 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_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()
-
- if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.0)
- set(CMAKE_CUDA17_STANDARD_COMPILE_OPTION "-std=c++17")
- set(CMAKE_CUDA17_EXTENSION_COMPILE_OPTION "-std=c++17")
- endif()
-
- if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 12.0)
- set(CMAKE_CUDA20_STANDARD_COMPILE_OPTION "-std=c++20")
- set(CMAKE_CUDA20_EXTENSION_COMPILE_OPTION "-std=c++20")
- endif()
-
-endif()
-
if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0")
set(CMAKE_CUDA_RESPONSE_FILE_DEVICE_LINK_FLAG "--options-file ")
set(CMAKE_CUDA_RESPONSE_FILE_FLAG "--options-file ")
@@ -171,5 +113,3 @@ else()
set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_LIBRARIES 0)
set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_OBJECTS 0)
endif()
-
-__compiler_check_default_language_standard(CUDA 6.0 03)
diff --git a/Modules/Compiler/NVIDIA.cmake b/Modules/Compiler/NVIDIA.cmake
new file mode 100644
index 0000000..686c03d
--- /dev/null
+++ b/Modules/Compiler/NVIDIA.cmake
@@ -0,0 +1,69 @@
+
+# This module is shared by multiple languages; use include blocker.
+if(__COMPILER_NVIDIA)
+ return()
+endif()
+set(__COMPILER_NVIDIA 1)
+
+include(Compiler/CMakeCommonCompilerMacros)
+
+macro(__compiler_nvidia_cxx_standards lang)
+ if("x${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "xMSVC")
+ # MSVC requires c++14 as the minimum level
+ set(CMAKE_${lang}03_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_${lang}03_EXTENSION_COMPILE_OPTION "")
+
+ # MSVC requires c++14 as the minimum level
+ set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "")
+
+ if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 9.0)
+ if(CMAKE_${lang}_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.10.25017)
+ set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "-std=c++14")
+ else()
+ set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "")
+ endif()
+ endif()
+
+ if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 11.0)
+ if(CMAKE_${lang}_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.11.25505)
+ set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std=c++17")
+ set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=c++17")
+ endif()
+ endif()
+
+ if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0)
+ if(CMAKE_${lang}_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.11.25505)
+ set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std=c++20")
+ set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=c++20")
+ endif()
+ endif()
+ else()
+ set(CMAKE_${lang}03_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_${lang}03_EXTENSION_COMPILE_OPTION "")
+
+ set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "-std=c++11")
+ set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "-std=c++11")
+
+ if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 9.0)
+ set(CMAKE_${lang}03_STANDARD_COMPILE_OPTION "-std=c++03")
+ set(CMAKE_${lang}03_EXTENSION_COMPILE_OPTION "-std=c++03")
+ set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "-std=c++14")
+ endif()
+
+ if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 11.0)
+ set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std=c++17")
+ set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=c++17")
+ endif()
+
+ if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0)
+ set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std=c++20")
+ set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=c++20")
+ endif()
+ endif()
+
+ __compiler_check_default_language_standard(${lang} 6.0 03)
+endmacro()