This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
69 lines (62 loc) · 1.72 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
cmake_minimum_required(VERSION 3.10)
project (gpu_tensor LANGUAGES CXX C)
include(CheckCXXCompilerFlag)
project(mshadow C CXX)
# GoogleTest lib
set(googletest_INCLUDE_DIRS
googletest/googletest/include/
googletest/googletest/
googletest/googlemock/include/
googletest/googlemock/
)
set(googletest_SOURCE
googletest/googletest/src/gtest-all.cc
googletest/googlemock/src/gmock-all.cc
)
include_directories(${googletest_INCLUDE_DIRS})
add_library(googletest STATIC ${googletest_SOURCE})
target_link_libraries(googletest pthread)
# Mshadow
set(USE_BLAS "Blas")
set(USE_CUDA 1)
include(cmake/mshadow.cmake)
# Cuda
# TODO: make optional
find_package(CUDA 8.0)
if (CUDA_FOUND)
message(STATUS "CUDA found")
else()
message(FALTAL_ERROR "CUDA not found")
endif()
# Unit test executable
set (UNIT_TEST_SRC
test/main.cc
test/guide_basic_stream.cu
test/guide_basic.cc
)
cuda_add_executable(unit_test ${UNIT_TEST_SRC})
target_include_directories(unit_test PUBLIC
${CUDA_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(unit_test
googletest
blas # TODO: modify mshadow's CMake to include this
${mshadow_LINKER_LIBS}
${CUDA_CUDART_LIBRARY}
${CUDA_curand_LIBRARY}
${CUDA_CUBLAS_LIBRARIES}
${CUDA_cusolver_LIBRARY}
)
# `make check-style` errors if styling is not compliant
add_custom_target(check-style
COMMAND ${CMAKE_COMMAND}
-DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}"
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check-style.cmake
)
# `make apply-style` runs clang-format to format all source code
add_custom_target(apply-style
COMMAND ${CMAKE_COMMAND}
-DPROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}"
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/apply-style.cmake
)