NVIDIA-CUDA.cmake 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. include(Compiler/CMakeCommonCompilerMacros)
  2. set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE True)
  3. set(CMAKE_CUDA_VERBOSE_FLAG "-v")
  4. set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v")
  5. set(_CMAKE_COMPILE_AS_CUDA_FLAG "-x cu")
  6. if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 10.2.89)
  7. # The -forward-unknown-to-host-compiler flag was only
  8. # added to nvcc in 10.2 so before that we had no good
  9. # way to invoke the CUDA compiler and propagate unknown
  10. # flags such as -pthread to the host compiler
  11. set(_CMAKE_CUDA_EXTRA_FLAGS "-forward-unknown-to-host-compiler")
  12. else()
  13. set(_CMAKE_CUDA_EXTRA_FLAGS "")
  14. endif()
  15. if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")
  16. set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets")
  17. else()
  18. set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "")
  19. endif()
  20. if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 10.2.89)
  21. # The -MD flag was only added to nvcc in 10.2 so
  22. # before that we had to invoke the compiler twice
  23. # to get header dependency information
  24. set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT <OBJECT> -MF <DEPFILE>")
  25. endif()
  26. if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
  27. set(CMAKE_CUDA_COMPILE_OPTIONS_PIE -Xcompiler=-fPIE)
  28. set(CMAKE_CUDA_COMPILE_OPTIONS_PIC -Xcompiler=-fPIC)
  29. set(CMAKE_CUDA_COMPILE_OPTIONS_VISIBILITY -Xcompiler=-fvisibility=)
  30. # CMAKE_SHARED_LIBRARY_CUDA_FLAGS is sent to the host linker so we
  31. # don't need to forward it through nvcc.
  32. set(CMAKE_SHARED_LIBRARY_CUDA_FLAGS -fPIC)
  33. string(APPEND CMAKE_CUDA_FLAGS_INIT " ")
  34. string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -g")
  35. string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -O3 -DNDEBUG")
  36. string(APPEND CMAKE_CUDA_FLAGS_MINSIZEREL_INIT " -O1 -DNDEBUG")
  37. string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG")
  38. endif()
  39. set(CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS -shared)
  40. set(CMAKE_INCLUDE_SYSTEM_FLAG_CUDA -isystem=)
  41. set(CMAKE_CUDA_RUNTIME_LIBRARY_DEFAULT "STATIC")
  42. set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_STATIC "cudadevrt;cudart_static")
  43. set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_SHARED "cudadevrt;cudart")
  44. set(CMAKE_CUDA_RUNTIME_LIBRARY_LINK_OPTIONS_NONE "")
  45. if("x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
  46. set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "")
  47. set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "")
  48. set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "")
  49. set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "")
  50. if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0)
  51. set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "")
  52. set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "")
  53. endif()
  54. else()
  55. set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "")
  56. set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "")
  57. set(CMAKE_CUDA11_STANDARD_COMPILE_OPTION "-std=c++11")
  58. set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "-std=c++11")
  59. if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0)
  60. set(CMAKE_CUDA03_STANDARD_COMPILE_OPTION "-std=c++03")
  61. set(CMAKE_CUDA03_EXTENSION_COMPILE_OPTION "-std=c++03")
  62. set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "-std=c++14")
  63. set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "-std=c++14")
  64. endif()
  65. endif()
  66. # FIXME: investigate use of --options-file.
  67. # Tell Makefile generator that nvcc does not support @<rspfile> syntax.
  68. set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_INCLUDES 0)
  69. set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_LIBRARIES 0)
  70. set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_OBJECTS 0)
  71. if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0")
  72. set(CMAKE_CUDA_RESPONSE_FILE_DEVICE_LINK_FLAG "--options-file ")
  73. set(CMAKE_CUDA_RESPONSE_FILE_FLAG "--options-file ")
  74. endif()
  75. __compiler_check_default_language_standard(CUDA 6.0 03)