Add FMT_CUDA_TEST CMake option to enable cuda-test

This commit is contained in:
Victor Zverovich 2019-12-09 07:30:34 -08:00
parent f675cb887e
commit fd52de0c6b
2 changed files with 17 additions and 14 deletions

View File

@ -42,6 +42,7 @@ option(FMT_DOC "Generate the doc target." ${MASTER_PROJECT})
option(FMT_INSTALL "Generate the install target." ${MASTER_PROJECT}) option(FMT_INSTALL "Generate the install target." ${MASTER_PROJECT})
option(FMT_TEST "Generate the test target." ${MASTER_PROJECT}) option(FMT_TEST "Generate the test target." ${MASTER_PROJECT})
option(FMT_FUZZ "Generate the fuzz target." OFF) option(FMT_FUZZ "Generate the fuzz target." OFF)
option(FMT_CUDA_TEST "Generate the cuda-test target." OFF)
project(FMT CXX) project(FMT CXX)

View File

@ -229,20 +229,22 @@ if (FMT_PEDANTIC AND NOT WIN32)
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
endif () endif ()
# Activate optional CUDA tests if CUDA is found. For version selection, see # Activate optional CUDA tests if CUDA is found. For version selection see
# https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#cpp14-language-features # https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#cpp14-language-features
if (${CMAKE_VERSION} VERSION_LESS 3.15) if (FMT_CUDA_TEST)
find_package(CUDA 9.0) if (${CMAKE_VERSION} VERSION_LESS 3.15)
else () find_package(CUDA 9.0)
include(CheckLanguage) else ()
check_language(CUDA) include(CheckLanguage)
if (CMAKE_CUDA_COMPILER) check_language(CUDA)
enable_language(CUDA OPTIONAL) if (CMAKE_CUDA_COMPILER)
set(CUDA_FOUND TRUE) enable_language(CUDA OPTIONAL)
set(CUDA_FOUND TRUE)
endif ()
endif ()
if (CUDA_FOUND)
add_subdirectory(cuda-test)
add_test(NAME cuda-test COMMAND fmt-in-cuda-test)
endif () endif ()
endif () endif ()
if (CUDA_FOUND)
add_subdirectory(cuda-test)
add_test(NAME cuda-test COMMAND fmt-in-cuda-test)
endif ()