CMakeLists.txt 10.6 KB
Newer Older
1
2
3
4
5
#------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0.  See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#

6
cmake_minimum_required(VERSION 3.6)
7
8
9
10
11
12
13
14

# Fail immediately if not using an out-of-source build
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
  message(FATAL_ERROR
    "In-source builds are not supported.  Please create a build directory "
    "separate from the source directory")
endif()

15
project(ADIOS2 VERSION 2.3.1)
16
17
18
if(POLICY CMP0074)
  cmake_policy(SET CMP0074 NEW)
endif()
19
20
21
22

#------------------------------------------------------------------------------#
# Some boilerplate to setup nice output directories
#------------------------------------------------------------------------------#
Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
23
include(GNUInstallDirs)
Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
24
25
26
set(CMAKE_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/adios2
  CACHE STRING "Installation CMake subdirectory")
mark_as_advanced(CMAKE_INSTALL_CMAKEDIR)
27

28
list(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR}/cmake")
29
30
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
31
    ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
32
33
34
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
35
    ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
36
37
38
endif()
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
39
    ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
40
41
endif()

42
43
44
# Let windows builds auto-export dll symbols
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)

45
46
47
48
49
50
51
52
53
54
55
56
57
#------------------------------------------------------------------------------#
# Silence MSVC warnings
#------------------------------------------------------------------------------#

if(MSVC)
  add_definitions(
    -D_CRT_SECURE_NO_DEPRECATE
    -D_CRT_SECURE_NO_WARNINGS
    -D_SCL_SECURE_NO_DEPRECATE
    -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
  )
endif()

58
59
60
61
62
#------------------------------------------------------------------------------#
# Deal with any pre-installation cleanup tasks
#------------------------------------------------------------------------------#
add_subdirectory(cmake/install/pre)

63
64
65
#------------------------------------------------------------------------------#
# Top level options
#------------------------------------------------------------------------------#
66
include(ADIOSFunctions)
67

68
# Default to a debug build if not specified
69
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
70
  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
71
72
endif()

73
74
75
# Force C++11 and C99
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
76
77
78
79
if(NOT MSVC)
  set(CMAKE_C_STANDARD 99)
  set(CMAKE_C_STANDARD_REQUIRED True)
endif()
80

81
82
# Use meta-compile features if available, otherwise use specific language
# features
83
84
if(CMAKE_VERSION VERSION_LESS 3.9 OR
   CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang|MSVC)$")
85
  set(ADIOS2_CXX11_FEATURES cxx_auto_type cxx_nullptr)
86
87
88
89
90
else()
  set(ADIOS2_CXX11_FEATURES cxx_std_11)
endif()
if(CMAKE_VERSION VERSION_LESS 3.9 OR
   CMAKE_C_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang|MSVC)$")
91
  set(ADIOS2_C99_FEATURES c_restrict)
92
93
else()
  set(ADIOS2_C99_FEATURES c_std_99)
94
endif()
95
96
97

include(CMakeDependentOption)

