Skip to content

Commit 6c3aa25

Browse files
author
Jack Poulson
committed
Reorganizing the CMakeLists.txt a bit and attempting to add support for METIS_LIBS into ElVars
1 parent 87b6d10 commit 6c3aa25

File tree

3 files changed

+169
-178
lines changed

3 files changed

+169
-178
lines changed

CMakeLists.txt

Lines changed: 140 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#
2-
# Copyright (c) 2009-2015, Jack Poulson
3-
# 2012, Jed Brown
2+
# Copyright 2009-2015, Jack Poulson
3+
# All rights reserved.
4+
#
5+
# Copyright 2012, Jed Brown
46
# All rights reserved.
57
#
68
# This file is part of Elemental and is under the BSD 2-Clause License,
@@ -20,114 +22,98 @@ project(Elemental)
2022
set(EL_VERSION_MAJOR 0)
2123
set(EL_VERSION_MINOR 86-dev)
2224

23-
################################################################################
24-
# Common build options #
25-
################################################################################
25+
# Configuration options
26+
# =====================
27+
28+
# Basic options
29+
# -------------
30+
31+
# "CMAKE_BUILD_TYPE"
32+
# Elemental requires it to be one of the following choices:
33+
# 1. "PureDebug": Vanilla MPI build meant for development and debugging
34+
# 2. "PureRelease": Vanilla MPI build meant for production runs
35+
# 3. "HybridDebug": MPI+OpenMP build meant for development and debugging
36+
# 4. "HybridRelease": MPI+OpenMP build meant for production runs
37+
# If "CMAKE_BUILD_TYPE" is not defined, the default is "PureRelease".
38+
39+
# "CXX_FLAGS"
40+
# Optimization and debugging/symbol flags
41+
42+
# "OpenMP_CXX_FLAGS"
43+
# Overrides the default compile flags for adding OpenMP support to CXX code
44+
45+
# TODO: Add list of MPI variables here, such as "MPI_CXX_COMPILE_FLAGS"
46+
47+
# TODO: Add discussion of "MATH_LIBS" and "REFERENCE_ROOT"
2648

27-
# By default, Elemental builds static libraries, but shared libraries are
28-
# also supported through this option.
2949
option(BUILD_SHARED_LIBS "Build shared libraries?" ON)
30-
if(BUILD_SHARED_LIBS AND WIN32)
31-
option(EL_DECLSPEC "Use __declspec(dllexport)?" ON)
32-
else()
33-
option(EL_DECLSPEC "Use __declspec(dllexport)?" OFF)
50+
51+
option(EL_C_INTERFACE "Build C interface" ON)
52+
if(BUILD_SHARED_LIBS AND EL_C_INTERFACE)
53+
# Define PYTHON_SITE_PACKAGES if you want to install the python package
54+
# somewhere other than the default system-wide location (e.g., within your
55+
# home directory)
56+
option(INSTALL_PYTHON_PACKAGE "Install python interface?" TRUE)
3457
endif()
3558

36-
# Whether or not to build a collection of simple example drivers.
37-
option(EL_EXAMPLES "A collection of simple examples" OFF)
59+
# Whether or not to use Qt5 for visualization if it is found.
60+
# Setting Qt5Widgets_DIR, Qt5_DIR, or Qt5_LIBDIR overrides this variable
61+
# and is often necessary anyway.
62+
option(EL_USE_QT5 "Attempt to use Qt5?" OFF)
3863

39-
# Whether or not to build a collection of performance and correctness tests
40-
option(EL_TESTS "A collection of performance and correctness tests" OFF)
64+
# NOTE: This is not yet used within Elemental...
65+
#
66+
# If BUILD_KISSFFT is set to 'OFF', then an external KISSFFT can be
67+
# built by defining:
68+
# KISSFFT_INCLUDE_DIR: The directory containing kiss_fft.h
69+
# KISSFFT_LIBS: The list of KISS-FFT libraries to link
70+
option(BUILD_KISSFFT "Build KISS FFT" OFF)
71+
72+
option(EL_EXAMPLES "Build simple examples?" OFF)
73+
option(EL_TESTS "Build performance and correctness tests?" OFF)
74+
option(EL_EXPERIMENTAL "Build experimental code" OFF)
4175

