a85df711e6d8d722b1b1415ca65fb350ef79a765
[platform/upstream/cmake.git] / Modules / Compiler / NVHPC.cmake
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
3
4
5 # This module is shared by multiple languages; use include blocker.
6 if(__COMPILER_NVHPC)
7   return()
8 endif()
9 set(__COMPILER_NVHPC 1)
10
11 include(Compiler/PGI)
12
13 macro(__compiler_nvhpc lang)
14   # Logic specific to NVHPC.
15
16   if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 21.07)
17     set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <DEP_TARGET> -MF <DEP_FILE>")
18     set(CMAKE_${lang}_DEPFILE_FORMAT gcc)
19     set(CMAKE_${lang}_DEPENDS_USE_COMPILER TRUE)
20   else()
21     # Before NVHPC 21.07 the `-MD` flag implicitly
22     # implies `-E` and therefore compilation and dependency generation
23     # can't occur in the same invocation
24     set(CMAKE_${lang}_DEPENDS_EXTRA_COMMANDS "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> ${CMAKE_${lang}_COMPILE_OPTIONS_EXPLICIT_LANGUAGE} -M <SOURCE> -MT <OBJECT> -MD<DEP_FILE>")
25   endif()
26
27 endmacro()