-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
83 lines (65 loc) · 2.18 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# SPDX-License-Identifier: LGPL-3.0-only
#
# Author: Hao-Xin Wang <wanghaoxin1996@gmail.com>
# Creation Date: 2019-04-24 16:28
#
# Description: QuantumLiquids/TensorToolkit project. Main CMake file.
#
# CMake basic setting
cmake_minimum_required(VERSION 3.12)
project("TensorToolkit"
DESCRIPTION "a high-performance tensor basic operation library written in C++"
LANGUAGES CXX
)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/")
# Build type.
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
if (${CMAKE_BUILD_TYPE} MATCHES Debug)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif ()
# Compilation and linking control.
set(CMAKE_CXX_STANDARD 17)
add_definitions(-Wall -g)
# Advanced options.
option(QLTEN_BUILD_UNITTEST "Build unittests for TensorKit." OFF)
option(QLTEN_TIMING_MODE "Timing mode." ON)
if (QLTEN_TIMING_MODE)
add_definitions(-DQLTEN_TIMING_MODE)
endif ()
option(QLTEN_MPI_TIMING_MODE "Timing mode." ON)
if (QLTEN_MPI_TIMING_MODE)
add_definitions(-DQLTEN_MPI_TIMING_MODE)
endif ()
option(QLTEN_USE_GPU "Use GPU" OFF)
if (QLTEN_USE_GPU)
add_definitions(-DUSE_GPU=1)
# Enable CUDA language support
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED) # Modern CUDA Toolkit detection
include_directories(${CUDAToolkit_INCLUDE_DIRS})
message(STATUS "CUDA_INCLUDE_DIRS: '${CUDAToolkit_INCLUDE_DIRS}'")
# Set CUDA architectures
set(CMAKE_CUDA_ARCHITECTURES 70 80) # For V100 & A100, adjust if needed
# Compiler flags
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -lineinfo -Xcompiler=-fPIC")
else ()
option(QLTEN_USE_EXTERNAL_HPTT_LIB "Use user pre-installed external hptt library" OFF)
endif ()
# Build dependencies.
if (NOT QLTEN_USE_EXTERNAL_HPTT_LIB)
add_subdirectory(external/hptt)
endif ()
# Installation.
set(QLTEN_HEADER_PATH "${PROJECT_SOURCE_DIR}/include")
set(QLTEN_HEADER_DIR ${QLTEN_HEADER_PATH}/qlten)
set(QLTEN_INCLUDE_DEST "${CMAKE_INSTALL_PREFIX}/include")
install(DIRECTORY ${QLTEN_HEADER_DIR}
DESTINATION ${QLTEN_INCLUDE_DEST})
# Unittests
if (QLTEN_BUILD_UNITTEST)
enable_testing()
find_package(GTest REQUIRED)
add_subdirectory(tests tests)
endif ()