-
Notifications
You must be signed in to change notification settings - Fork 61
/
CMakeLists.txt
100 lines (83 loc) · 3.13 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
# CMake 3.15+ for Thrust/Cub support
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
project(MegBA VERSION 1.0.0 LANGUAGES CUDA CXX)
set(CMAKE_CXX_STANDARD 14)
set(CUDA_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(CMAKE_CUDA_ARCHITECTURES "60;61;62;70;72;75;80;86;87")
set(CMAKE_CUDA_SEPARABLE_COMPILATION TRUE)
set(CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS TRUE)
set(CMAKE_CUDA_HOST_COMPILATION_CPP FALSE)
set(CMAKE_CUDA_PROPAGATE_HOST_FLAGS FALSE)
include(GenerateExportHeader)
include(GNUInstallDirs)
set(generated_headers "${CMAKE_CURRENT_BINARY_DIR}/generated_headers")
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/MegBA")
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
# Configuration
set(version_config "${generated_dir}/MegBAConfigVersion.cmake")
set(project_config "${generated_dir}/MegBAConfig.cmake")
set(ALGO_EXPORT_NAME "Algo_Targets")
set(EDGE_EXPORT_NAME "Edge_Targets")
set(GEO_EXPORT_NAME "Geo_Targets")
set(LINEAR_SYSTEM_EXPORT_NAME "LinearSystem_Targets")
set(OPERATOR_EXPORT_NAME "Operator_Targets")
set(PROBLEM_EXPORT_NAME "Problem_Targets")
set(RESOURCE_EXPORT_NAME "Resource_Targets")
set(SOLVER_EXPORT_NAME "Solver_Targets")
set(VERTEX_EXPORT_NAME "Vertex_Targets")
option(MEGBA_ENABLE_NCCL "Enable NCCL" FALSE)
option(MEGBA_ENABLE_EXAMPLE "BUILD EXAMPLES" TRUE)
# CUDA
find_package(CUDAToolkit REQUIRED)
find_package(OpenMP REQUIRED)
set(EIGEN_BUILD_TESTING OFF)
add_subdirectory(third_party/eigen)
find_package(Threads REQUIRED)
if (${CMAKE_CUDA_COMPILER_VERSION} GREATER_EQUAL 11.5)
set(Thrust_DIR /usr/local/cuda/targets/x86_64-linux/lib/cmake/thrust/)
set(CUB_DIR /usr/local/cuda/targets/x86_64-linux/lib/cmake/cub/)
else ()
set(Thrust_DIR /usr/local/cuda/include/thrust/cmake/)
set(CUB_DIR /usr/local/cuda/include/cub/cmake/)
endif()
if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
add_definitions(-DDEBUG=1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -fPIC -fopenmp -pthread")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -O0 --extended-lambda")
else ()
add_definitions(-DDEBUG=0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fPIC -fopenmp -pthread")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -O3 --extended-lambda")
endif ()
find_package(Thrust REQUIRED CONFIG)
thrust_create_target(Thrust)
add_subdirectory(src)
if(MEGBA_ENABLE_EXAMPLE)
add_subdirectory(examples)
endif()
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${version_config}" COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
"cmake/libraryConfig.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${config_install_dir}"
)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
set(CPACK_GENERATOR "7Z")
set(CPACK_PACKAGE_VERSION "${MegBA_VERSION}")
include(CPack)
include(FeatureSummary)
feature_summary(WHAT ALL)