forked from scivision/mumps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
151 lines (114 loc) · 3.82 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
cmake_minimum_required(VERSION 3.19...3.27)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "Please use out of source build:
cmake -B build")
endif()
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT is_multi_config AND NOT (CMAKE_BUILD_TYPE OR DEFINED ENV{CMAKE_BUILD_TYPE}))
set(CMAKE_BUILD_TYPE Release CACHE STRING "Release default")
endif()
project(MUMPS
LANGUAGES C Fortran
VERSION 5.6.2.5
DESCRIPTION "Sparse direct parallel solver"
HOMEPAGE_URL "http://mumps-solver.org/"
)
enable_testing()
if(DEFINED BUILD_TESTING)
set(${PROJECT_NAME}_BUILD_TESTING ${BUILD_TESTING})
else()
set(${PROJECT_NAME}_BUILD_TESTING true)
endif()
if(NOT MUMPS_UPSTREAM_VERSION)
set(MUMPS_UPSTREAM_VERSION 5.6.2)
endif()
if(MSVC AND BUILD_SHARED_LIBS)
message(WARNING "MUMPS: Windows Intel/IntelLLVM compilers with **shared** libraries is not supported and will probably fail.
Recommend using static libraries, which does work:
cmake -DBUILD_SHARED_LIBS=off")
endif()
# --- user options
include(options.cmake)
include(cmake/compilers.cmake)
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} upstream ${MUMPS_UPSTREAM_VERSION} install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMake ${CMAKE_VERSION} Toolchain ${CMAKE_TOOLCHAIN_FILE}")
# --- dependencies
find_package(Threads)
# -- Scalapack / MPI
if(parallel)
find_package(MPI COMPONENTS C Fortran REQUIRED)
if(NOT DEFINED ENV{MKLROOT})
# oneMKL MKLConfig.cmake must be invoked only once
include(cmake/lapack.cmake)
endif()
include(cmake/scalapack.cmake)
set(NUMERIC_LIBS SCALAPACK::SCALAPACK LAPACK::LAPACK)
if(find_static AND NOT WIN32 AND
MKL IN_LIST LAPACK_VENDOR AND
CMAKE_VERSION VERSION_GREATER_EQUAL 3.24
)
set(NUMERIC_LIBS $<LINK_GROUP:RESCAN,${NUMERIC_LIBS}>)
endif()
# avoid MPICH -fallow flag leakage
set(NUMERIC_INC ${MPI_Fortran_INCLUDE_DIRS})
list(APPEND NUMERIC_LIBS ${MPI_Fortran_LIBRARIES} MPI::MPI_C)
if(openmp)
find_package(OpenMP COMPONENTS C Fortran REQUIRED)
list(APPEND NUMERIC_LIBS OpenMP::OpenMP_Fortran OpenMP::OpenMP_C)
endif()
else()
include(cmake/lapack.cmake)
endif()
# --- ordering libs
set(ORDERING_LIBS)
set(ORDERING_DEFS pord)
if(scotch)
find_package(Scotch COMPONENTS ESMUMPS REQUIRED)
list(APPEND ORDERING_DEFS scotch)
list(APPEND ORDERING_LIBS Scotch::Scotch)
endif()
if(parmetis)
find_package(METIS REQUIRED COMPONENTS parallel)
list(APPEND ORDERING_DEFS parmetis metis)
list(APPEND ORDERING_LIBS METIS::METIS)
elseif(metis)
find_package(METIS REQUIRED)
list(APPEND ORDERING_DEFS metis)
list(APPEND ORDERING_LIBS METIS::METIS)
endif()
list(APPEND ORDERING_LIBS pord)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLAPACK.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindSCALAPACK.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindMETIS.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindScotch.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindMUMPS.cmake
DESTINATION cmake
)
message(STATUS "MUMPS ORDERING_DEFS: ${ORDERING_DEFS}")
message(STATUS "MUMPS ORDERING_LIBS: ${ORDERING_LIBS}")
# --- download MUMPS source
include(cmake/mumps_src.cmake)
message(VERBOSE "MUMPS ${MUMPS_UPSTREAM_VERSION} source directory: ${mumps_SOURCE_DIR}")
# --- MUMPS build
# --- mpiseq (No MPI)
if(NOT parallel)
include(cmake/libseq.cmake)
set(NUMERIC_LIBS mpiseq LAPACK::LAPACK)
endif()
list(APPEND NUMERIC_LIBS ${CMAKE_THREAD_LIBS_INIT})
# --- PORD (always used)
include(cmake/pord.cmake)
# --- MUMPS itself
include(cmake/mumps.cmake)
if(matlab OR octave)
include(cmake/matlab.cmake)
endif()
if(${PROJECT_NAME}_BUILD_TESTING)
add_subdirectory(test)
endif()
# --- feature summary
message(STATUS "Configured MUMPS ${MUMPS_UPSTREAM_VERSION} source in ${mumps_SOURCE_DIR}")
include(cmake/summary.cmake)
include(cmake/install.cmake)
file(GENERATE OUTPUT .gitignore CONTENT "*")