Squashed commit of the following:
Some checks failed
CI / build_cuda10-1 (push) Failing after 2s
CI / build (push) Failing after 3s

commit 25e7cb77683736a588acb6b30a8ac89e2bd7f56a
Author: Carl Pearson <pearson@illinois.edu>
Date:   Fri Sep 20 13:25:49 2019 -0500

    automatically define PERFECT_HAS_CUDA with nvcc

commit fcc699c165ba515619781aefb378d3c0c4d1093d
Author: Carl Pearson <pearson@illinois.edu>
Date:   Fri Sep 20 13:18:42 2019 -0500

    optional CUDA support
This commit is contained in:
Carl Pearson
2019-09-20 13:26:08 -05:00
parent 72c39c1dd5
commit 91e15ee7ea
8 changed files with 130 additions and 48 deletions

View File

@@ -5,9 +5,22 @@
# 3.13+ for target_link_directories
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(perfect LANGUAGES CUDA CXX VERSION 0.1.0)
project(perfect LANGUAGES CXX VERSION 0.1.0)
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
include(CheckLanguage)
option(USE_CUDA "try to use CUDA" ON)
if(USE_CUDA)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
else()
message(STATUS "No CUDA support")
endif()
endif()
#https://blog.kitware.com/cmake-and-the-default-build-type/
# Set a default build type if none was specified
set(default_build_type "Release")
@@ -33,19 +46,20 @@ elseif (CMAKE_BUILD_TYPE MATCHES Release)
set(CMAKE_CUDA_FLAGS ${CMAKE_CUDA_FLAGS} -lineinfo)
endif()
set(CMAKE_CUDA_STANDARD 11)
add_subdirectory(include/perfect)
add_library(perfect INTERFACE)
target_compile_features(perfect INTERFACE cxx_std_11)
if(CMAKE_CUDA_COMPILER)
target_compile_definitions(perfect INTERFACE -DPERFECT_HAS_CUDA)
# tell the host compiler where to find the CUDA includes and libraries
# CMakeFiles/<version>/CMakeCUDACompiler.cmake
target_include_directories(perfect INTERFACE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
target_link_directories(perfect INTERFACE ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES})
target_link_libraries(perfect INTERFACE nvidia-ml)
endif()
target_include_directories(perfect INTERFACE include/)
# tell the host compiler where to find the CUDA includes and libraries
target_include_directories(perfect INTERFACE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
# CMakeFiles/<version>/CMakeCUDACompiler.cmake
target_link_directories(perfect INTERFACE ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES})
target_link_libraries(perfect INTERFACE nvidia-ml)
add_subdirectory(examples)
add_subdirectory(tools)