Skip to content

Commit e45ede8

Browse files
authored
Suppress MSVC-specific warnings on linux. (#7462)
1 parent 75afb5f commit e45ede8

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

lib/cmake/libcudacxx/libcudacxx-config.cmake

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -150,29 +150,12 @@ function(libcudacxx_update_language_compat_flags)
150150
message(DEBUG "libcudacxx: CMAKE_CUDA_HOST_COMPILER_VERSION: ${CMAKE_CUDA_HOST_COMPILER_VERSION}")
151151
# gersemi: on
152152

153-
if (NOT cxx_warned AND NOT CXX IN_LIST langs)
154-
# gersemi: off
155-
message(VERBOSE "libcudacxx: - CXX language not enabled.")
156-
message(VERBOSE "libcudacxx: /Zc:__cplusplus and /Zc:preprocessor flags may not be automatically added to CXX targets.")
157-
message(VERBOSE "libcudacxx: Call find_package(CCCL) again after enabling CXX to enable compatibility flags.")
158-
# gersemi: on
159-
_libcudacxx_define_internal_global_property(_libcudacxx_cxx_warned)
160-
endif()
161-
162-
if (NOT cuda_warned AND NOT CUDA IN_LIST langs)
163-
# gersemi: off
164-
message(VERBOSE "libcudacxx: - CUDA language not enabled.")
165-
message(VERBOSE "libcudacxx: /Zc:__cplusplus and /Zc:preprocessor flags may not be automatically added to CUDA targets.")
166-
message(VERBOSE "libcudacxx: Call find_package(CCCL) again after enabling CUDA to enable compatibility flags.")
167-
# gersemi: on
168-
_libcudacxx_define_internal_global_property(_libcudacxx_cuda_warned)
169-
endif()
170-
171153
if (CXX IN_LIST langs)
172154
set(msvc_cxx_id ${CMAKE_CXX_COMPILER_ID})
173155
set(msvc_cxx_version ${CMAKE_CXX_COMPILER_VERSION})
174156
endif()
175157

158+
# Best effort detection of CUDA host compiler on all supported CMake versions:
176159
if (CUDA IN_LIST langs)
177160
option(
178161
libcudacxx_MISMATCHED_HOST_COMPILER
@@ -207,6 +190,29 @@ function(libcudacxx_update_language_compat_flags)
207190
# gersemi: on
208191
endif()
209192

193+
# Only MSVC needs these flags. Exit before printing warnings / etc.
194+
if (NOT (msvc_cxx_id STREQUAL "MSVC" OR msvc_cuda_host_id STREQUAL "MSVC"))
195+
return()
196+
endif()
197+
198+
if (NOT cxx_warned AND NOT CXX IN_LIST langs)
199+
# gersemi: off
200+
message(VERBOSE "libcudacxx: - CXX language not enabled.")
201+
message(VERBOSE "libcudacxx: /Zc:__cplusplus and /Zc:preprocessor flags may not be automatically added to CXX targets.")
202+
message(VERBOSE "libcudacxx: Call find_package(CCCL) again after enabling CXX to enable compatibility flags.")
203+
# gersemi: on
204+
_libcudacxx_define_internal_global_property(_libcudacxx_cxx_warned)
205+
endif()
206+
207+
if (NOT cuda_warned AND NOT CUDA IN_LIST langs)
208+
# gersemi: off
209+
message(VERBOSE "libcudacxx: - CUDA language not enabled.")
210+
message(VERBOSE "libcudacxx: /Zc:__cplusplus and /Zc:preprocessor flags may not be automatically added to CUDA targets.")
211+
message(VERBOSE "libcudacxx: Call find_package(CCCL) again after enabling CUDA to enable compatibility flags.")
212+
# gersemi: on
213+
_libcudacxx_define_internal_global_property(_libcudacxx_cuda_warned)
214+
endif()
215+
210216
function(_libcudacxx_get_msvc_flags_for_version out_var msvc_version)
211217
set(flags "/Zc:__cplusplus")
212218
if (msvc_version GREATER_EQUAL 19.25)

0 commit comments

Comments
 (0)