98
# Setup shared library defaults.  If explicitly specified somehow, then default
99
100
# to that.  Otherwise base the default on whether or not shared libs are even
# supported.
101
get_property(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
102
103
cmake_dependent_option(BUILD_SHARED_LIBS
  "Build shared libraries (so/dylib/dll)." ${SHARED_LIBS_SUPPORTED}
104
105
106
107
  "SHARED_LIBS_SUPPORTED" OFF
)
mark_as_advanced(BUILD_SHARED_LIBS)

Godoy, William F's avatar
Godoy, William F committed
108
adios_option(Blosc     "Enable support for Blosc transforms" AUTO)
109
adios_option(BZip2     "Enable support for BZip2 transforms" AUTO)
110
adios_option(ZFP       "Enable support for ZFP transforms" AUTO)
111
adios_option(SZ        "Enable support for SZ transforms" AUTO)
William F Godoy's avatar
William F Godoy committed
112
adios_option(MGARD     "Enable support for MGARD transforms" AUTO)
William F Godoy's avatar
William F Godoy committed
113
adios_option(PNG       "Enable support for PNG transforms" AUTO)
114
adios_option(MPI       "Enable support for MPI" AUTO)
115
adios_option(DataMan   "Enable support for DataMan" AUTO)
Ruonan Wang's avatar
Ruonan Wang committed
116
adios_option(SSC       "Enable support for SSC" AUTO)
117
adios_option(SST       "Enable support for SST" AUTO)
118
119
120
adios_option(ZeroMQ    "Enable support for ZeroMQ" AUTO)
adios_option(HDF5      "Enable support for the HDF5 engine" AUTO)
adios_option(Python    "Enable support for Python bindings" AUTO)
121
adios_option(Fortran   "Enable support for Fortran bindings" AUTO)
122
adios_option(SysVShMem "Enable support for SysV Shared Memory IPC on *NIX" AUTO)
123
adios_option(Profiling "Enable support for profiling" AUTO)
Godoy, William F's avatar
Godoy, William F committed
124
adios_option(Endian_Reverse "Enable support for Little/Big Endian Interoperability" AUTO)
125
include(${PROJECT_SOURCE_DIR}/cmake/DetectOptions.cmake)
126

127
if(ADIOS2_HAVE_MPI)
Godoy, William F's avatar
Godoy, William F committed
128
129
130
  if(MPIEXEC_MAX_NUMPROCS LESS 4 AND "$ENV{OMPI_MCA_rmaps_base_oversubscribe}")
    message(STATUS "OpenMPI oversubscribe detected: raising MPIEXEC_MAX_NUMPROCS to 4 for testing")
    set(MPIEXEC_MAX_NUMPROCS 4 CACHE STRING "" FORCE)
Godoy, William F's avatar
Godoy, William F committed
131
  endif()
Godoy, William F's avatar
Godoy, William F committed
132

133
134
  # Workaround for MPI forcing the link of C++ bindings
  add_definitions(-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX)
135
endif()
Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
136

137
set(ADIOS2_CONFIG_OPTS
Godoy, William F's avatar
Godoy, William F committed
138
    Blosc BZip2 ZFP SZ MGARD PNG MPI DataMan SSC SST ZeroMQ HDF5 Python Fortran SysVShMem Profiling Endian_Reverse
139
140
)
GenerateADIOSHeaderConfig(${ADIOS2_CONFIG_OPTS})
141
configure_file(
142
143
  ${PROJECT_SOURCE_DIR}/CTestCustom.cmake.in
  ${PROJECT_BINARY_DIR}/CTestCustom.cmake
144
145
  @ONLY
)
146

147
148
install(FILES ${PROJECT_BINARY_DIR}/source/adios2/common/ADIOSConfig.h
  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/adios2/common
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
#------------------------------------------------------------------------------#
# Some specialized shared library and RPATH handling
#------------------------------------------------------------------------------#
if(BUILD_SHARED_LIBS)
  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

  if(APPLE)
    # On Mac OS X, set the dir included as part of the installed library's path:
    if(NOT DEFINED CMAKE_INSTALL_NAME_DIR)
      set(CMAKE_INSTALL_NAME_DIR
        "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
    endif ()

    # Various homebrew MPI fortran installations break rpath usage on OSX
    if(APPLE AND ADIOS2_HAVE_Fortran AND ADIOS2_HAVE_MPI)
      set(CMAKE_MACOSX_RPATH OFF)
    endif()

  elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
    # Linux needs some specialized RPATH handling
    string(REGEX REPLACE "[^/]+" ".." relative_base "${CMAKE_INSTALL_LIBDIR}")
    set(CMAKE_INSTALL_RPATH "$ORIGIN/${relative_base}/${CMAKE_INSTALL_LIBDIR}")
  endif()
endif()

176
177
178
179
#------------------------------------------------------------------------------#
# Third party libraries
#------------------------------------------------------------------------------#
include(CTest)
180
mark_as_advanced(BUILD_TESTING)
181
182
add_subdirectory(thirdparty)

183
184
185
186
187
#------------------------------------------------------------------------------#
# Main library source
#------------------------------------------------------------------------------#
add_subdirectory(source)

188
189
190
191
192
#------------------------------------------------------------------------------#
# Language bindings
#------------------------------------------------------------------------------#
add_subdirectory(bindings)

193
194
195
#------------------------------------------------------------------------------#
# Testing
#------------------------------------------------------------------------------#
196
197
198
199
200
201
if(DEFINED BUILD_TESTING)
  set(ADIOS2_BUILD_TESTING_DEFAULT ${BUILD_TESTING})
else()
  set(ADIOS2_BUILD_TESTING_DEFAULT ON)
endif()
unset(BUILD_TESTING)
202
203
204
option(ADIOS2_BUILD_TESTING "Build the ADIOS2 testing tree" 
       ${ADIOS2_BUILD_TESTING_DEFAULT})
       
205
206
include(CTest)
set(BUILD_TESTING ${ADIOS2_BUILD_TESTING})
207
if(BUILD_TESTING)
208
209
210
211
212
  find_program(DIFF_EXECUTABLE diff)
  if(NOT DIFF_EXECUTABLE)
    message(FATAL_ERROR "diff command is required for testing")
  endif()

213
214
215
  enable_testing()
  add_subdirectory(testing)
endif()
Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
216

217
218
219
220
221
222
223
224
225
#------------------------------------------------------------------------------#
# Examples
#------------------------------------------------------------------------------#
option(ADIOS2_BUILD_EXAMPLES "Build examples" ON)
option(ADIOS2_BUILD_EXAMPLES_EXPERIMENTAL "Build experimental examples" OFF)
if(ADIOS2_BUILD_EXAMPLES)
  add_subdirectory(examples)
endif()

226
227
228
#------------------------------------------------------------------------------#
# Generating package configs
#------------------------------------------------------------------------------#
229
add_subdirectory(cmake/install/packaging)
230

231
232
233
234
#------------------------------------------------------------------------------#
# Generating static adios-config
#------------------------------------------------------------------------------#
add_subdirectory(cmake/install/post)
235

Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
236
237
238
239
240
#------------------------------------------------------------------------------#
# Configuration summary
#------------------------------------------------------------------------------#
message("")
message("ADIOS2 build configuration:")
241
message("  ADIOS Version: ${ADIOS2_VERSION}")
242
243
244
message("  C++ Compiler : ${CMAKE_CXX_COMPILER_ID} " 
                         "${CMAKE_CXX_COMPILER_VERSION} " 
                         "${CMAKE_CXX_COMPILER_WRAPPER}")
245
message("    ${CMAKE_CXX_COMPILER}")
Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
246
message("")
William F Godoy's avatar
William F Godoy committed
247
248
249
250
251
252
253
if(ADIOS2_HAVE_Fortran)
  message("  Fortran Compiler : ${CMAKE_Fortran_COMPILER_ID} "
                               "${CMAKE_Fortran_COMPILER_VERSION} "
                               "${CMAKE_Fortran_COMPILER_WRAPPER}")
  message("    ${CMAKE_Fortran_COMPILER}")
  message("")
endif()
Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
254
message("  Installation prefix: ${CMAKE_INSTALL_PREFIX}")
255
256
257
258
259
260
261
262
message("        bin: ${CMAKE_INSTALL_BINDIR}")
message("        lib: ${CMAKE_INSTALL_LIBDIR}")
message("    include: ${CMAKE_INSTALL_INCLUDEDIR}")
message("      cmake: ${CMAKE_INSTALL_CMAKEDIR}")
if(ADIOS2_HAVE_Python)
  message("     python: ${CMAKE_INSTALL_PYTHONDIR}")
endif()
message("")
Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
263
264
message("  Features:")
if(BUILD_SHARED_LIBS)
265
266
267
  set(msg_lib_type "shared")
elseif(CMAKE_POSITION_INDEPENDENT_CODE)
  set(msg_lib_type "static (with PIC)")
Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
268
else()
269
  set(msg_lib_type "static (without PIC)")
Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
270
endif()
271
message("    Library Type: ${msg_lib_type}")
272
message("    Build Type:   ${CMAKE_BUILD_TYPE}")
273
message("    Testing: ${BUILD_TESTING}")
274
message("    Build Options:")
275

276
foreach(opt IN LISTS ADIOS2_CONFIG_OPTS)
277
  message_pad("      ${opt}" 15 label)
278
  if(${ADIOS2_HAVE_${opt}})
279
280
281
282
283
    message("${label}: ON")
  else()
    message("${label}: OFF")
  endif()
endforeach()
284
285
286
287
288
if (ADIOS2_HAVE_SST AND ADIOS2_SST_HAVE_LIBFABRIC) 
message("    RDMA Transport for Staging: Available")
else()
message("    RDMA Transport for Staging: Unconfigured")
endif()
Atkins, Charles Vernon's avatar
Atkins, Charles Vernon committed
289
message("")