-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathCMakeLists.txt
130 lines (110 loc) · 4.73 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# -----
# @file : CMakeLists.txt
# @project : OpenPARF
# @author : Jing Mai <[email protected]>
# @created date : March 30 2023, 21:39:53, Thursday
# @brief :
# -----
# Last Modified: July 31 2023, 00:23:15, Monday
# Modified By: Jing Mai <[email protected]>
# -----
# @history :
# ====================================================================================
# Date By (version) Comments
# ------------- ------- --------- --------------------------------------------------
# ====================================================================================
# Copyright (c) 2020 - 2023 All Right Reserved, PKU-IDEA Lab
# -----
# This header is generated by VSCode extension psi-header.
#
# CMake setup
cmake_minimum_required(VERSION 3.12)
MESSAGE(STATUS "CMAKE_ROOT: " ${CMAKE_ROOT})
# Project name
project(OpenPARF)
add_subdirectory(cmake/Ccache.cmake)
# options
option(ENABLE_ROUTER "Enable router build" OFF)
# disable frame pointer omission for debugging.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer")
# enable address sanitizer for debugging.
# set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
# set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# get the value of _GLIBCXX_USE_CXX11_ABI from torch
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import torch; print(torch._C._GLIBCXX_USE_CXX11_ABI)"
OUTPUT_VARIABLE TORCH_USE_CXX11_ABI
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(TORCH_USE_CXX11_ABI STREQUAL "True")
set(TORCH_CXX_ABI 1)
else()
set(TORCH_CXX_ABI 0)
endif()
message(STATUS "TORCH_CXX_ABI: ${TORCH_CXX_ABI}")
if(NOT CMAKE_CXX_ABI)
set(CMAKE_CXX_ABI ${TORCH_CXX_ABI} CACHE STRING
"Choose the value for _GLIBCXX_USE_CXX11_ABI, options are: 0|1."
FORCE)
endif(NOT CMAKE_CXX_ABI)
message(STATUS "CMAKE_CXX_ABI: _GLIBCXX_USE_CXX11_ABI=${CMAKE_CXX_ABI}")
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=${CMAKE_CXX_ABI})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# for CUDA, must be put before finding PyTorch
# link dynamic libraries rather than static ones
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
# critical for cuda_add_library, as we need to turn off -O flags
# to make sure the symbols generated by nvcc and gcc are the same
set(CUDA_PROPAGATE_HOST_FLAGS ON)
# set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};--expt-extended-lambda)
# required for executable to run at the install directory
# it will change the RPATH when installing
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
include(cmake/TorchExtension.cmake)
set(Boost_NO_BOOST_CMAKE TRUE)
find_package(Boost 1.55.0 REQUIRED)
message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
find_package(BISON 3.4 REQUIRED)
find_package(FLEX REQUIRED)
# use Doxygen to generate documentation
find_package(Doxygen)
message(STATUS "CMAKE_HOST_SYSTEM: ${CMAKE_HOST_SYSTEM}")
message(STATUS "CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
message(STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
message(STATUS "CMAKE_CXX_FLAGS_MINSIZEREL: ${CMAKE_CXX_FLAGS_MINSIZEREL}")
message(STATUS "CMAKE_EXE_LINKER_FLAGS: " ${CMAKE_EXE_LINKER_FLAGS})
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
message(STATUS "CUDA_FOUND: ${CUDA_FOUND}")
message(STATUS "ENABLE_ROUTER: ${ENABLE_ROUTER}")
if(CUDA_FOUND)
if(NOT CUDA_ARCH_LIST)
set(CUDA_ARCH_LIST 6.0 6.1 7.0)
if(${CUDA_VERSION_MAJOR} VERSION_GREATER "9")
list(APPEND CUDA_ARCH_LIST 7.5 8.0)
endif(${CUDA_VERSION_MAJOR} VERSION_GREATER "9")
endif(NOT CUDA_ARCH_LIST)
# for cuda_add_library
cuda_select_nvcc_arch_flags(CUDA_ARCH_FLAGS ${CUDA_ARCH_LIST})
message(STATUS "CUDA_ARCH_FLAGS: ${CUDA_ARCH_FLAGS}")
list(APPEND CUDA_NVCC_FLAGS ${CUDA_ARCH_FLAGS} --compiler-options;-fPIC)
endif(CUDA_FOUND)
# without this, clang will complain about linking
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
add_subdirectory(thirdparty)
add_subdirectory(openparf)
add_subdirectory(benchmarks)
enable_testing()
add_subdirectory(unittest)
add_subdirectory(docs)
file(GLOB SRCS *.py)
install(FILES ${SRCS} DESTINATION .)