4276
# Whether or not to have the Memory class zero initialize what it allocates.
4377
# If valgrind was detected and is running, this will be forced anyway.
4478
option(EL_ZERO_INIT "Initialize buffers to zero by default?" OFF)
4579

46-
# Whether or not to build current 'experimental' code, such as:
47-
# Martin's 3D Gemm code
48-
option(EL_EXPERIMENTAL "Build experimental code" OFF)
49-
50-
option(EL_C_INTERFACE "Build work-in-progress C interface" ON)
51-
5280
# Attempt to use 64-bit integers
5381
option(EL_USE_64BIT_INTS "Use 64-bit integers where possible" OFF)
5482

55-
# Whether or not to use Qt5 for visualization if it is found (experimental)
56-
# NOTE: Setting Qt5Widgets_DIR, Qt5_DIR, or Qt5_LIBDIR overrides this variable
57-
option(EL_USE_QT5 "Attempt to use Qt5?" OFF)
58-
5983
option(EL_USE_CUSTOM_ALLTOALLV "Avoid MPI_Alltoallv for performance reasons" ON)
6084
option(EL_BARRIER_IN_ALLTOALLV "Barrier before posting non-blocking recvs" OFF)
6185

62-
option(BUILD_KISSFFT "Build KISS FFT" ON)
63-
if(BUILD_KISSFFT)
64-
add_subdirectory(external/kiss_fft)
65-
include_directories(external/kiss_fft)
66-
elseif(MANUAL_KISSFFT)
67-
# The following variables should be set:
68-
# KISSFFT_INCLUDE_DIR: The directory containing kiss_fft.h
69-
# KISSFFT_LIBS: The list of KISS-FFT libraries to link
70-
include_directories(${KISSFFT_INCLUDE_DIR})
71-
endif()
72-
73-
# NOTE: ParMETIS cannot yet be legally distributed under an unrestrictive
74-
# license and is currently limited to educational and research purposes.
75-
# However, recent versions of METIS can be distributed under the Apache
76-
# License Version 2.
86+
# If the version of METIS packaged with Elemental is to be built (the default),
87+
# then no METIS-specific variables need to be specified, but if the user prefers
88+
# to use their own version, then the root path of the installation should be
89+
# passed in via the METIS_ROOT variable.
7790
option(BUILD_METIS "Build METIS" ON)
78-
option(BUILD_PARMETIS "Build ParMETIS" OFF)
79-
if(BUILD_PARMETIS)
80-
message(FATAL_ERROR "ParMETIS cannot be legally distributed with Elemental under a permissive license. A version of Elemental restricted to educational purposes which contains ParMETIS will hopefully soon be available.")
81-
# add_subdirectory(external/parmetis)
82-
# set(EL_HAVE_METIS TRUE)
83-
# set(EL_HAVE_PARMETIS TRUE)
91+
92+
# ParMETIS cannot yet be legally distributed under an unrestrictive
93+
# license and is currently limited to educational and research purposes.
94+
# (recent versions of METIS can be distributed under the Apache License
95+
# Version 2).
8496
#
85-
# set(PARMETIS_ROOT ${PROJECT_SOURCE_DIR}/external/parmetis)
86-
# set(METIS_ROOT ${PROJECT_SOURCE_DIR}/external/parmetis/metis)
87-
# set(GKLIB_INCLUDE_DIR ${PROJECT_BINARY_DIR}/external/parmetis/include)
97+
# However, if the user is in an educational or government institution, then
98+
# it is possible to re-enable support for ParMETIS by specifying the following
99+
# variables:
88100
#
89-
# include_directories(${GKLIB_INCLUDE_DIR})
90-
# include_directories(${METIS_ROOT}/include)
91-
# include_directories(${PARMETIS_ROOT}/include)
92-
elseif(MANUAL_PARMETIS)
93-
message(FATAL_ERROR "ParMETIS cannot be legally distributed with Elemental under a permissive license. A version of Elemental restricted to educational purposes which contains ParMETIS will hopefully soon be available.")
94-
# # The following variables need to be specified:
95-
# # PARMETIS_TLS_PATCH: defined iff there is a GKlib configure file
96-
# # GKLIB_INCLUDE_DIR: if PARMETIS_TLS_PATCH is defined, this should point
97-
# # to the directory containing gklib_tls.h
98-
# # METIS_ROOT: the full path to the root of the MeTiS source tree
99-
# # PARMETIS_ROOT: the full path to the root of the ParMeTiS source tree
100-
# # PARMETIS_LIBS: the list of ParMETIS libraries to link to
101-
# set(EL_HAVE_METIS TRUE)
102-
# set(EL_HAVE_PARMETIS TRUE)
103-
# if(PARMETIS_TLS_PATCH)
104-
# include_directories(${GKLIB_INCLUDE_DIR})
105-
# endif()
101+
# METIS_ROOT: the full path to the root of the MeTiS source tree
102+
# PARMETIS_ROOT: the full path to the root of the ParMeTiS source tree
103+
# PARMETIS_LIBS: the list of ParMETIS libraries to link to
104+
# PARMETIS_TLS_PATCH: defined iff there is a GKlib configure file
105+
# (if you have not heard of this, ignore it)
106+
# GKLIB_INCLUDE_DIR: if PARMETIS_TLS_PATCH is defined, this should point
107+
# to the directory containing gklib_tls.h
108+
#
109+
# and adding in a custom ParMETIS routine for performing nodal bisections
110+
# in parallel (which was originally part of Clique and can be easily found).
111+
# Please contact [email protected] or [email protected] for more details.
106112
#
107-
# include_directories(${METIS_ROOT}/include)
108-
# include_directories(${PARMETIS_ROOT}/include)
109-
elseif(BUILD_METIS)
110-
add_subdirectory(external/metis)
111-
112-
set(METIS_ROOT ${PROJECT_SOURCE_DIR}/external/metis)
113-
include_directories(${METIS_ROOT}/include)
114-
115-
set(EL_HAVE_METIS TRUE)
116-
set(EL_HAVE_PARMETIS FALSE)
117-
else()
118-
if(NOT MANUAL_METIS)
119-
message(FATAL_ERROR
120-
"If Metis is not to be built, then MANUAL_METIS must be specified")
121-
endif()
122-
include_directories(${METIS_ROOT}/include)
123-
124-
set(EL_HAVE_METIS TRUE)
125-
set(EL_HAVE_PARMETIS FALSE)
126-
endif()
113+
#option(BUILD_PARMETIS "Build ParMETIS" OFF)
127114

128-
################################################################################
129-
# Advanced build options #
130-
################################################################################
115+
# Advanced options
116+
# ----------------
131117

132118
# Since it is surprisingly common for MPI libraries to have bugs in their
133119
# support for complex data, the following option forces Elemental to cast
@@ -154,15 +140,6 @@ option(EL_REDUCE_SCATTER_BLOCK_VIA_ALLREDUCE
154140
"AllReduce based block MPI_Reduce_scatter" OFF)
155141
mark_as_advanced(EL_REDUCE_SCATTER_BLOCK_VIA_ALLREDUCE)
156142

157-
# This can easily be performed, but is likely not a good idea
158-
option(EL_POOL_MEMORY
159-
"Make Memory class accumulate memory until destruction" OFF)
160-
mark_as_advanced(EL_POOL_MEMORY)
161-
162-
################################################################################
163-
# Elemental-development build options #
164-
################################################################################
165-
166143
# Print a warning any time a redistribution is performed which unpacks a
167144
# large amount of data with a non-unit stride
168145
option(EL_CACHE_WARNINGS "Warns when using cache-unfriendly routines" OFF)
@@ -180,35 +157,8 @@ option(EL_VECTOR_WARNINGS
180157
"Warn when vector redistribution chances are missed" OFF)
181158
mark_as_advanced(EL_VECTOR_WARNINGS)
182159

