Skip to content
Snippets Groups Projects
Commit 696810f4 authored by Atkins, Charles Vernon's avatar Atkins, Charles Vernon
Browse files

CMake: Allow auto-detection of default options

parent 853a9325
No related branches found
No related tags found
1 merge request!134CMake: Allow auto-detection of default options
Showing
with 179 additions and 77 deletions
......@@ -37,6 +37,7 @@ endif()
#------------------------------------------------------------------------------#
# Top level options
#------------------------------------------------------------------------------#
include(ADIOSFunctions)
# Default to a debug build if not specified
if(NOT CMAKE_BUILD_TYPE)
......@@ -54,33 +55,30 @@ get_property(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
cmake_dependent_option(ADIOS_BUILD_SHARED_LIBS
"Whether or not to build shared libraries" ON
"SHARED_LIBS_SUPPORTED" OFF)
if(SHARED_LIBS_SUPPORTED)
cmake_dependent_option(ADIOS_ENABLE_PIC
"Build with Position Independent Code" ON
"NOT ADIOS_BUILD_SHARED_LIBS" ON)
endif()
cmake_dependent_option(ADIOS_ENABLE_PIC
"Build with Position Independent Code" ON
"SHARED_LIBS_SUPPORTED" OFF)
set(BUILD_SHARED_LIBS ${ADIOS_BUILD_SHARED_LIBS})
if(ADIOS_ENABLE_PIC)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
option(ADIOS_USE_MPI "Enable the MPI version of ADIOS" OFF)
if(ADIOS_USE_MPI)
adios_option(BZip2 "Enable support for BZip2 transforms" AUTO)
adios_option(ZFP "Enable support for ZFP transforms" AUTO)
adios_option(MPI "Enable support for MPI" AUTO)
adios_option(DataMan "Enable support for DataMan" AUTO)
adios_option(ZeroMQ "Enable support for ZeroMQ" AUTO)
adios_option(HDF5 "Enable support for the HDF5 engine" AUTO)
adios_option(ADIOS1 "Enable support for the ADIOS 1 engine" AUTO)
adios_option(Python "Enable support for Python bindings" AUTO)
include(${ADIOS_SOURCE_DIR}/cmake/DetectOptions.cmake)
if(ADIOS_HAVE_MPI)
# Workaround for OpenMPI forcing the link of C++ bindings
add_definitions(-DOMPI_SKIP_MPICXX)
endif()
option(ADIOS_USE_BZip2 "Enable support for BZip2 transforms" OFF)
option(ADIOS_USE_ZFP "Enable support for ZFP transforms" OFF)
option(ADIOS_USE_ADIOS1 "Enable support for the ADIOS 1 engine" OFF)
option(ADIOS_USE_HDF5 "Enable support for the HDF5 engine" OFF)
option(ADIOS_USE_Python "Enable support for Python bindings" OFF)
# DataMan is not a user-settable option. It will always be enabled if the
# platform supports it.
set(ADIOS_USE_DataMan ${SHARED_LIBS_SUPPORTED})
include(GenerateADIOSConfig)
GenerateADIOSConfig(MPI ZFP BZip2 ADIOS1 HDF5 DataMan Python)
install(
FILES ${ADIOS_BINARY_DIR}/adios2/ADIOSConfig.h
......@@ -141,13 +139,13 @@ else()
endif()
message(" Build Type: ${CMAKE_BUILD_TYPE}")
message(" Testing: ${BUILD_TESTING}")
message(" MPI: ${ADIOS_USE_MPI}")
message(" BZip2: ${ADIOS_USE_BZip2}")
message(" ZFP: ${ADIOS_USE_ZFP}")
message(" ADIOS1: ${ADIOS_USE_ADIOS1}")
message(" DataMan: ${ADIOS_USE_DataMan}")
message(" ZeroMQ: ${ADIOS_USE_DataMan_ZeroMQ}")
message(" ZFP: ${ADIOS_USE_DataMan_ZFP}")
message(" HDF5: ${ADIOS_USE_HDF5}")
message(" Python: ${ADIOS_USE_Python}")
message(" Build Options:")
foreach(opt BZip2 ZFP MPI DataMan ZeroMQ HDF5 ADIOS1 Python)
message_pad(" ${opt}" 13 label)
if(${ADIOS_HAVE_${opt}})
message("${label}: ON")
else()
message("${label}: OFF")
endif()
endforeach()
message("")
if(ADIOS_USE_Python)
if(ADIOS_HAVE_Python)
add_subdirectory(python)
endif()
......@@ -18,7 +18,7 @@ pybind11_add_module(adios2py MODULE
VariablePy.cpp
)
target_link_libraries(adios2py PRIVATE adios2)
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(PythonModule REQUIRED COMPONENTS mpi4py mpi4py/mpi4py.h)
target_link_libraries(adios2py PRIVATE PythonModule::mpi4py)
endif()
......
......@@ -6,7 +6,7 @@
function(GenerateADIOSConfig)
foreach(OPT IN LISTS ARGN)
string(TOUPPER ${OPT} OPT_UPPER)
if(ADIOS_USE_${OPT})
if(ADIOS_HAVE_${OPT})
set(ADIOS2_HAVE_${OPT_UPPER} 1)
else()
set(ADIOS2_HAVE_${OPT_UPPER})
......@@ -18,3 +18,22 @@ function(GenerateADIOSConfig)
${ADIOS_BINARY_DIR}/adios2/ADIOSConfig.h
)
endfunction()
function(adios_option name description default)
set(ADIOS_USE_${name} ${default} CACHE STRING "${description}")
set_property(CACHE ADIOS_USE_${name} PROPERTY
STRINGS "ON;TRUE;AUTO;OFF;FALSE"
)
endfunction()
function(message_pad msg out_len out_msg)
string(LENGTH "${msg}" msg_len)
if(NOT (msg_len LESS out_len))
set(${out_msg} "${msg}" PARENT_SCOPE)
else()
math(EXPR pad_len "${out_len} - ${msg_len}")
string(RANDOM LENGTH ${pad_len} pad)
string(REGEX REPLACE "." " " pad "${pad}")
set(${out_msg} "${msg}${pad}" PARENT_SCOPE)
endif()
endfunction()
#------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0. See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
# This file contains the option and dependency logic. The configuration
# options are designed to be tertiary: ON, OFF, or AUTO. If AUTO, we try to
# determine if dependencies are available and enable the option if we find
# them, otherwise we disable it. If explicitly ON then a failure to find
# dependencies is an error,
# BZip2
if(ADIOS_USE_BZip2 STREQUAL AUTO)
find_package(BZip2)
if(BZIP2_FOUND)
set(ADIOS_HAVE_BZip2 TRUE)
endif()
elseif(ADIOS_USE_BZip2)
set(ADIOS_HAVE_BZip2 TRUE)
endif()
# ZFP
if(ADIOS_USE_ZFP STREQUAL AUTO)
find_package(ZFP)
if(ZFP_FOUND)
set(ADIOS_HAVE_ZFP TRUE)
endif()
elseif(ADIOS_USE_ZFP)
set(ADIOS_HAVE_ZFP TRUE)
endif()
# MPI
if(ADIOS_USE_MPI STREQUAL AUTO)
find_package(MPI COMPONENTS C)
if(MPI_FOUND)
set(ADIOS_HAVE_MPI TRUE)
endif()
elseif(ADIOS_USE_MPI)
set(ADIOS_HAVE_MPI TRUE)
endif()
# DataMan
if(ADIOS_USE_DataMan STREQUAL AUTO)
if(SHARED_LIBS_SUPPORTED AND NOT MSVC)
set(ADIOS_HAVE_DataMan TRUE)
endif()
elseif(ADIOS_USE_DataMan)
set(ADIOS_HAVE_DataMan TRUE)
endif()
# ZeroMQ
if(ADIOS_USE_ZeroMQ STREQUAL AUTO)
find_package(ZeroMQ)
if(ZeroMQ_FOUND)
set(ADIOS_HAVE_ZeroMQ TRUE)
endif()
elseif(ADIOS_USE_ZeroMQ)
set(ADIOS_HAVE_ZeroMQ TRUE)
endif()
# HDF5
if(ADIOS_USE_HDF5 STREQUAL AUTO)
find_package(HDF5 COMPONENTS C)
if(HDF5_FOUND AND
((ADIOS_HAVE_MPI AND HDF5_IS_PARALLEL) OR
NOT (ADIOS_HAVE_MPI OR HDF5_IS_PARALLEL)))
set(ADIOS_HAVE_HDF5 TRUE)
endif()
elseif(ADIOS_USE_HDF5)
set(ADIOS_HAVE_HDF5 TRUE)
endif()
# ADIOS1
if(ADIOS_USE_ADIOS1 STREQUAL AUTO)
if(NOT ADIOS_HAVE_MPI)
set(adios1_args COMPONENTS sequential)
endif()
find_package(ADIOS1 1.12.0 ${adios1_args})
unset(adios1_args)
if(ADIOS1_FOUND)
set(ADIOS_HAVE_ADIOS1 TRUE)
endif()
elseif(ADIOS_USE_ADIOS1)
set(ADIOS_HAVE_ADIOS1 TRUE)
endif()
# Python
if(ADIOS_USE_Python STREQUAL AUTO)
if(BUILD_SHARED_LIBS)
find_package(PythonLibs)
if(PYTHONLIBS_FOUND)
if(ADIOS_HAVE_MPI)
find_package(PythonModule COMPONENTS mpi4py mpi4py/mpi4py.h)
if(PythonModule_mpi4py_FOUND)
set(ADIOS_HAVE_Python TRUE)
endif()
else()
set(ADIOS_HAVE_Python TRUE)
endif()
endif()
endif()
elseif(ADIOS_USE_Python)
set(ADIOS_HAVE_Python TRUE)
endif()
......@@ -4,14 +4,10 @@
#------------------------------------------------------------------------------#
add_executable(globalArray_write globalArray_write.cpp)
target_link_libraries(globalArray_write adios2)
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
target_include_directories(globalArray_write PRIVATE ${MPI_C_INCLUDE_PATH})
target_link_libraries(globalArray_write ${MPI_C_LIBRARIES})
endif()
target_link_libraries(globalArray_write adios2)
......@@ -4,14 +4,10 @@
#------------------------------------------------------------------------------#
add_executable(joinedArray_write joinedArray_write.cpp)
target_link_libraries(joinedArray_write adios2)
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
target_include_directories(joinedArray_write PRIVATE ${MPI_C_INCLUDE_PATH})
target_link_libraries(joinedArray_write ${MPI_C_LIBRARIES})
endif()
target_link_libraries(joinedArray_write adios2)
......@@ -4,14 +4,10 @@
#------------------------------------------------------------------------------#
add_executable(localArray_write localArray_write.cpp)
target_link_libraries(localArray_write adios2)
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
target_include_directories(localArray_write PRIVATE ${MPI_C_INCLUDE_PATH})
target_link_libraries(localArray_write ${MPI_C_LIBRARIES})
endif()
target_link_libraries(localArray_write adios2)
......@@ -4,14 +4,10 @@
#------------------------------------------------------------------------------#
add_executable(values_write values_write.cpp)
target_link_libraries(values_write adios2)
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
target_include_directories(values_write PRIVATE ${MPI_C_INCLUDE_PATH})
target_link_libraries(values_write ${MPI_C_LIBRARIES})
endif()
target_link_libraries(values_write adios2)
......@@ -3,6 +3,6 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
if(ADIOS_USE_ADIOS1)
if(ADIOS_HAVE_ADIOS1)
add_subdirectory(multistep)
endif()
......@@ -6,8 +6,11 @@
add_executable(writer_multistep writer_multistep.cpp)
add_executable(reader_stepping reader_stepping.cpp)
add_executable(reader_allsteps reader_allsteps.cpp)
target_link_libraries(writer_multistep adios2)
target_link_libraries(reader_stepping adios2)
target_link_libraries(reader_allsteps adios2)
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
target_include_directories(writer_multistep PRIVATE ${MPI_C_INCLUDE_PATH})
......@@ -18,10 +21,4 @@ if(ADIOS_USE_MPI)
target_include_directories(reader_allsteps PRIVATE ${MPI_C_INCLUDE_PATH})
target_link_libraries(reader_allsteps ${MPI_C_LIBRARIES})
endif()
target_link_libraries(writer_multistep adios2)
target_link_libraries(reader_stepping adios2)
target_link_libraries(reader_allsteps adios2)
......@@ -4,7 +4,7 @@
#------------------------------------------------------------------------------#
if(ADIOS_USE_ADIOS1)
if(ADIOS_HAVE_ADIOS1)
add_subdirectory(write)
add_subdirectory(read)
endif()
......
......@@ -3,7 +3,7 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
add_executable(heatTransfer_read_adios2 heatRead_adios2.cpp PrintData.cpp)
......@@ -14,7 +14,7 @@ if(ADIOS_USE_MPI)
adios2 ${MPI_C_LIBRARIES}
)
if(ADIOS_USE_ADIOS1)
if(ADIOS_HAVE_ADIOS1)
find_package(ADIOS1 REQUIRED)
add_executable(heatTransfer_read_adios1 heatRead_adios1.cpp PrintData.cpp)
......
......@@ -3,7 +3,7 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
add_executable(heatTransfer_write_adios2
......@@ -17,7 +17,7 @@ if(ADIOS_USE_MPI)
)
target_link_libraries(heatTransfer_write_adios2 adios2 ${MPI_C_LIBRARIES})
if(ADIOS_USE_ADIOS1)
if(ADIOS_HAVE_ADIOS1)
find_package(ADIOS1 REQUIRED)
find_package(MPI COMPONENTS C REQUIRED)
......@@ -35,7 +35,7 @@ if(ADIOS_USE_MPI)
)
endif()
if(ADIOS_USE_HDF5)
if(ADIOS_HAVE_HDF5)
find_package(HDF5 REQUIRED)
find_package(MPI COMPONENTS C REQUIRED)
......@@ -54,7 +54,7 @@ if(ADIOS_USE_MPI)
endif()
if(ADIOS_USE_HDF5)
if(ADIOS_HAVE_HDF5)
find_package(HDF5 REQUIRED)
find_package(MPI COMPONENTS C REQUIRED)
......@@ -73,7 +73,7 @@ if(ADIOS_USE_MPI)
endif()
if(ADIOS_USE_HDF5)
if(ADIOS_HAVE_HDF5)
find_package(MPI COMPONENTS C REQUIRED)
add_executable(heatTransfer_write_a2h5
......
......@@ -7,15 +7,15 @@ add_subdirectory(bpWriter)
add_subdirectory(bpTimeWriter)
add_subdirectory(bpFlushWriter)
if(ADIOS_USE_ADIOS1)
if(ADIOS_HAVE_ADIOS1)
add_subdirectory(adios1Writer)
endif()
if(ADIOS_USE_DataMan)
if(ADIOS_HAVE_DataMan)
add_subdirectory(datamanReader)
add_subdirectory(datamanWriter)
endif()
if(ADIOS_USE_HDF5)
if(ADIOS_HAVE_HDF5)
add_subdirectory(hdf5Writer)
endif()
......@@ -3,7 +3,7 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
add_executable(hello_adios1Writer helloADIOS1Writer.cpp)
......
......@@ -3,7 +3,7 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
add_executable(hello_bpFlushWriter helloBPFlushWriter.cpp)
......
......@@ -3,7 +3,7 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
add_executable(hello_bpTimeWriter helloBPTimeWriter.cpp)
......
......@@ -3,7 +3,7 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
add_executable(hello_bpWriter helloBPWriter.cpp)
......
......@@ -3,7 +3,7 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
if(ADIOS_USE_MPI)
if(ADIOS_HAVE_MPI)
find_package(MPI COMPONENTS C REQUIRED)
add_executable(hello_datamanReader helloDataManReader.cpp)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment