forked from awslabs/palace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
158 lines (134 loc) · 6.38 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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
#
# CMake superbuild for Palace and its dependencies
#
# CMake 3.18.1 was released in Jul. 2020
cmake_minimum_required(VERSION 3.18.1)
# Prohibit in-source builds
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are prohibited")
endif()
# Initialize the project
project(palace-superbuild LANGUAGES CXX C VERSION 0.11.2)
# Define build settings and defaults
set(PALACE_WITH_64BIT_INT OFF CACHE BOOL "Use 64 bit integers")
set(PALACE_WITH_64BIT_BLAS_INT OFF CACHE BOOL "Use ILP64 BLAS/LAPACK interface instead of LP64 (not recommended)")
set(PALACE_WITH_OPENMP OFF CACHE BOOL "Use OpenMP")
set(PALACE_BUILD_EXTERNAL_DEPS ON CACHE BOOL "Build external third-party dependency libraries")
set(PALACE_WITH_SUPERLU ON CACHE BOOL "Build with SuperLU_DIST sparse direct solver")
set(PALACE_WITH_STRUMPACK OFF CACHE BOOL "Build with STRUMPACK sparse direct solver")
set(PALACE_WITH_MUMPS OFF CACHE BOOL "Build with MUMPS sparse direct solver")
set(PALACE_WITH_SLEPC ON CACHE BOOL "Build with SLEPc eigenvalue solver")
set(PALACE_WITH_ARPACK OFF CACHE BOOL "Build with ARPACK eigenvalue solver")
set(PALACE_WITH_LIBXSMM ON CACHE BOOL "Build with LIBXSMM backend for libCEED")
set(PALACE_WITH_GSLIB ON CACHE BOOL "Build with GSLIB library for high-order field interpolation")
set(ANALYZE_SOURCES_CLANG_TIDY OFF CACHE BOOL "Run static analysis checks using clang-tidy")
set(ANALYZE_SOURCES_CPPCHECK OFF CACHE BOOL "Run static analysis checks using cppcheck")
# Enable Fortran if required
if(PALACE_WITH_STRUMPACK OR PALACE_WITH_MUMPS OR PALACE_WITH_ARPACK)
enable_language(Fortran)
endif()
# Set a default build type if none was provided
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting CMAKE_BUILD_TYPE to 'Release' as none was specified")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Specifies the build type ('Debug' or 'Release', for example)" FORCE
)
endif()
# Set a default installation location if none was provided
if(NOT CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message(STATUS "Setting CMAKE_INSTALL_PREFIX to '${CMAKE_BINARY_DIR}' as none was specified")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE STRING
"Install directory used by install()" FORCE
)
endif()
# Set a default for dependency library builds if none was provided
if(NOT DEFINED BUILD_SHARED_LIBS)
message(STATUS "Setting BUILD_SHARED_LIBS to 'OFF' as it was not specified")
set(BUILD_SHARED_LIBS OFF CACHE BOOL
"Global flag to cause add_library() to create shared libraries if ON"
)
endif()
# Configure default RPATH for installed targets if not provided
if(NOT DEFINED CMAKE_INSTALL_RPATH)
message(STATUS "Setting CMAKE_INSTALL_RPATH to '\${CMAKE_INSTALL_PREFIX}/lib;\${CMAKE_INSTALL_PREFIX}/lib64' as it was not specified")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib$<SEMICOLON>${CMAKE_INSTALL_PREFIX}/lib64" CACHE STRING
"Global RPATH to use for installed targets"
)
endif()
if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
message(STATUS "Setting CMAKE_INSTALL_RPATH_USE_LINK_PATH to 'ON' as it was not specified")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON CACHE BOOL
"Global flag to append to the RPATH of installed binaries any directories which linked library files if ON"
)
endif()
# Add extra CMake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Intel classic compilers no longer supported (prior to CMake 3.20, the new compilers are
# detected as Clang instead of IntelLLVM)
if(CMAKE_C_COMPILER_ID STREQUAL "Intel" OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
message(WARNING "The Intel classic compilers (icc/icpc) are no longer supported and \
have been replaced by the newer Clang-based icx/icpx from Intel oneAPI")
endif()
# MPI is required for most dependency builds
message(STATUS "====================== Configuring MPI dependency ======================")
find_package(MPI REQUIRED)
# Add BLAS/LAPACK libraries
message(STATUS "================= Configuring BLAS/LAPACK dependencies =================")
include(ExternalBLASLAPACK)
# Default arguments for all external CMake builds (needs to happen after BLAS/LAPACK
# detection in case CMAKE_PREFIX_PATH is modified)
# See https://spack.readthedocs.io/en/latest/build_systems/cmakepackage.html#cmake-arguments-provided-by-spack
set(PALACE_SUPERBUILD_DEFAULT_ARGS
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}"
)
if(NOT "${CMAKE_PREFIX_PATH}" STREQUAL "")
string(REPLACE ";" "$<SEMICOLON>" PALACE_CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}")
list(APPEND PALACE_SUPERBUILD_DEFAULT_ARGS
"-DCMAKE_PREFIX_PATH=${PALACE_CMAKE_PREFIX_PATH}$<SEMICOLON>${CMAKE_INSTALL_PREFIX}"
)
else()
list(APPEND PALACE_SUPERBUILD_DEFAULT_ARGS
"-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}"
)
endif()
if(NOT "${CMAKE_INSTALL_RPATH}" STREQUAL "")
string(REPLACE ";" "$<SEMICOLON>" PALACE_CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}")
list(APPEND PALACE_SUPERBUILD_DEFAULT_ARGS
"-DCMAKE_INSTALL_RPATH=${PALACE_CMAKE_INSTALL_RPATH}"
)
endif()
if(NOT "${CMAKE_INSTALL_RPATH_USE_LINK_PATH}" STREQUAL "")
list(APPEND PALACE_SUPERBUILD_DEFAULT_ARGS
"-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=${CMAKE_INSTALL_RPATH_USE_LINK_PATH}"
)
endif()
include(ExternalGitTags)
# Avoid DOWNLOAD_EXTRACT_TIMESTAMP warning
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
# Add other third-party dependency builds
include(ExternalGitTags)
if(PALACE_BUILD_EXTERNAL_DEPS)
add_subdirectory("extern")
endif()
# Add GSLIB (always built as part of Palace)
if(PALACE_WITH_GSLIB)
message(STATUS "===================== Configuring GSLIB dependency =====================")
include(ExternalGSLIB)
endif()
# Add libCEED (always built as part of Palace)
message(STATUS "==================== Configuring libCEED dependency ====================")
include(ExternalLibCEED)
# Add MFEM (always built as part of Palace)
message(STATUS "====================== Configuring MFEM dependency =====================")
include(ExternalMFEM)
# Add the main Palace project
message(STATUS "========================== Configuring Palace ==========================")
include(ExternalPalace)
# Finished with superbuild configuration
message(STATUS "======================= Configure stage complete =======================")