-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
53 lines (40 loc) · 1.66 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
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(jotting-sdk LANGUAGES C CXX CUDA)
set(CMAKE_CXX_STANDARD 17)
option(WITH_TEST "whether to build with unittest" ON)
option(WITH_PROFILER "whether to build with profiler" ON)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 61 70 75 80)
endif(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
message(STATUS "CMAKE_CUDA_ARCHITECTURES: ${CMAKE_CUDA_ARCHITECTURES}")
enable_language(CUDA)
# if use old way, the variables can be found in https://cmake.org/cmake/help/latest/module/FindCUDA.html.
# find_package(CUDA)
# new in cmake 3.17
find_package(CUDAToolkit REQUIRED)
# all cuda libraries can be found in https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html#result-variables.
message(STATUS "CUDA_INCLUDE_DIRS: ${CUDAToolkit_INCLUDE_DIRS}")
message(STATUS "CUDA_TOOLKIT_ROOT_DIR: ${CUDA_TOOLKIT_ROOT_DIR}")
message(STATUS "CUDA_cublas_LIBRARY: ${CUDA_cublas_LIBRARY}")
message(STATUS "CUDA_cusparse_LIBRARY: ${CUDA_cusparse_LIBRARY}")
# get all cuda libs
# set(CUDA_LIB_DIR ${CUDA_TOOLKIT_ROOT_DIR}/lib64)
# file(GLOB_RECURSE CUDA_ALL_LIBS ${CUDA_LIB_DIR}/*.so)
# message(STATUS "CUDA_ALL_LIBS: ${CUDA_ALL_LIBS}")
find_package(OpenMP REQUIRED)
if(OpenMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# specify for cuda
set (CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=${OpenMP_CXX_FLAGS}")
else()
message(FATAL_ERROR "OpenMP not found!")
endif()
if(WITH_PROFILER)
add_definitions(-DWITH_PROFILER)
endif()
add_subdirectory(src)
if(WITH_TEST)
enable_testing()
add_subdirectory(test)
endif()