1
# - Find ADIOS library, routines for scientific, parallel IO
2
# https://www.olcf.ornl.gov/center-projects/adios/
4
# Use this module by invoking find_package with the form:
6
# [version] [EXACT] # Minimum or EXACT version, e.g. 1.6.0
7
# [REQUIRED] # Fail with an error if ADIOS or a required
8
# # component is not found
10
# [COMPONENTS <...>] # Compiled in components: fortran, readonly,
11
# sequential (all are case insentative)
14
# Module that finds the includes and libraries for a working ADIOS install.
15
# This module invokes the `adios_config` script that should be installed with
16
# the other ADIOS tools.
18
# To provide a hint to the module where to find the ADIOS installation,
19
# set the ADIOS_ROOT environment variable.
21
# If this variable is not set, make sure that at least the according `bin/`
22
# directory of ADIOS is in your PATH environment variable.
24
# Set the following CMake variables BEFORE calling find_packages to
25
# influence this module:
26
# ADIOS_USE_STATIC_LIBS - Set to ON to force the use of static
27
# libraries. Default: OFF
29
# This module will define the following variables:
30
# ADIOS_INCLUDE_DIRS - Include directories for the ADIOS headers.
31
# ADIOS_LIBRARIES - ADIOS libraries.
32
# ADIOS_FOUND - TRUE if FindADIOS found a working install
33
# ADIOS_VERSION - Version in format Major.Minor.Patch
36
# ADIOS_DEFINITIONS - Compiler definitions you should add with
37
# add_definitions(${ADIOS_DEFINITIONS})
39
# Example to find ADIOS (default)
42
# include_directories(${ADIOS_INCLUDE_DIRS})
43
# add_executable(foo foo.c)
44
# target_link_libraries(foo ${ADIOS_LIBRARIES})
47
# Example to find ADIOS using component
48
# find_package(ADIOS COMPONENTS fortran)
50
# include_directories(${ADIOS_INCLUDE_DIRS})
51
# add_executable(foo foo.c)
52
# target_link_libraries(foo ${ADIOS_LIBRARIES})
54
###############################################################################
55
#Copyright (c) 2014, Axel Huebl and Felix Schmitt from http://picongpu.hzdr.de
58
#Redistribution and use in source and binary forms, with or without
59
#modification, are permitted provided that the following conditions are met:
61
#1. Redistributions of source code must retain the above copyright notice, this
62
#list of conditions and the following disclaimer.
64
#2. Redistributions in binary form must reproduce the above copyright notice,
65
#this list of conditions and the following disclaimer in the documentation
66
#and/or other materials provided with the distribution.
68
#3. Neither the name of the copyright holder nor the names of its contributors
69
#may be used to endorse or promote products derived from this software without
70
#specific prior written permission.
72
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
73
#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
74
#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
75
#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
76
#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
77
#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
78
#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
79
#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
80
#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
81
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
82
###############################################################################
85
###############################################################################
86
# Required cmake version
87
###############################################################################
89
cmake_minimum_required(VERSION 2.8.5)
92
###############################################################################
94
###############################################################################
95
# get flags for adios_config, -l is the default
96
#-f for fortran, -r for readonly, -s for sequential (nompi)
98
if(ADIOS_FIND_COMPONENTS)
99
foreach(COMP ${ADIOS_FIND_COMPONENTS})
100
string(TOLOWER ${COMP} comp)
101
if(comp STREQUAL "fortran")
102
set(OPTLIST ${OPTLIST} f)
103
elseif(comp STREQUAL "readonly")
104
set(OPTLIST ${OPTLIST} r)
105
elseif(comp STREQUAL "sequential")
106
set(OPTLIST ${OPTLIST} s)
108
message("ADIOS component ${COMP} is not supported. Please use fortran, readonly, or sequential")
112
string(REGEX REPLACE ";" "" OPTLIST "${OPTLIST}")
114
# we start by assuming we found ADIOS and falsify it if some
115
# dependencies are missing (or if we did not find ADIOS at all)
116
set(ADIOS_FOUND TRUE)
119
# find `adios_config` program #################################################
120
# check the ADIOS_ROOT hint and the normal PATH
121
find_file(ADIOS_CONFIG
123
PATHS $ENV{ADIOS_ROOT}/bin $ENV{ADIOS_DIR}/bin $ENV{INSTALL_PREFIX}/bin $ENV{PATH})
126
message(STATUS "Found 'adios_config': ${ADIOS_CONFIG}")
128
set(ADIOS_FOUND FALSE)
129
message(STATUS "Can NOT find 'adios_config' - set ADIOS_ROOT, ADIOS_DIR or INSTALL_PREFIX, or check your PATH")
132
# check `adios_config` program ################################################
134
execute_process(COMMAND ${ADIOS_CONFIG} ${OPTLIST}
135
OUTPUT_VARIABLE ADIOS_LINKFLAGS
136
RESULT_VARIABLE ADIOS_CONFIG_RETURN
137
OUTPUT_STRIP_TRAILING_WHITESPACE)
138
if(NOT ADIOS_CONFIG_RETURN EQUAL 0)
139
set(ADIOS_FOUND FALSE)
140
message(STATUS "Can NOT execute 'adios_config' - check file permissions")
143
# find ADIOS_ROOT_DIR
144
execute_process(COMMAND ${ADIOS_CONFIG} -d
145
OUTPUT_VARIABLE ADIOS_ROOT_DIR
146
OUTPUT_STRIP_TRAILING_WHITESPACE)
147
if(NOT IS_DIRECTORY "${ADIOS_ROOT_DIR}")
148
set(ADIOS_FOUND FALSE)
149
message(STATUS "The directory provided by 'adios_config -d' does not exist: ${ADIOS_ROOT_DIR}")
153
# option: use only static libs ################################################
154
if(ADIOS_USE_STATIC_LIBS)
155
# carfully: we have to restore the original path in the end
156
set(_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
157
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
161
# we found something in ADIOS_ROOT_DIR and adios_config works #################
164
list(APPEND ADIOS_INCLUDE_DIRS ${ADIOS_ROOT_DIR}/include)
166
# check for compiled in dependencies
167
message(STATUS "ADIOS linker flags (unparsed): ${ADIOS_LINKFLAGS}")
169
# find all library paths -L
170
# note: this can cause trouble if some libs are specified twice from
171
# different sources (quite unlikely)
172
# http://www.cmake.org/pipermail/cmake/2008-November/025128.html
173
set(ADIOS_LIBRARY_DIRS "")
174
string(REGEX MATCHALL "-L([A-Za-z_0-9/\\.-]+)" _ADIOS_LIBDIRS "${ADIOS_LINKFLAGS}")
175
foreach(_LIBDIR ${_ADIOS_LIBDIRS})
176
string(REPLACE "-L" "" _LIBDIR ${_LIBDIR})
177
list(APPEND ADIOS_LIBRARY_DIRS ${_LIBDIR})
179
# we could append ${CMAKE_PREFIX_PATH} now but that is not really necessary
181
#message(STATUS "ADIOS DIRS to look for libs: ${ADIOS_LIBRARY_DIRS}")
183
# parse all -lname libraries and find an absolute path for them
184
string(REGEX MATCHALL "-l([A-Za-z_0-9\\.-]+)" _ADIOS_LIBS "${ADIOS_LINKFLAGS}")
185
foreach(_LIB ${_ADIOS_LIBS})
186
string(REPLACE "-l" "" _LIB ${_LIB})
188
# find static lib: absolute path in -L then default
189
find_library(_LIB_DIR NAMES ${_LIB} PATHS ${ADIOS_LIBRARY_DIRS})
193
message(STATUS "Found ${_LIB} in ${_LIB_DIR}")
194
list(APPEND ADIOS_LIBRARIES "${_LIB_DIR}")
196
set(ADIOS_FOUND FALSE)
197
message(STATUS "ADIOS: Could NOT find library '${_LIB}'")
201
unset(_LIB_DIR CACHE)
205
#add libraries which are already using cmake format
206
string(REGEX MATCHALL "/([A-Za-z_0-9/\\.-]+)\\.([a|so]+)" _ADIOS_LIBS_SUB "${ADIOS_LINKFLAGS}")
207
list(APPEND ADIOS_LIBRARIES "${_ADIOS_LIBS_SUB}")
209
# add the version string
210
execute_process(COMMAND ${ADIOS_CONFIG} -v
211
OUTPUT_VARIABLE ADIOS_VERSION
212
OUTPUT_STRIP_TRAILING_WHITESPACE)
216
# unset checked variables if not found
218
unset(ADIOS_INCLUDE_DIRS)
219
unset(ADIOS_LIBRARIES)
220
endif(NOT ADIOS_FOUND)
223
# restore CMAKE_FIND_LIBRARY_SUFFIXES if manipulated by this module ###########
224
if(ADIOS_USE_STATIC_LIBS)
225
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
229
###############################################################################
230
# FindPackage Options
231
###############################################################################
233
# handles the REQUIRED, QUIET and version-related arguments for find_package
234
include(FindPackageHandleStandardArgs)
235
find_package_handle_standard_args(ADIOS
236
REQUIRED_VARS ADIOS_LIBRARIES ADIOS_INCLUDE_DIRS
237
VERSION_VAR ADIOS_VERSION