CMakeDetermineCUDACompiler.cmake 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
  4. if( NOT ( ("${CMAKE_GENERATOR}" MATCHES "Make") OR
  5. ("${CMAKE_GENERATOR}" MATCHES "Ninja") ) )
  6. message(FATAL_ERROR "CUDA language not currently supported by \"${CMAKE_GENERATOR}\" generator")
  7. endif()
  8. if(NOT CMAKE_CUDA_COMPILER)
  9. set(CMAKE_CUDA_COMPILER_INIT NOTFOUND)
  10. # finally list compilers to try
  11. if(NOT CMAKE_CUDA_COMPILER_INIT)
  12. set(CMAKE_CUDA_COMPILER_LIST nvcc)
  13. endif()
  14. _cmake_find_compiler(CUDA)
  15. else()
  16. _cmake_find_compiler_path(CUDA)
  17. endif()
  18. mark_as_advanced(CMAKE_CUDA_COMPILER)
  19. # Build a small source file to identify the compiler.
  20. if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
  21. set(CMAKE_CUDA_COMPILER_ID_RUN 1)
  22. # Try to identify the compiler.
  23. set(CMAKE_CUDA_COMPILER_ID)
  24. set(CMAKE_CUDA_PLATFORM_ID)
  25. file(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in
  26. CMAKE_CUDA_COMPILER_ID_PLATFORM_CONTENT)
  27. list(APPEND CMAKE_CUDA_COMPILER_ID_MATCH_VENDORS NVIDIA)
  28. set(CMAKE_CUDA_COMPILER_ID_MATCH_VENDOR_REGEX_NVIDIA "nvcc: NVIDIA \(R\) Cuda compiler driver")
  29. set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdCUDA/(\\./)?(CompilerIdCUDA.xctest/)?CompilerIdCUDA[ \t\n\\\"]")
  30. set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_INDEX 2)
  31. include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
  32. CMAKE_DETERMINE_COMPILER_ID(CUDA CUDAFLAGS CMakeCUDACompilerId.cu)
  33. endif()
  34. include(CMakeFindBinUtils)
  35. # configure all variables set in this file
  36. configure_file(${CMAKE_ROOT}/Modules/CMakeCUDACompiler.cmake.in
  37. ${CMAKE_PLATFORM_INFO_DIR}/CMakeCUDACompiler.cmake
  38. @ONLY
  39. )
  40. set(CMAKE_CUDA_COMPILER_ENV_VAR "CUDACXX")