diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2016-08-26 20:59:36 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2016-11-14 16:36:42 (GMT) |
commit | f8aac21947f43a0e886a3cc3655514abb95bb260 (patch) | |
tree | a257ad0211362ab635e3b09922ec143eba1827a3 /Modules/CMakeDetermineCUDACompiler.cmake | |
parent | 4a4be0301bd9c6062738e87892cbe5bd8d900a49 (diff) | |
download | CMake-f8aac21947f43a0e886a3cc3655514abb95bb260.zip CMake-f8aac21947f43a0e886a3cc3655514abb95bb260.tar.gz CMake-f8aac21947f43a0e886a3cc3655514abb95bb260.tar.bz2 |
CUDA: Add basic CUDA language support for *NIX systems.
Diffstat (limited to 'Modules/CMakeDetermineCUDACompiler.cmake')
-rw-r--r-- | Modules/CMakeDetermineCUDACompiler.cmake | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake new file mode 100644 index 0000000..fd87358 --- /dev/null +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -0,0 +1,49 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) + +if( NOT ( ("${CMAKE_GENERATOR}" MATCHES "Make") OR + ("${CMAKE_GENERATOR}" MATCHES "Ninja") ) ) + message(FATAL_ERROR "CUDA language not currently supported by \"${CMAKE_GENERATOR}\" generator") +endif() + +if(NOT CMAKE_CUDA_COMPILER) + set(CMAKE_CUDA_COMPILER_INIT NOTFOUND) + + # finally list compilers to try + if(NOT CMAKE_CUDA_COMPILER_INIT) + set(CMAKE_CUDA_COMPILER_LIST nvcc) + endif() + + _cmake_find_compiler(CUDA) +else() + _cmake_find_compiler_path(CUDA) +endif() + +mark_as_advanced(CMAKE_CUDA_COMPILER) + +# Build a small source file to identify the compiler. +if(NOT CMAKE_CUDA_COMPILER_ID_RUN) + set(CMAKE_CUDA_COMPILER_ID_RUN 1) + + list(APPEND CMAKE_CUDA_COMPILER_ID_MATCH_VENDORS NVidia) + set(CMAKE_CUDA_COMPILER_ID_MATCH_VENDOR_REGEX_NVidia "nvcc: NVIDIA \(R\) Cuda compiler driver") + + set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdCXX/(\\./)?(CompilerIdCXX.xctest/)?CompilerIdCXX[ \t\n\\\"]") + set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_INDEX 2) + + include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) + CMAKE_DETERMINE_COMPILER_ID(CUDA CUDAFLAGS CMakeCUDACompilerId.cu) + +endif() + +include(CMakeFindBinUtils) + +# configure all variables set in this file +configure_file(${CMAKE_ROOT}/Modules/CMakeCUDACompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeCUDACompiler.cmake + @ONLY + ) + +set(CMAKE_CUDA_COMPILER_ENV_VAR "CUDACXX") |