-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCMakeLists.txt
38 lines (33 loc) · 1.02 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
cmake_minimum_required(VERSION 3.5.1)
message(STATUS "CMake version: ${CMAKE_VERSION}")
project(diana)
option(USE_CUDA "Use CUDA" ON)
file(GLOB cpu_source_files "${CMAKE_SOURCE_DIR}/src/*.cc")
file(GLOB gpu_source_files "${CMAKE_SOURCE_DIR}/src/*.cu")
if( ("${CMAKE_VERSION}" VERSION_EQUAL 3.8) OR
("${CMAKE_VERSION}" VERSION_GREATER 3.8) )
# Modern CMake
if(USE_CUDA)
enable_language("CUDA")
add_executable(diana ${cpu_source_files} ${gpu_source_files})
else(USE_CUDA)
add_executable(diana ${cpu_source_files})
endif()
else()
# Old CMake
add_executable(diana ${cpu_source_files})
if(USE_CUDA)
find_package(CUDA 8.0)
if(NOT CUDA_FOUND)
message(STATUS "CUDA not found")
set(USE_CUDA OFF)
else()
CUDA_ADD_LIBRARY(diana_gpu ${gpu_source_files})
target_link_libraries(diana diana_gpu)
endif()
endif()
endif()
message(STATUS "USE_CUDA: ${USE_CUDA}")
if(USE_CUDA)
add_definitions(-DUSE_CUDA)
endif()