183-
################################################################################
184-
# Significant command-line variable definitions #
185-
################################################################################
186-
187-
# "CMAKE_BUILD_TYPE"
188-
# Elemental requires it to be one of the following choices:
189-
# 1. "PureDebug": Vanilla MPI build meant for development and debugging
190-
# 2. "PureRelease": Vanilla MPI build meant for production runs
191-
# 3. "HybridDebug": MPI+OpenMP build meant for development and debugging
192-
# 4. "HybridRelease": MPI+OpenMP build meant for production runs
193-
# If "CMAKE_BUILD_TYPE" is not defined, the default is "PureRelease".
194-
195-
# "CXX_FLAGS"
196-
# Optimization and debugging/symbol flags
197-
198-
# "OpenMP_CXX_FLAGS"
199-
# Overrides the default compile flags for adding OpenMP support to CXX code
200-
201-
# TODO: Add list of MPI variables here, such as "MPI_CXX_COMPILE_FLAGS"
202-
203-
# TODO: Add discussion of "MATH_LIBS"
204-
205-
# TODO: Add discussion of "REFERENCE_ROOT"
206-
207-
# TODO: Check to see if there are any others...
208-
209-
################################################################################
210-
# Build logic starts here #
211-
################################################################################
160+
# Build logic
161+
# ===========
212162

213163
# Elemental must be built "out-of-source", so we start by ensuring that the
214164
# source and build directories are different.
@@ -242,13 +192,13 @@ endif()
242192
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_BUILD_TYPE)
243193

