From 14c5dab2e63e5ad55414b45a2b535f396d6b394a Mon Sep 17 00:00:00 2001 From: luncliff Date: Thu, 29 Aug 2019 00:50:43 +0900 Subject: [PATCH] test cuda: checks NVCC and CUDA The header file checks 2 things. * __NVCC__: if the compiler is from NVIDIA * __CUDACC__: if the source code is CUDA(.cu) file Since we can't sure all users prefer latest, Version for `find_pacakge(CUDA)` is downgraded to 9.0. This is the minimum version for C++14 in CUDA --- include/fmt/core.h | 8 ++++++++ test/CMakeLists.txt | 6 +++--- test/cuda-test/cuda-cpp14.cu | 8 +++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 2dc6ed55..1448ab24 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -132,6 +132,7 @@ # endif # endif #endif + // Workaround broken [[deprecated]] in the Intel compiler. #ifdef __INTEL_COMPILER # define FMT_DEPRECATED_ALIAS @@ -139,6 +140,13 @@ # define FMT_DEPRECATED_ALIAS FMT_DEPRECATED #endif +// Workaround broken [[deprecated]] for the NVCC (CUDA with C++14) +#if defined(__NVCC__) || defined(__CUDACC__) +# define FMT_DEPRECATED_ALIAS +#else +# define FMT_DEPRECATED_ALIAS FMT_DEPRECATED +#endif + #ifndef FMT_BEGIN_NAMESPACE # if FMT_HAS_FEATURE(cxx_inline_namespaces) || FMT_GCC_VERSION >= 404 || \ FMT_MSC_VER >= 1900 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 62cc7ee4..e6c75361 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -227,10 +227,10 @@ if (FMT_PEDANTIC AND NOT WIN32) endif () # -# Activate CUDA related tests (Optional) -# if and only if we can find the CUDA in current CMake run. +# Activate CUDA related tests if we can find CUDA from CMake. This is optional. +# For version selection, see https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#cpp14-language-features # -find_package(CUDA 9.2) +find_package(CUDA 9.0) if(CUDA_FOUND) add_test(cuda-test ${CMAKE_CTEST_COMMAND} -C ${CMAKE_BUILD_TYPE} diff --git a/test/cuda-test/cuda-cpp14.cu b/test/cuda-test/cuda-cpp14.cu index 3d2aef90..48a36b62 100644 --- a/test/cuda-test/cuda-cpp14.cu +++ b/test/cuda-test/cuda-cpp14.cu @@ -24,9 +24,11 @@ static_assert(__cplusplus >= 201402L, "expect C++ 2014 for nvcc"); // Since we don't know the actual case in this header, checking both macro // will prevent possible pitfalls ... // -#if defined(__NVCC__) || defined(__CUDACC__) -# define FMT_DEPRECATED -#endif +// --- this check is moved into the --- +// +// #if defined(__NVCC__) || defined(__CUDACC__) +// # define FMT_DEPRECATED // suppress [[deprecated]] attribute +// #endif #include #include