forked from ORNL-QCI/exatn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
205 lines (171 loc) · 7.62 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()
set(CMAKE_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_DISABLE_IN_SOURCE_BUILDS ON)
#set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(EXATENSOR_ROOT ${CMAKE_SOURCE_DIR}/tpls/ExaTensor-devel)
set(CMAKE_DEBUG_POSTFIX "")
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
set(CMAKE_SKIP_INSTALL_RPATH OFF)
set(CMAKE_SKIP_RPATH OFF)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPATH_MAX=4096 -Wno-attributes")
project(exatn LANGUAGES CXX Fortran)
option(EXATN_BUILD_TESTS "Build ExaTN tests" OFF)
option(CUDA_HOST_COMPILER "Provide the host compiler for nvcc" "")
option(BLAS_LIB "Provide the BLAS implementation: ATLAS,MKL,OPENBLAS,ACML,ESSL" "")
option(BLAS_PATH "Provide the path to the BLAS libraries" "")
option(WITH_LAPACK "Turn on LAPACK support" YES)
option(MPI_LIB "Provide the MPI implementation (MPICH,OPENMPI)" "")
option(MPI_ROOT_DIR "Provide the MPI root directory" "")
option(MPI_BIN_PATH "Provide the MPI bin path" "")
option(ENABLE_CUDA "Turn on CUDA support" OFF)
#Check to make sure that both the MPI implementation and root installation/bin paths were supplied
if(MPI_LIB)
if(NOT MPI_LIB STREQUAL "MPICH" AND NOT MPI_LIB STREQUAL "OPENMPI")
message(FATAL_ERROR "Invalid MPI_LIB choice: Available choices: MPICH (incl. Cray-MPICH), OPENMPI (incl. Spectrum-MPI). CMake is exiting.")
endif()
if(NOT MPI_ROOT_DIR)
message(FATAL_ERROR "If you specify the MPI implementation, you must also specify the MPI root path (-DMPI_ROOT_DIR). CMake is exiting.")
endif()
if(NOT MPI_BIN_PATH)
set(MPI_BIN_PATH ${MPI_ROOT_DIR}/bin)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMPI_ENABLED")
else()
if(MPI_ROOT_DIR OR MPI_BIN_PATH)
message(FATAL_ERROR "If you specify the MPI root and/or bin paths, you should also specify the MPI_LIB choice (-DMPI_LIB). CMake is exiting.")
endif()
endif()
#Check to make sure that both the BLAS implementation and installation path were supplied
if(BLAS_LIB)
if(NOT BLAS_PATH AND NOT BLAS_LIB STREQUAL "MKL")
message(FATAL_ERROR "Your choice of BLAS implementation requires specification of the path to the BLAS libraries (-DBLAS_PATH). CMake is exiting.")
endif()
if(BLAS_LIB STREQUAL "ATLAS")
if(NOT EXISTS "${BLAS_PATH}/libblas.so")
message(FATAL_ERROR "The ATLAS BLAS library path does not contain libblas.so. CMake is exiting.")
endif()
elseif(BLAS_LIB STREQUAL "MKL")
if(NOT PATH_INTEL_ROOT)
message(FATAL_ERROR "The MKL BLAS choice requires the Intel root directory (-DPATH_INTEL_ROOT), for example /opt/intel. CMake is exiting.")
endif()
set(BLAS_PATH ${PATH_INTEL_ROOT}/mkl/lib/intel64)
if(NOT EXISTS "${BLAS_PATH}/libmkl_core.so")
message(FATAL_ERROR "The MKL BLAS library path does not contain libmkl_core.so. CMake is exiting.")
endif()
elseif(BLAS_LIB STREQUAL "OPENBLAS")
if(NOT EXISTS "${BLAS_PATH}/libopenblas.so")
message(FATAL_ERROR "The OPENBLAS BLAS library path does not contain libopenblas.so. CMake is exiting.")
endif()
elseif(BLAS_LIB STREQUAL "ACML")
if(NOT EXISTS "${BLAS_PATH}/libacml_mp.so")
message(FATAL_ERROR "The ACML BLAS library path does not contain libacml_mp.so. CMake is exiting.")
endif()
elseif(BLAS_LIB STREQUAL "ESSL")
if(NOT EXISTS "${BLAS_PATH}/libessl.so")
message(FATAL_ERROR "The ESSL BLAS library path does not contain libessl.so. CMake is exiting.")
endif()
if(NOT PATH_IBM_XL_CPP)
message(FATAL_ERROR "The ESSL BLAS choice requires the path to IBM XL C++ runtime libraries (-DPATH_IBM_XL_CPP). CMake is exiting.")
endif()
if(NOT PATH_IBM_XL_FOR)
message(FATAL_ERROR "The ESSL BLAS choice requires the path to IBM XL Fortran runtime libraries (-DPATH_IBM_XL_FOR). CMake is exiting.")
endif()
if(NOT PATH_IBM_XL_SMP)
message(FATAL_ERROR "The ESSL BLAS choice requires the path to IBM XL SMP runtime libraries (-DPATH_IBM_XL_SMP). CMake is exiting.")
endif()
else()
message(FATAL_ERROR "Invalid BLAS_LIB choice: ATLAS (default Linux), MKL, OPENBLAS, ACML, ESSL. CMake is exiting.")
endif()
else()
if(BLAS_PATH)
message(FATAL_ERROR "If you specify the path to the BLAS libraries, you must also specify which BLAS (-DBLAS_LIB): ATLAS, MKL, OPENBLAS, ACML, ESSL. CMake is exiting.")
endif()
endif()
if(NOT CMAKE_BUILD_TYPE)
set(
CMAKE_BUILD_TYPE "Release"
CACHE
STRING
"Choose the type of build, options are: Debug, Release, RelWithDebInfo, MinSizeRel"
FORCE)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.exatn"
CACHE PATH "default install path"
FORCE)
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
include(CTest)
find_package(OpenMP REQUIRED)
find_package(MPI)
if(ENABLE_CUDA)
find_package(CUDAExaTN)
if(NOT CUDA_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_GPU")
message(WARNING "You specified ENABLE_CUDA=TRUE but find_package(CUDA) could not find CUDA development headers or libraries")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_GPU")
set(CUDA_FOUND FALSE)
endif()
#If BLAS implementation is not user specified, proceed with "NONE"
if(NOT BLAS_LIB)
set(BLAS_LIB NONE)
set(BLAS_PATH "")
endif()
#If MPI implementation is not user specified, proceed with "NONE"
set(EXA_TALSH_ONLY "YES") #reset to "NO" for full ExaTENSOR
if(NOT MPI_LIB)
set(MPI_LIB NONE)
set(MPI_ROOT_DIR "")
set(MPI_BIN_PATH "")
set(EXA_TALSH_ONLY "YES")
endif()
message(STATUS "MPIRUN: ${MPIEXEC_EXECUTABLE}")
include_directories(${CMAKE_BINARY_DIR}/tpls/cppmicroservices/include)
include_directories(${CMAKE_BINARY_DIR}/tpls/cppmicroservices/framework/include)
include_directories(${CMAKE_SOURCE_DIR}/tpls/cppmicroservices/framework/include)
macro(exatn_configure_library_rpath LIBNAME)
if(APPLE)
set_target_properties(${LIBNAME} PROPERTIES INSTALL_RPATH "@loader_path")
set_target_properties(${LIBNAME}
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
set_target_properties(${LIBNAME} PROPERTIES INSTALL_RPATH "$ORIGIN")
set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS "-shared")
endif()
endmacro()
macro(exatn_configure_plugin_rpath LIBNAME)
if(APPLE)
set_target_properties(${LIBNAME} PROPERTIES INSTALL_RPATH "@loader_path/../lib/")
set_target_properties(${LIBNAME}
PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
set_target_properties(${LIBNAME} PROPERTIES INSTALL_RPATH "$ORIGIN/../lib")
set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS "-shared")
endif()
endmacro()
configure_file("${CMAKE_SOURCE_DIR}/cmake/exatn_config.hpp.in"
"${CMAKE_BINARY_DIR}/exatn_config.hpp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEXATN_SERVICE")
add_subdirectory(tpls)
add_subdirectory(src)
find_package(Python COMPONENTS Interpreter Development)
if(Python_FOUND)
if(${Python_VERSION} VERSION_GREATER_EQUAL 3.0.0)
message(STATUS "${BoldGreen}Found Python version ${Python_VERSION}. Building ExaTN Python API with ${Python_INCLUDE_DIRS}${ColorReset}")
add_subdirectory(python)
else()
message(STATUS "${BoldYellow}Found Python version ${Python_VERSION}. Version must be greater than 3.0.0, skipping Python API build.${ColorReset}")
endif()
else()
message(STATUS "${BoldYellow}Python interpreter or development headers not found. Skipping Python API build.${ColorReset}")
endif()