244194
# Set the basic compile flags from the build type
245-
if(NOT WIN32) # I forget why we need this guard
195+
if(NOT WIN32)
246196
set(LANGUAGES CXX C Fortran)
247197
foreach(LANG ${LANGUAGES})
248198
if(NOT ${LANG}_FLAGS)
249199
if(EL_DEBUG)
250-
set(${LANG}_FLAGS "-O2 -g -Wunused-variable -Wunused-but-set-variable -Wunused-local-typedefs" CACHE STRING
251-
#set(${LANG}_FLAGS "-O2 -g" CACHE STRING
200+
#set(${LANG}_FLAGS "-O2 -g -Wunused-variable -Wunused-but-set-variable -Wunused-local-typedefs" CACHE STRING
201+
set(${LANG}_FLAGS "-O2 -g" CACHE STRING
252202
"${LANG} optimization/debug flags for ${UPPER_BUILD_TYPE} mode")
253203
else()
254204
set(${LANG}_FLAGS "-O3" CACHE STRING
@@ -258,6 +208,62 @@ if(NOT WIN32) # I forget why we need this guard
258208
endforeach()
259209
endif()
260210

211+
if(BUILD_PARMETIS)
212+
message(FATAL_ERROR "ParMETIS cannot be legally distributed with Elemental under a permissive license. A version of Elemental restricted to educational purposes which contains ParMETIS will hopefully soon be available.")
213+
# add_subdirectory(external/parmetis)
214+
# set(EL_HAVE_METIS TRUE)
215+
# set(EL_HAVE_PARMETIS TRUE)
216+
#
217+
# set(PARMETIS_ROOT ${PROJECT_SOURCE_DIR}/external/parmetis)
218+
# set(METIS_ROOT ${PROJECT_SOURCE_DIR}/external/parmetis/metis)
219+
# set(GKLIB_INCLUDE_DIR ${PROJECT_BINARY_DIR}/external/parmetis/include)
220+
#
221+
# include_directories(${GKLIB_INCLUDE_DIR})
222+
# include_directories(${METIS_ROOT}/include)
223+
# include_directories(${PARMETIS_ROOT}/include)
224+
elseif(METIS_ROOT AND PARMETIS_ROOT)
225+
message(FATAL_ERROR "ParMETIS cannot be legally distributed with Elemental under a permissive license. A version of Elemental restricted to educational purposes which contains ParMETIS will hopefully soon be available.")
226+
# set(EL_HAVE_METIS TRUE)
227+
# set(EL_HAVE_PARMETIS TRUE)
228+
# if(PARMETIS_TLS_PATCH)
229+
# include_directories(${GKLIB_INCLUDE_DIR})
230+
# endif()
231+
#
232+
# include_directories(${METIS_ROOT}/include)
233+
# include_directories(${PARMETIS_ROOT}/include)
234+
# set(MANUAL_PARMETIS TRUE)
235+
elseif(BUILD_METIS)
236+
add_subdirectory(external/metis)
237+
238+
set(METIS_ROOT ${PROJECT_SOURCE_DIR}/external/metis)
239+
include_directories(${METIS_ROOT}/include)
240+
241+
set(EL_HAVE_METIS TRUE)
242+
else()
243+
if(NOT METIS_ROOT)
244+
message(FATAL_ERROR
245+
"If METIS is not to be built, then METIS_ROOT must be specified")
246+
endif()
247+
include_directories(${METIS_ROOT}/include)
248+
249+
set(EL_HAVE_METIS TRUE)
250+
set(MANUAL_METIS TRUE)
251+
endif()
252+
253+
if(BUILD_KISSFFT)
254+
add_subdirectory(external/kiss_fft)
255+
include_directories(external/kiss_fft)
256+
elseif(KISSFFT_INCLUDE_DIR AND KISSFFT_LIBS)
257+
include_directories(${KISSFFT_INCLUDE_DIR})
258+
set(MANUAL_KISSFFT TRUE)
259+
endif()
260+
261+
if(BUILD_SHARED_LIBS AND WIN32)
262+
option(EL_DECLSPEC "Use __declspec(dllexport)?" ON)
263+
else()
264+
option(EL_DECLSPEC "Use __declspec(dllexport)?" OFF)
265+
endif()
266+
261267
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
262268
include(tests/Fortran)
263269
include(tests/CXX)
@@ -313,9 +319,9 @@ set(MPI_CXX_LIBSTRING)
313319
foreach(LIB ${MPI_CXX_LIBRARIES})
314320
set(MPI_CXX_LIBSTRING "${MPI_CXX_LIBSTRING} ${LIB}")
315321
endforeach()
316-
set(LAPACK_ADDONSTRING)
317-
foreach(LIB ${LAPACK_ADDONS_LIBS})
318-
set(LAPACK_ADDONSTRING "${LAPACK_ADDONSTRING} ${LIB}")
322+
set(METIS_LIBSTRING)
323+
foreach(LIB ${METIS_LIBS})
324+
set(METIS_LIBSTRING "${METIS_LIBSTRING} ${LIB}")
319325
endforeach()
320326
set(QT5_DEFSTRING)
321327
foreach(DEF ${Qt5Widgets_DEFINITIONS})
@@ -329,6 +335,7 @@ set(QT5_COMPILESTRING)
329335
foreach(FLAG ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS})
330336
set(QT5_COMPILESTRING "${QT5_COMPILE_STRING} ${FLAG}")
331337
endforeach()
338+
# TODO: Generalize this for non-Unix architectures
332339
set(QT5_LIBSTRING "-L${Qt5_LIBDIR} -lQt5Widgets -lQt5Gui -lQt5Core")
333340
configure_file(${PROJECT_SOURCE_DIR}/cmake/ElVars.cmake
334341
${PROJECT_BINARY_DIR}/conf/ElVars @ONLY)
@@ -390,8 +397,6 @@ add_custom_target(prepare_El_headers DEPENDS ${PREPARED_HEADERS})
390397
add_dependencies(El prepare_El_headers)
391398

392399
if(BUILD_SHARED_LIBS)
393-
# Install the python interface
394-
option(INSTALL_PYTHON_PACKAGE "Install python wrappers as package" TRUE)
395400
if(INSTALL_PYTHON_PACKAGE)
396401
if(NOT PYTHON_SITE_PACKAGES)
397402
execute_process(

0 commit comments

Comments
 (0)