test cuda: <fmt/core.h> 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
This commit is contained in:
luncliff 2019-08-29 00:50:43 +09:00
parent bfa245e1a7
commit 14c5dab2e6
3 changed files with 16 additions and 6 deletions

View File

@ -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

View File

@ -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}

View File

@ -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 <fmt/core.h> ---
//
// #if defined(__NVCC__) || defined(__CUDACC__)
// # define FMT_DEPRECATED // suppress [[deprecated]] attribute
// #endif
#include <fmt/core.h>
#include <cuda.h>