-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
189 lines (151 loc) · 5.77 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# -*- Mode: cmake -*-
cmake_minimum_required( VERSION 3.8 )
project( ChASE LANGUAGES C CXX VERSION 1.3.0 )
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# ## algorithm ##
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_library(chase_algorithm INTERFACE)
include(GNUInstallDirs)
target_include_directories( chase_algorithm INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> # <prefix>/include/mylib
)
target_compile_features(chase_algorithm INTERFACE cxx_auto_type)
option( CHASE_OUTPUT "ChASE will provide output at each iteration")
# Add an option to enable/disable OpenMP support
option(CHASE_ENABLE_OPENMP "Enable OpenMP support" ON)
option(CHASE_ENABLE_MIXED_PRECISION "Enable mixed precision support" OFF)
option(CHASE_ENABLE_MPI_IO "Enable MPI IO to read Hamiltonian matrix from local" OFF)
option(CHASE_USE_NVTX "Enable NVTX for profiling" OFF)
option(CHASE_BUILD_WITH_EXAMPLES "Build the examples" OFF)
option(CHASE_BUILD_WITH_DOCS "Build the docs" OFF)
if( CHASE_OUTPUT )
target_compile_definitions( chase_algorithm INTERFACE "-DCHASE_OUTPUT" )
endif()
# Find OpenMP package if the option is enabled
# Find OpenMP package if the option is enabled
if(ENABLE_OPENMP)
find_package(OpenMP REQUIRED)
if(OpenMP_CXX_FOUND)
message(STATUS "OpenMP found, enabling OpenMP support")
# Add OpenMP compiler flags globally
add_compile_options(${OpenMP_CXX_FLAGS})
# Link OpenMP libraries globally
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else()
message(WARNING "OpenMP not found, building without OpenMP support")
endif()
endif()
# Add the flag to the preprocessor if the option is enabled
if (CHASE_ENABLE_MIXED_PRECISION)
add_definitions(-DENABLE_MIXED_PRECISION)
message(STATUS "Mixed precision support enabled.")
else()
message(STATUS "Mixed precision support disabled.")
endif()
if(CHASE_USE_NVTX)
target_compile_definitions( chase_algorithm INTERFACE "-DUSE_NVTX" )
endif()
add_subdirectory(grid)
add_subdirectory(external)
add_subdirectory(linalg)
add_subdirectory(Impl)
add_subdirectory(interface)
if(CHASE_BUILD_WITH_EXAMPLES)
add_subdirectory(examples)
endif()
add_executable( "chase_driver" tests/noinput.cpp )
target_link_libraries(chase_driver chase_cpu)
if(TARGET chase_gpu)
add_executable( "chase_driver_gpu" tests/noinput.cpp )
target_link_libraries(chase_driver_gpu chase_gpu)
endif()
option(ENABLE_TESTS "Enable unit tests." OFF)
if(ENABLE_TESTS)
MESSAGE("Test enabled. Finding GoogleTests.")
include(${CMAKE_SOURCE_DIR}/cmake/external/Gtest/FetchGtest.cmake)
include(CTest)
set(MPI_RUN mpirun CACHE STRING "MPI runner (mpirun/srun)")
set(MPI_RUN_ARGS CACHE STRING "")
set(MPI_TEST ON CACHE BOOL "Run test with mpi")
add_subdirectory(tests)
endif()
# Documentation
if(CHASE_BUILD_WITH_DOCS)
message(STATUS "Building Documentation of ChASE")
add_subdirectory("docs")
endif()
#get_target_property(interface_defs mpi_grid_nccl INTERFACE_COMPILE_DEFINITIONS)
#message("INTERFACE_COMPILE_DEFINITIONS: ${interface_defs}")
# List all dependencies (linked targets)
#get_target_property(linked_libraries pchase_gpu INTERFACE_LINK_LIBRARIES)
#message("linked_libraries: ${linked_libraries}")
# Prepare a list to store definitions
#set(all_inherited_defs "")
#foreach(dep ${linked_libraries})
# Check if the dependency is a valid target
# if(TARGET ${dep})
# Get INTERFACE_COMPILE_DEFINITIONS from the dependency
# get_target_property(dep_defs ${dep} INTERFACE_COMPILE_DEFINITIONS)
# Append to the list
# if(dep_defs)
# list(APPEND all_inherited_defs ${dep_defs})
# endif()
# endif()
#endforeach()
# Remove duplicates (optional)
#list(REMOVE_DUPLICATES all_inherited_defs)
# Print all inherited definitions
#message("Inherited compile definitions: ${all_inherited_defs}")
#get_target_property(linked_libraries blaspp INTERFACE_LINK_LIBRARIES)
#message("Libraries linked by blaspp: ${linked_libraries}")
#get_target_property(blas_library ${linked_libraries} IMPORTED_LOCATION)
#message("BLAS library path: ${blas_library}")
##installation
install( TARGETS chase_algorithm
EXPORT chase_targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY algorithm DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.inc"
)
install(EXPORT chase_targets
NAMESPACE ChASE::
EXPORT_LINK_INTERFACE_LIBRARIES
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
FILE chaseTargets.cmake)
include(CMakePackageConfigHelpers)
set(IS_ENABLE_MPI OFF)
set(IS_ENABLE_SCALAPACK OFF)
set(IS_ENABLE_NCCL OFF)
if(TARGET pchase_cpu)
set(IS_ENABLE_MPI ON)
endif()
if(TARGET scalapackpp)
set(IS_ENABLE_SCALAPACK ON)
endif()
if(TARGET linalg_internal_nccl)
set(IS_ENABLE_NCCL ON)
endif()
# Convert booleans to "ON"/"OFF" strings for the config file
set(IS_ENABLE_MPI_STRING ${IS_ENABLE_MPI})
set(IS_ENABLE_SCALAPACK_STRING ${IS_ENABLE_SCALAPACK})
set(IS_ENABLE_NCCL_STRING ${IS_ENABLE_NCCL})
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/chase-config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ChASE
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/chase-config.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ChASE
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/cmake/modules
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ChASE)